apimachinery: k8s.io/apimachinery/pkg/util/version Index | Files

package version

import "k8s.io/apimachinery/pkg/util/version"

Package version provides utilities for version number comparisons

Index

Package Files

doc.go version.go

type Version Uses

type Version struct {
    // contains filtered or unexported fields
}

Version is an opqaue representation of a version number

func MustParseGeneric Uses

func MustParseGeneric(str string) *Version

MustParseGeneric is like ParseGeneric except that it panics on error

func MustParseSemantic Uses

func MustParseSemantic(str string) *Version

MustParseSemantic is like ParseSemantic except that it panics on error

func ParseGeneric Uses

func ParseGeneric(str string) (*Version, error)

ParseGeneric parses a "generic" version string. The version string must consist of two or more dot-separated numeric fields (the first of which can't have leading zeroes), followed by arbitrary uninterpreted data (which need not be separated from the final numeric field by punctuation). For convenience, leading and trailing whitespace is ignored, and the version can be preceded by the letter "v". See also ParseSemantic.

func ParseSemantic Uses

func ParseSemantic(str string) (*Version, error)

ParseSemantic parses a version string that exactly obeys the syntax and semantics of the "Semantic Versioning" specification (http://semver.org/) (although it ignores leading and trailing whitespace, and allows the version to be preceded by "v"). For version strings that are not guaranteed to obey the Semantic Versioning syntax, use ParseGeneric.

func (*Version) AtLeast Uses

func (v *Version) AtLeast(min *Version) bool

AtLeast tests if a version is at least equal to a given minimum version. If both Versions are Semantic Versions, this will use the Semantic Version comparison algorithm. Otherwise, it will compare only the numeric components, with non-present components being considered "0" (ie, "1.4" is equal to "1.4.0").

func (*Version) BuildMetadata Uses

func (v *Version) BuildMetadata() string

BuildMetadata returns the build metadata, if v is a Semantic Version, or ""

func (*Version) Compare Uses

func (v *Version) Compare(other string) (int, error)

Compare compares v against a version string (which will be parsed as either Semantic or non-Semantic depending on v). On success it returns -1 if v is less than other, 1 if it is greater than other, or 0 if they are equal.

func (*Version) Components Uses

func (v *Version) Components() []uint

Components returns the version number components

func (*Version) LessThan Uses

func (v *Version) LessThan(other *Version) bool

LessThan tests if a version is less than a given version. (It is exactly the opposite of AtLeast, for situations where asking "is v too old?" makes more sense than asking "is v new enough?".)

func (*Version) Major Uses

func (v *Version) Major() uint

Major returns the major release number

func (*Version) Minor Uses

func (v *Version) Minor() uint

Minor returns the minor release number

func (*Version) Patch Uses

func (v *Version) Patch() uint

Patch returns the patch release number if v is a Semantic Version, or 0

func (*Version) PreRelease Uses

func (v *Version) PreRelease() string

PreRelease returns the prerelease metadata, if v is a Semantic Version, or ""

func (*Version) String Uses

func (v *Version) String() string

String converts a Version back to a string; note that for versions parsed with ParseGeneric, this will not include the trailing uninterpreted portion of the version number.

func (*Version) WithMajor Uses

func (v *Version) WithMajor(major uint) *Version

WithMajor returns copy of the version object with requested major number

func (*Version) WithMinor Uses

func (v *Version) WithMinor(minor uint) *Version

WithMinor returns copy of the version object with requested minor number

func (*Version) WithPatch Uses

func (v *Version) WithPatch(patch uint) *Version

WithPatch returns copy of the version object with requested patch number

func (*Version) WithPreRelease Uses

func (v *Version) WithPreRelease(preRelease string) *Version

WithPreRelease returns copy of the version object with requested prerelease

Package version imports 5 packages (graph) and is imported by 288 packages. Updated 2019-01-20. Refresh now. Tools for package owners.