Documentation
¶
Overview ¶
Package versionutils parses and compares Nutanix version strings.
Nutanix products report versions as '.'-separated integers: a plain release version such as "3.5.2.1" from AOS, or a Prism Central version such as "2024.3.1" or "pc.7.6.0.5". Parse a version once, then compare it as often as needed:
minPC := versionutils.Parse("7.6")
if versionutils.Parse(pcVersion).AtLeast(minPC) {
// Prism Central is new enough.
}
Parse handles every Nutanix version format, so callers do not classify a version before parsing it. It normalizes away an optional "pc." prefix, surrounding whitespace and casing, and it knows that Prism Central moved from calendar versioning (202x.xx.xx) to a 7.x line, so a 7.x version is newer than any 202x.xx version despite comparing lower numerically. That rule is inert for AOS, which has no calendar-versioned releases.
Prism Element often truncates config.buildInfo.version (AOS 7.5.1 reports as "7.5") while fullVersion still carries the patch:
el8.5-release-ganges-7.5.1-stable-<commit>
Parse extracts the AOS token from that fullVersion form, ignoring a leading OS prefix (el8.5, ol9, …). When both fields are available, ParseReported combines them so a truncated short version is refined by fullVersion:
minAOS := versionutils.Parse("7.5.1")
if versionutils.ParseReported(short, full).AtLeast(minAOS) {
// Prism Element is new enough.
}
Unparsable versions ¶
A version that is not '.'-separated integers, such as a development build reporting "master" or an empty string from a failed lookup, sorts as the newest possible version. A development build therefore satisfies every minimum-version gate, which is deliberate: preflight-style checks should not block a test or debug cluster.
A caller that has no version at all is asking a different question, and answers it before parsing:
if pcVersion == "" {
return false // nothing was reported, use the fallback path
}
return versionutils.Parse(pcVersion).AtLeast(minPC)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version is a parsed Nutanix version, ready to compare. The zero Version is not meaningful; construct one with Parse.
func Parse ¶
Parse parses any Nutanix version string, whether it came from AOS ("3.5.2.1"), Prism Central ("2024.3.1", "7.6", "pc.7.6.0.5"), or a Prism Element fullVersion ("el8.5-release-ganges-7.5.1-stable-<commit>"). An optional "pc." prefix, surrounding whitespace, and casing are normalized away. A fullVersion is reduced to its AOS token (7.5.1); a leading OS prefix such as el8.5 or ol9 is ignored.
Parse never fails. A version that is not '.'-separated integers and does not contain an extractable AOS token sorts as the newest possible version.
func ParseReported ¶ added in v0.8.2
ParseReported combines Prism's truncated short version with fullVersion. AOS 7.5.1 often reports version "7.5" while fullVersion is "el8.5-release-ganges-7.5.1-stable-<commit>". The result is the more specific refinement of short (7.5.1). An unparseable short version such as "master" is left unchanged so development builds keep the existing gate.