Documentation
¶
Overview ¶
Package modversion is the library's one home for CUE module version helpers: the rules for turning a version as a caller or subscription writes it into the form CUE's module machinery requires, the major qualifier of a version, SemVer validity and precedence, and the constants for the core module path and the CUE language floor. It is the only package under opm/ that imports golang.org/x/mod/semver, the SemVer implementation CUE's own module code uses, so the library compares versions one way.
Index ¶
Constants ¶
const ( // CoreModule is the module path of the OPM core schema, without a major // qualifier. CoreModule = "opmodel.dev/core" // CorePath is the major-qualified core path the v2 kernel builds against. CorePath = CoreModule + "@v2" // LanguageFloor is the lowest CUE language version a generated or render // module declares: v0.17.0 introduced cue.mod/local-module.cue. LanguageFloor = "v0.17.0" )
Variables ¶
This section is empty.
Functions ¶
func Bare ¶
Bare returns v without the "v" prefix: the spelling a catalog's metadata.version carries and a platform registry entry stamps. It is the inverse of Canonical and validates nothing either.
func Canonical ¶
Canonical returns v with the "v" prefix CUE module versions require. A bare SemVer ("1.0.0") gains it; an already-prefixed or empty version is returned unchanged. It validates nothing: module.NewVersion remains the validator.
func Compare ¶
Compare orders a and b by SemVer precedence, returning -1, 0 or +1 and accepting either spelling on each side. Prerelease builds order by SemVer 2 precedence ("2.0.0-beta.2" < "2.0.0-beta.10" < "2.0.0") and build metadata is ignored. An invalid input is refused as `invalid version "<as written>"`.
func Major ¶
Major returns the "@vN" qualifier of a version in either spelling: "0.1.0" -> "v0", "v2.0.0-beta.1" -> "v2", "v2" -> "v2". Like Canonical and Bare it validates nothing: an invalid input yields "v" plus whatever precedes its first dot, and the module path built from it fails in CUE with CUE's own error.
Types ¶
This section is empty.