version

package
v1.137.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 4 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIfMinorVersionUpdate added in v1.125.1

func CheckIfMinorVersionUpdate(old, new string) (bool, error)

CheckIfMinorVersionUpdate checks if the new version is a minor version update to the old version.

func CheckVersionMeetsConstraint

func CheckVersionMeetsConstraint(version, constraint string) (bool, error)

CheckVersionMeetsConstraint returns true if the <version> meets the <constraint>.

func CompareVersions

func CompareVersions(version1, operator, version2 string) (bool, error)

CompareVersions returns true if the constraint <version1> compared by <operator> to <version2> returns true, and false otherwise. The comparison is based on semantic versions, i.e. <version1> and <version2> will be converted if needed.

func Normalize added in v1.60.0

func Normalize(version string) string

Normalize returns the normalized version string by removing the leading 'v' and any suffixes like '-rc1', '-beta2', etc.

Types

type Constraints

type Constraints struct {
	*semver.Constraints
}

Constraints is a wrapper around semver.Constraints.

var (
	// ConstraintK8sLess131 is a version constraint for versions < 1.31.
	ConstraintK8sLess131 *Constraints
	// ConstraintK8sEqual131 is a version constraint for versions == 1.31.
	ConstraintK8sEqual131 *Constraints
	// ConstraintK8sGreaterEqual131 is a version constraint for versions >= 1.31.
	ConstraintK8sGreaterEqual131 *Constraints
	// ConstraintK8sLess132 is a version constraint for versions < 1.32.
	ConstraintK8sLess132 *Constraints
	// ConstraintK8sGreaterEqual132 is a version constraint for versions >= 1.32.
	ConstraintK8sGreaterEqual132 *Constraints
	// ConstraintK8sLess133 is a version constraint for versions < 1.33.
	ConstraintK8sLess133 *Constraints
	// ConstraintK8sGreaterEqual133 is a version constraint for versions >= 1.33.
	ConstraintK8sGreaterEqual133 *Constraints
	// ConstraintK8sLess134 is a version constraint for versions < 1.34.
	ConstraintK8sLess134 *Constraints
	// ConstraintK8sGreaterEqual134 is a version constraint for versions >= 1.34.
	ConstraintK8sGreaterEqual134 *Constraints
	// ConstraintK8sLess135 is a version constraint for versions < 1.35.
	ConstraintK8sLess135 *Constraints
	// ConstraintK8sGreaterEqual135 is a version constraint for versions >= 1.35.
	ConstraintK8sGreaterEqual135 *Constraints
)

func MustNewConstraint

func MustNewConstraint(constraintStr string) *Constraints

MustNewConstraint creates a new Constraints object from the given constraint string. The function panics if the passed constraint is invalid.

func (*Constraints) CheckVersion

func (c *Constraints) CheckVersion(version string) bool

CheckVersion checks whether the given version string satisfies the constraints. Please ensure the passed version is a valid semantic version (errors related to parsing the version will result in `false` being returned - the error is omitted).

type VersionRange added in v1.84.0

type VersionRange struct {
	AddedInVersion   string
	RemovedInVersion string
}

VersionRange represents a version range of type [AddedInVersion, RemovedInVersion).

func (*VersionRange) Contains added in v1.84.0

func (r *VersionRange) Contains(version string) (bool, error)

Contains returns true if the range contains the given version, false otherwise. The range contains the given version only if it's greater or equal than AddedInVersion (always true if AddedInVersion is empty), and less than RemovedInVersion (always true if RemovedInVersion is empty).

func (*VersionRange) SupportedVersionRange added in v1.84.0

func (r *VersionRange) SupportedVersionRange() string

SupportedVersionRange returns the supported version range for the given API.

Jump to

Keyboard shortcuts

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