Documentation
¶
Overview ¶
Package helmversion deals with the two spellings a Helm chart version can have, and orders versions in a way which takes build metadata into account.
OCI registries do not allow a plus sign in a tag, so Helm publishes a chart whose version carries build metadata under a tag where the plus sign is replaced with an underscore: version 109.0.1+up1.0.2 lives in the tag 109.0.1_up1.0.2.
The semver specification also mandates that build metadata be ignored when comparing versions, which is unhelpful when the metadata is the only thing telling two versions apart. Comparison here therefore falls back to the metadata for versions semver considers equal, so that resolving a version against a set of tags always yields the same answer, whatever order the registry lists them in.
Index ¶
- func Compare(a, b *semver.Version) int
- func CompareMetadata(a, b string) int
- func Equal(a, b *semver.Version) bool
- func FromTag(tag string) string
- func IsExact(v string) bool
- func Normalize(v string) string
- func Parse(v string) (*semver.Version, error)
- func ParseExact(v string) (*semver.Version, bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
Compare orders two versions by precedence as semver defines it, and then, for versions semver considers equal, by build metadata. A version with metadata takes precedence over the same version without it, so that version 109.0.1 resolves to the build published as 109.0.1+up1.0.2, which is the chart a registry following the convention actually holds.
func CompareMetadata ¶
CompareMetadata orders two build metadata strings. The semver specification says nothing about their precedence, so they are compared the way it defines for pre-release strings: identifier by identifier, numerically wherever both identifiers are numeric. That keeps up1.0.10 above up1.0.2, which comparing the strings as a whole would not. Digits which are part of a longer identifier are not numbers of their own, again as for pre-release identifiers, so up10 does compare below up2.
func Equal ¶
Equal reports whether a and b are the same version, build metadata included. This is stricter than semver.Version.Equal, which ignores metadata and would therefore consider 1.1.2 and 1.1.2+build01 to be the same version.
func FromTag ¶
FromTag returns the version an OCI tag holds, restoring the build metadata separator Helm replaced to make the tag acceptable to a registry.
func IsExact ¶
IsExact reports whether v is a fully specified version, as opposed to a constraint which versions other than v may satisfy.
func Normalize ¶
Normalize returns v spelled as semver, accepting the tag spelling of build metadata users may copy from a registry's list of tags. Anything which is not a version, a version constraint in particular, is returned unchanged.
func Parse ¶
Parse parses a chart version, rejecting a version semver only accepts loosely, such as 1.2 for 1.2.0. Fleet hands the version it resolves on as the chart version, and a loose spelling is refused further down, before a single bundle deployment is created, so a tag holding one is no candidate at all.
A leading "v" is tolerated, as some Helm repositories publish their versions that way and Fleet accepts them
func ParseExact ¶
ParseExact parses v as a fully specified version, in either spelling of build metadata. It returns false for anything else, such as a version constraint, a partial version or an empty string.
A version parsed this way still leaves build metadata open unless it spells some out: 109.0.1 denotes every build of 109.0.1, whereas 109.0.1+up1.0.2 denotes that one build alone.
Types ¶
This section is empty.