type Version … var versionMatchRE … var extraMatchRE … func parse(str string, semver bool) (*Version, error) { … } // HighestSupportedVersion returns the highest supported version // This function assumes that the highest supported version must be v1.x. func HighestSupportedVersion(versions []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 ParseGeneric(str string) (*Version, error) { … } // MustParseGeneric is like ParseGeneric except that it panics on error func MustParseGeneric(str string) *Version { … } // Parse tries to do ParseSemantic first to keep more information. // If ParseSemantic fails, it would just do ParseGeneric. func Parse(str string) (*Version, error) { … } // MustParse is like Parse except that it panics on error func MustParse(str string) *Version { … } // ParseMajorMinor parses a "generic" version string and returns a version with the major and minor version. func ParseMajorMinor(str string) (*Version, error) { … } // MustParseMajorMinor is like ParseMajorMinor except that it panics on error func MustParseMajorMinor(str string) *Version { … } // 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 ParseSemantic(str string) (*Version, error) { … } // MustParseSemantic is like ParseSemantic except that it panics on error func MustParseSemantic(str string) *Version { … } // MajorMinor returns a version with the provided major and minor version. func MajorMinor(major, minor uint) *Version { … } // Major returns the major release number func (v *Version) Major() uint { … } // Minor returns the minor release number func (v *Version) Minor() uint { … } // Patch returns the patch release number if v is a Semantic Version, or 0 func (v *Version) Patch() uint { … } // BuildMetadata returns the build metadata, if v is a Semantic Version, or "" func (v *Version) BuildMetadata() string { … } // PreRelease returns the prerelease metadata, if v is a Semantic Version, or "" func (v *Version) PreRelease() string { … } // Components returns the version number components func (v *Version) Components() []uint { … } // WithMajor returns copy of the version object with requested major number func (v *Version) WithMajor(major uint) *Version { … } // WithMinor returns copy of the version object with requested minor number func (v *Version) WithMinor(minor uint) *Version { … } // SubtractMinor returns the version with offset from the original minor, with the same major and no patch. // If -offset >= current minor, the minor would be 0. func (v *Version) OffsetMinor(offset int) *Version { … } // SubtractMinor returns the version diff minor versions back, with the same major and no patch. // If diff >= current minor, the minor would be 0. func (v *Version) SubtractMinor(diff uint) *Version { … } // AddMinor returns the version diff minor versions forward, with the same major and no patch. func (v *Version) AddMinor(diff uint) *Version { … } // WithPatch returns copy of the version object with requested patch number func (v *Version) WithPatch(patch uint) *Version { … } // WithPreRelease returns copy of the version object with requested prerelease func (v *Version) WithPreRelease(preRelease string) *Version { … } // WithBuildMetadata returns copy of the version object with requested buildMetadata func (v *Version) WithBuildMetadata(buildMetadata string) *Version { … } // 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 (v *Version) String() string { … } // compareInternal returns -1 if v is less than other, 1 if it is greater than other, or 0 // if they are equal func (v *Version) compareInternal(other *Version) int { … } // returns false if array contain any non-zero element func onlyZeros(array []uint) bool { … } // EqualTo tests if a version is equal to a given version. func (v *Version) EqualTo(other *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 (v *Version) AtLeast(min *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 (v *Version) LessThan(other *Version) bool { … } // GreaterThan tests if a version is greater than a given version. func (v *Version) GreaterThan(other *Version) bool { … } // 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 (v *Version) Compare(other string) (int, error) { … } // WithInfo returns copy of the version object with requested info func (v *Version) WithInfo(info apimachineryversion.Info) *Version { … } func (v *Version) Info() *apimachineryversion.Info { … } func itoa(i uint) string { … }