Documentation
¶
Overview ¶
package version implements a k0s version type and functions to parse and compare versions
Index ¶
- Constants
- Variables
- type Collection
- type Constraints
- type Version
- func (v *Version) AirgapDownloadURL(arch string) string
- func (v *Version) Base() string
- func (v *Version) Clone() *Version
- func (v *Version) ComparableFields() comparableFields
- func (v *Version) Compare(b *Version) int
- func (v *Version) DocsURL() string
- func (v *Version) DownloadURL(os, arch string) string
- func (v *Version) Equal(b *Version) bool
- func (v *Version) GreaterThan(b *Version) bool
- func (v *Version) GreaterThanOrEqual(b *Version) bool
- func (v *Version) IsK0s() bool
- func (v *Version) IsPrerelease() bool
- func (v *Version) IsZero() bool
- func (v *Version) K0s() (int, bool)
- func (v *Version) LessThan(b *Version) bool
- func (v *Version) LessThanOrEqual(b *Version) bool
- func (v *Version) MarshalText() ([]byte, error)
- func (v *Version) MarshalYAML() (interface{}, error)
- func (v *Version) Metadata() string
- func (v *Version) Prerelease() string
- func (v *Version) Satisfies(constraint Constraints) bool
- func (v *Version) Segments() []int
- func (v *Version) Segments64() []int64
- func (v *Version) String() string
- func (v *Version) URL() string
- func (v *Version) UnmarshalText(text []byte) error
- func (v *Version) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (v *Version) WithK0s(n int) *Version
Constants ¶
const (
BaseUrl = "https://github.com/k0sproject/k0s/"
)
Variables ¶
var Timeout = time.Second * 10
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection []*Version
Collection is a type that implements the sort.Interface interface so that versions can be sorted.
func NewCollection ¶
func NewCollection(versions ...string) (Collection, error)
func (Collection) Len ¶
func (c Collection) Len() int
func (Collection) Less ¶
func (c Collection) Less(i, j int) bool
func (Collection) Swap ¶
func (c Collection) Swap(i, j int)
type Constraints ¶ added in v0.4.0
type Constraints []constraint
Constraints is a collection of version constraint rules that can be checked against a version.
func MustConstraint ¶ added in v0.4.0
func MustConstraint(cs string) Constraints
MustConstraint is like NewConstraint but panics if the constraint is invalid.
func NewConstraint ¶ added in v0.4.0
func NewConstraint(cs string) (Constraints, error)
NewConstraint parses a string into a Constraints object that can be used to check if a given version satisfies the constraint.
func (Constraints) Check ¶ added in v0.4.0
func (cs Constraints) Check(v *Version) bool
Check returns true if the given version satisfies all of the constraints.
func (Constraints) CheckString ¶ added in v0.4.0
func (cs Constraints) CheckString(v string) bool
CheckString is like Check but takes a string version. If the version is invalid, it returns false.
func (Constraints) String ¶ added in v0.4.1
func (cs Constraints) String() string
String returns the constraint as a string.
type Version ¶
type Version struct {
// contains filtered or unexported fields
}
Version is a k0s version
func Latest ¶ added in v0.3.0
LatestVersion returns the semantically sorted latest version even if it is a prerelease from the online repository
func LatestByPrerelease ¶ added in v0.3.0
LatestByPrerelease returns the latest released k0s version, if preok is true, prereleases are also accepted.
func LatestStable ¶ added in v0.3.0
LatestStable returns the semantically sorted latest non-prerelease version from the online repository
func MustParse ¶ added in v0.4.0
MustParse is like NewVersion but panics if the version cannot be parsed. It simplifies safe initialization of global variables.
func NewVersion ¶
NewVersion returns a new Version object from a string representation of a k0s version
func (*Version) AirgapDownloadURL ¶ added in v0.3.0
AirgapDownloadURL returns the k0s airgap bundle download URL for the k0s version
func (*Version) Base ¶ added in v0.7.0
Base returns the version as a string without the k0s or metadata part (eg v1.2.3+k0s.4 -> v1.2.3)
func (*Version) ComparableFields ¶ added in v0.7.0
func (v *Version) ComparableFields() comparableFields
ComparableFields returns the comparable fields of the k0s version
func (*Version) Compare ¶
Compare returns 0 if the k0s version is equal to the supplied version, 1 if it's greater and -1 if it's lower
func (*Version) DownloadURL ¶ added in v0.3.0
DownloadURL returns the k0s binary download URL for the k0s version
func (*Version) GreaterThan ¶
GreaterThan returns true if the version is greater than the supplied version
func (*Version) GreaterThanOrEqual ¶
GreaterThanOrEqual returns true if the version is greater than the supplied version or equal
func (*Version) IsPrerelease ¶ added in v0.7.0
IsPrerelease returns true if the k0s version is a prerelease version
func (*Version) K0s ¶ added in v0.7.0
K0s returns the k0s version (eg 4 from v1.2.3-k0s.4) and true if the version is a k0s version. Otherwise it returns 0 and false.
func (*Version) LessThanOrEqual ¶
LessThanOrEqual returns true if the version is lower than the supplied version or equal
func (*Version) MarshalText ¶ added in v0.7.0
MarshalText implements the encoding.TextMarshaler interface (used as fallback by encoding/json and yaml.v3).
func (*Version) MarshalYAML ¶ added in v0.4.0
MarshalYAML implements the yaml.v2 Marshaler interface.
func (*Version) Metadata ¶ added in v0.7.0
Metadata returns the metadata part of the k0s version (eg 123abc from v1.2.3+k0s.1.123abc)
func (*Version) Prerelease ¶ added in v0.7.0
Prerelease returns the prerelease part of the k0s version (eg rc1 from v1.2.3-rc1).
func (*Version) Satisfies ¶ added in v0.4.0
func (v *Version) Satisfies(constraint Constraints) bool
Satisfies returns true if the version satisfies the supplied constraint
func (*Version) Segments ¶ added in v0.7.0
Segments returns the numerical segments of the version. The returned slice is always maxSegments long. Missing segments are zeroes. Eg 1,1,0 from v1.1
func (*Version) Segments64 ¶ added in v0.7.0
Segments64 returns the numerical segments of the k0s version as int64 (eg 1,2,3 from v1.2.3). Missing segments are zeroes.
func (*Version) String ¶ added in v0.3.0
String returns a v-prefixed string representation of the k0s version
func (*Version) URL ¶ added in v0.3.0
URL returns an URL to the release information page for the k0s version
func (*Version) UnmarshalText ¶ added in v0.7.0
UnmarshalText implements the encoding.TextUnmarshaler interface (used as fallback by encoding/json and yaml.v3).
func (*Version) UnmarshalYAML ¶ added in v0.4.0
UnmarshalYAML implements the yaml.v2 Unmarshaler interface.