versionutils

package
v0.6.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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.

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

func Parse(version string) Version

Parse parses any Nutanix version string, whether it came from AOS ("3.5.2.1") or from Prism Central ("2024.3.1", "7.6", "pc.7.6.0.5"). An optional "pc." prefix, surrounding whitespace, and casing are normalized away.

Parse never fails. A version that is not '.'-separated integers sorts as the newest possible version.

func (Version) AtLeast

func (v Version) AtLeast(minVersion Version) bool

AtLeast reports whether v is newer than or equal to minVersion. An unparsable version, including an empty one, reports true.

func (Version) String

func (v Version) String() string

String returns the normalized version: trimmed, lower-cased and without any "pc." prefix.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL