Documentation
¶
Index ¶
- func IsUnsupportedKubernetesVersionError(err error) bool
- func UnsupportedKubernetesVersionError(err error) error
- type Version
- func MustParseDate(str string) *Version
- func MustParseGeneric(str string) *Version
- func MustParseMajorMinorVersion(str string) *Version
- func MustParseSemantic(str string) *Version
- func ParseDate(str string) (*Version, error)
- func ParseGeneric(str string) (*Version, error)
- func ParseMajorMinorVersion(str string) (*Version, error)
- func ParseSemantic(str string) (*Version, error)
- func (v *Version) AtLeast(min *Version) bool
- func (v *Version) BuildMetadata() string
- func (v *Version) Compare(other string) (int, error)
- func (v *Version) GreaterThan(other *Version) bool
- func (v *Version) LessThan(other *Version) bool
- func (v *Version) MajorVersion() uint
- func (v *Version) MajorVersionString() string
- func (v *Version) MinorVersion() uint
- func (v *Version) MinorVersionString() string
- func (v *Version) PatchVersion() uint
- func (v *Version) PreRelease() string
- func (v *Version) ShortString() string
- func (v *Version) ShortStringWithRelease() string
- func (v *Version) String() string
- func (v *Version) ToMajorMinorString() string
- func (v *Version) ToMajorMinorVersion() *Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version is an opaque representation of a version number
func MustParseDate ¶
MustParseDate is like ParseDate except that it panics on error
func MustParseGeneric ¶
MustParseGeneric is like ParseGeneric except that it panics on error
func MustParseMajorMinorVersion ¶
MustParseMajorMinorVersion is like ParseMajorMinorVersion except that it panics on error
func MustParseSemantic ¶
MustParseSemantic is like ParseSemantic except that it panics on error
func ParseDate ¶
ParseDate parses a version string that mostly 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"). Furthermore, it allows leading zeroes on the second numerical component so that the version may represent a two-digit month (i.e. 17.07.1). A date-based version string must be of the form <year>.<month>.<rev>[-preRelease][+buildMetadata], where the year/month/rev values are numerical, and the month must be in the range 1..12.
func ParseGeneric ¶
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 ParseMajorMinorVersion ¶
ParseMajorMinorVersion accepts a major-minor version and adds a dummy patch value to the version to satisfy the parser. There are circumstances where the caller is only concerned with the major-minor version
func ParseSemantic ¶
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 ¶
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 ¶
BuildMetadata returns the build metadata, if v is a Semantic Version, or ""
func (*Version) Compare ¶
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) GreaterThan ¶
GreaterThan tests if a version is greater than a given version.
func (*Version) LessThan ¶
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) MajorVersion ¶
func (*Version) MajorVersionString ¶
func (*Version) MinorVersion ¶
func (*Version) MinorVersionString ¶
func (*Version) PatchVersion ¶
func (*Version) PreRelease ¶
func (*Version) ShortString ¶
ShortString converts a Version back to a string, including only the major/minor/patch components.
func (*Version) ShortStringWithRelease ¶
ShortStringWithRelease converts a Version back to a string, including only the major/minor/patch components with release information
func (*Version) 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.