Skip to content

Commit

Permalink
Rename field 'version.{metadata → build}'
Browse files Browse the repository at this point in the history
  • Loading branch information
mamachanko committed Sep 14, 2022
1 parent f93bb39 commit f9e68a5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions proposals/ytt/005-semver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ templates:
* I want to access a semver's components so that I can easily change its representation.
* I want to compare semvers, e.g. expect a given version to be larger than a known version.
* I want to (de,in)crement the major, minor and/or patch version of a semver.
* I want to add, change or remove a semver's prerelease identifier or metadata.
* I want to add, change or remove a semver's prerelease identifier or build metadata.

Starlark's standard library provides the means to achieve this. However, it sets a high bar and burdens configuration
authors to write boilerplate code for common, industry standard operations.

## Terminology / Concepts

A semantic version encodes different properties about the version in a string of the
form `<major>.<minor>.<patch>(-<pre-release>)(+<metadata>)`.
form `<major>.<minor>.<patch>(-<pre-release>)(+<build>)`.

Semantic versions can be sorted based on [precedence](https://semver.org/#spec-item-11).

Expand Down Expand Up @@ -92,9 +92,9 @@ load("@ytt:semver", "semver")

#### semver·version

`semver.version([major=int, minor=int, patch=int, prerelease=string, metadata=string])` returns a struct representing a
`semver.version([major=int, minor=int, patch=int, prerelease=string, build=string])` returns a struct representing a
semantic version. The fields `major`, `minor` and `patch` are strings and default to `0`. The fields `prerelease` and
`metadata` are strings and default to `None`. If any of the arguments are of the wrong type or contain forbidden
`build` are strings and default to `None`. If any of the arguments are of the wrong type or contain forbidden
characters, it is a dynamic error.

```yaml
Expand All @@ -103,7 +103,7 @@ characters, it is a dynamic error.
#@ semver.version() #! 0.0.0
#@ semver.version(1, 2, 3) #! 1.2.3
#@ semver.version(1, 2, 3, "beta") #! 1.2.3-beta
#@ semver.version(1, 2, 3, metadata="build.5") #! 1.2.3+build.5
#@ semver.version(1, 2, 3, build="build.5") #! 1.2.3+build.5
#@ semver.version(1, 2, 3, "next", "nightly") #! 1.2.3-next+nightly
#@ semver.version(minor=1, prerelease="alpha") #! 0.1.0-alpha
#@ semver.version(1, 2, -5) #! ⚡️ error
Expand All @@ -120,7 +120,7 @@ Use cases:
#@ load("@ytt:assert", "assert")

#@ v = semver.version(1, 2, 3)
#@ d = dict(major=v.major, minor=v.minor, patch=v.patch, prerelease=v.prerelease, metadata=v.metadata)
#@ d = dict(major=v.major, minor=v.minor, patch=v.patch, prerelease=v.prerelease, build=v.build)

--- #@ d

Expand All @@ -136,7 +136,7 @@ version.json: #@ json.encode(d)
#@ end

#@ forbidden = ["nightly", "dev"]
#@ if v.metadata in forbidden:
#@ if v.build in forbidden:
#@ assert.fail("Sorry, that version is forbidden")
#@ end
```
Expand All @@ -151,7 +151,7 @@ is malformed, it is a dynamic error.

#@ semver.from_str("1.2.3") #! semver.version(1, 2, 3)
#@ semver.from_str("1.2.3-pre") #! semver.version(1, 2, 3, "pre")
#@ semver.from_str("1.2.3+meta") #! semver.version(1, 2, 3, metadata="meta")
#@ semver.from_str("1.2.3+meta") #! semver.version(1, 2, 3, build="meta")
#@ semver.from_str("1.2.3-pre+meta") #! semver.version(1, 2, 3, "pre", "meta")
#@ semver.from_str("1.2.-5") #! ⚡️ error
#@ semver.from_str("Homer Simpson") #! ⚡️ error
Expand All @@ -167,7 +167,7 @@ is malformed, it is a dynamic error.
#@ semver.version().to_str() #! "0.0.0"
#@ semver.version(1, 2, 3).to_str() #! "1.2.3"
#@ semver.version(1, 2, 3, "beta").to_str() #! "1.2.3-beta"
#@ semver.version(1, 2, 3, metadata="build.5").to_str() #! "1.2.3+build.5"
#@ semver.version(1, 2, 3, build="build.5").to_str() #! "1.2.3+build.5"
#@ semver.version(1, 2, 3, "next", "nightly").to_str() #! "1.2.3-next+nightly"
#@ semver.version(minor=1, prerelease="alpha").to_str() #! "0.1.0-alpha"
```
Expand Down Expand Up @@ -226,7 +226,7 @@ ye_olde_confyg: they don't make 'em like this any more
#### version·(next_major, next_minor, next_patch)

All of `version.next_major()`, `version.next_minor()` and `version.next_patch()` return a new `version` and bump the
respective components. Existing `prerelease` and `metadata` are reset.
respective components. Existing `prerelease` and `build` are reset.

```yaml
#@ load("@ytt:semver", "semver")
Expand Down

0 comments on commit f9e68a5

Please sign in to comment.