Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ConcreteVersionRE matches a concrete version anywhere in the string. ConcreteVersionRE = regexp.MustCompile(`(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)`) // OnlyConcreteVersionRE matches a string that's just a concrete version. OnlyConcreteVersionRE = regexp.MustCompile(`^` + ConcreteVersionRE.String() + `$`) )
var ( // VersionPlatformRE matches concrete version-platform strings. VersionPlatformRE = regexp.MustCompile(`^` + versionPlatformREBase + `$`) // ArchiveRE matches concrete version-platform.tar.gz strings. ArchiveRE = regexp.MustCompile(`^kubebuilder-tools-` + versionPlatformREBase + `\.tar\.gz$`) )
var ( // LatestVersion matches the most recent version on the remote server. LatestVersion = Spec{ Selector: AnySelector{}, CheckLatest: true, } // AnyVersion matches any local or remote version. AnyVersion = Spec{ Selector: AnySelector{}, } )
Functions ¶
func ExtractWithPlatform ¶
ExtractWithPlatform produces a version & platform from the given regular expression and string that should match it. If no match is found, Version will be nil.
The regular expression must have the following capture groups: major, minor, patch, prelabel, prenum, os, arch, and must not support wildcard versions.
Types ¶
type AnySelector ¶
type AnySelector struct{}
AnySelector matches any version at all.
func (AnySelector) AsConcrete ¶
func (AnySelector) AsConcrete() *Concrete
AsConcrete returns nil (this is never a concrete version).
func (AnySelector) Matches ¶
func (AnySelector) Matches(_ Concrete) bool
Matches checks if the given version matches this selector.
func (AnySelector) String ¶
func (AnySelector) String() string
type Concrete ¶
type Concrete struct {
Major, Minor, Patch int
}
Concrete is a concrete Kubernetes-style semver version.
func (Concrete) AsConcrete ¶
AsConcrete returns this version.
type LessThanSelector ¶
type LessThanSelector struct { PatchSelector OrEquals bool }
LessThanSelector selects versions older than the given one (mainly useful for cleaning up).
func (LessThanSelector) AsConcrete ¶
func (s LessThanSelector) AsConcrete() *Concrete
AsConcrete returns nil (this is never a concrete version).
func (LessThanSelector) Matches ¶
func (s LessThanSelector) Matches(ver Concrete) bool
Matches checks if the given version matches this selector.
func (LessThanSelector) String ¶
func (s LessThanSelector) String() string
type PatchSelector ¶
type PatchSelector struct {
Major, Minor int
Patch PointVersion
}
PatchSelector selects a set of versions where the patch is a wildcard.
func PatchSelectorFromMatch ¶
func PatchSelectorFromMatch(match []string, re *regexp.Regexp) PatchSelector
PatchSelectorFromMatch constructs a simple selector according to the ParseExpr rules out of pre-validated sections.
re must include name captures for major, minor, patch, prenum, and prelabel
Any bad input may cause a panic. Use with when you got the parts from an RE match.
func (PatchSelector) AsConcrete ¶
func (s PatchSelector) AsConcrete() *Concrete
AsConcrete returns nil if there are wildcards in this selector, and the concrete version that this selects otherwise.
func (PatchSelector) Matches ¶
func (s PatchSelector) Matches(ver Concrete) bool
Matches checks if the given version matches this selector.
func (PatchSelector) String ¶
func (s PatchSelector) String() string
type Platform ¶
Platform contains OS & architecture information Either may be '*' to indicate a wildcard match.
func (Platform) ArchiveName ¶
ArchiveName returns the full archive name for this version and platform.
func (Platform) BaseName ¶
BaseName returns the base directory name that fully identifies a given version and platform.
func (Platform) IsWildcard ¶
IsWildcard checks if either OS or Arch are set to wildcard values.
type PlatformItem ¶
PlatformItem represents a platform with corresponding known metadata for its download.
type PointVersion ¶
type PointVersion int
PointVersion represents a wildcard (patch) version or concrete number.
const ( // AnyPoint matches any point version. AnyPoint PointVersion = -1 )
func PointVersionFromValidString ¶
func PointVersionFromValidString(str string) PointVersion
PointVersionFromValidString extracts a point version from the corresponding string representation, which may be a number >= 0, or x|* (AnyPoint).
Anything else will cause a panic (use this on strings extracted from regexes).
func (PointVersion) Matches ¶
func (p PointVersion) Matches(other int) bool
Matches checks if a point version is compatible with a concrete point version. Two point versions are compatible if they are a) both concrete b) one is a wildcard.
func (PointVersion) String ¶
func (p PointVersion) String() string
type Selector ¶
type Selector interface { // AsConcrete tries to return this selector as a concrete version. // If the selector would only match a single version, it'll return // that, otherwise it'll return nil. AsConcrete() *Concrete // Matches checks if this selector matches the given concrete version. Matches(ver Concrete) bool String() string }
Selector selects some concrete version or range of versions.
type Set ¶
type Set struct { Version Concrete Platforms []PlatformItem }
Set is a concrete version and all the corresponding platforms that it's available for.
type Spec ¶
type Spec struct { Selector // CheckLatest tells us to check the remote server for the latest // version that matches our selector, instead of just relying on // matching local versions. CheckLatest bool }
Spec matches some version or range of versions, and tells us how to deal with local and remote when selecting a version.
func FromExpr ¶
FromExpr extracts a version from a string in the form of a semver version, where X, Y, and Z may also be wildcards ('*', 'x'), and pre-release names & numbers may also be wildcards. The prerelease section is slightly restricted to match what k8s does. The whole string is a version selector as follows:
- X.Y.Z matches version X.Y.Z where x, y, and z are are ints >= 0, and Z may be '*' or 'x'
- X.Y is equivalent to X.Y.*
- ~X.Y.Z means >= X.Y.Z && < X.Y+1.0
- <X.Y.Z means older than the X.Y.Z (mainly useful for cleanup (similarly for <=)
- an '!' at the end means force checking API server for the latest versions instead of settling for local matches.
^[^~]?SEMVER(!)??$ .
func (Spec) AsConcrete ¶
AsConcrete returns the underlying selector as a concrete version, if possible.
func (*Spec) MakeConcrete ¶
MakeConcrete replaces the contents of this spec with one that matches the given concrete version (without checking latest from the server).
type TildeSelector ¶
type TildeSelector struct {
Concrete
}
TildeSelector selects [X.Y.Z, X.Y+1.0).
func (TildeSelector) AsConcrete ¶
func (s TildeSelector) AsConcrete() *Concrete
AsConcrete returns nil (this is never a concrete version).
func (TildeSelector) Matches ¶
func (s TildeSelector) Matches(ver Concrete) bool
Matches checks if the given version matches this selector.
func (TildeSelector) String ¶
func (s TildeSelector) String() string