Documentation ¶
Index ¶
- Constants
- func IsValidTargetKey(key string) bool
- func IsValidTargetVal(val string) bool
- func Normalize(v string) string
- type Target
- func (t Target) Major() string
- func (t Target) NewerThan(other Target) bool
- func (t Target) NextMajor() string
- func (t Target) Ok() bool
- func (t Target) OlderThan(other Target) bool
- func (t Target) Prerelease() bool
- func (t Target) SecurityPatch() bool
- func (t Target) SecurityPatchAltOf(other Target) bool
- func (t Target) Version() string
- func (t Target) VersionEquals(other Target) bool
- type TargetOption
- type Visitor
Constants ¶
const LabelSecurityPatch = "security-patch"
LabelSecurityPatch indicates that a release is a security patch when set to 'yes'.
const LabelSecurityPatchAlts = "security-patch-alts"
LabelSecurityPatchAlts lists alternative versions that provide the same security fixes.
const LabelVersion = "version"
LabelVersion is the only required label for an installation target and must be valid go-style semver.
Variables ¶
This section is empty.
Functions ¶
func IsValidTargetKey ¶
IsValidTargetKey checks if a string is a valid installation target key.
func IsValidTargetVal ¶
IsValidTargetVal checks if a string is a valid installtion target value.
func Normalize ¶
Normalize attaches the expected `v` prefix to a version string if the supplied version is currently invalid, and attaching the prefix makes it valid. Useful for normalizing the teleport.Version variable. Note that this package generally treats targets and version strings as immutable, so normalization is never applied automatically. It is the responsibility of the consumers of this package to apply normalization when and where immutability is known to not be required (e.g. the 'teleport.Version' can and should always be normalized).
NOTE: this isn't equivalent to "canonicalization" which makes equivalent version strings comparable via `==`. version strings returned by this function should still only be compared via `semver.Compare`, or via the comparison methods on the Target type.
Types ¶
type Target ¶
Target is a description of an available installation target. A given "release" (e.g. v1.2.3) may consist of one or more targets depending on how intallation targets are being modeled (e.g. TUF creates a separate target for each installation package for a given version, whereas the github releases scraper simply creates one target per version). Unknown keypairs should be ignored, and invalid values for expected labels should cause the target as a whole to be ignored. If the Target is being used in a manner that would cause it to be written to the backend, and therefore potentially be used later on by a newer version of teleport, then invalid keypairs should be preserved since they may have known meaning to newer versions.
func NewTarget ¶
func NewTarget(version string, opts ...TargetOption) Target
NewTarget creates a new target with the specified version and options.
func (Target) Major ¶
Major gets the major version of this target (e.g. if version=v1.2.3 then Major() returns v1).
func (Target) NewerThan ¶
NewerThan returns true if this target has a well-defined "newer" relationship to other. Returns false if other is older, equal, or incomparable (e.g. if one or both targets have invalid versions).
func (Target) NextMajor ¶
NextMajor gets the next major version string (e.g. if version=v2.3.4 then NextMajor() returns v3).
func (Target) Ok ¶
Ok checks if the target is valid. The only requirement for a target to be valid is for it to have a version field containing valid go-style semver. This must be checked prior to use of the target (this method also works as a nil check).
func (Target) OlderThan ¶
OlderThan returns true if this target has a well-defined "newer" relationship to other. Returns false if other is older, equal, or incomparable (e.g. if one or both targets have invalid versions).
func (Target) Prerelease ¶
Prerelease checks if this target represents a prerelease installation target (e.g. v1.2.3-alpha.1).
func (Target) SecurityPatch ¶
SecurityPatch checks for the special label 'security-patch=yes'.
func (Target) SecurityPatchAltOf ¶
SecurityPatchAltOf performs a bidirectional check to see if this target and another are security patch alternates (i.e. wether or not they provide the same security fix).
func (Target) Version ¶
Version gets the version of this installation target. Note that the returned value is not necessarily canonicalized (i.e. two equivalent version strings may not compare as equal).
func (Target) VersionEquals ¶
VersionEquals returns true if this target has a well-defined equivalence relationship to the version of other. Returns false if the versons are not equal, or if they are incomparable (e.g. if one or both targets have invalid versions).
type TargetOption ¶
type TargetOption func(*targetOptions)
TargetOption is a functional option for setting additional target fields during construction.
func SecurityPatch ¶
func SecurityPatch(sec bool) TargetOption
SecurityPatch sets the security-patch=yes label if true.
func SecurityPatchAlts ¶
func SecurityPatchAlts(alts ...string) TargetOption
SecurityPatchAlts appends version strings to the security-patch-alts label.
type Visitor ¶
type Visitor struct { // PermitPrerelease configures whether or not the visitor will process/yield targets // with semver prerelease versions. PermitPrerelease bool // NotNewerThan is an optional target represented a constraint for the *newest* version // that we care about. Targets newer than NotNewerThan are ignored if it is supplied. NotNewerThan Target // Current is an optional target representing the current installation. If a valid // target is supplied, then the Next* family of targets are selected relative to it. Current Target // contains filtered or unexported fields }
Visitor is a helper for aggregating information about observed targets. Useful for getting newest/oldest version observed during iteration/pagination. Zero value omits prereleases.
TODO(fspmarshall): Rework this to handle scenarios where multiple targets have the same version and add collection for .newest current version", "latest next major version", and .newest security patch" (relative to an optional "current version" param).
func (*Visitor) NewestCurrent ¶
NewestCurrent gets the newest target from the current major version (nil if Current was not supplied or no matches were found). Note that this target may not actually be newer than than the current target.
func (*Visitor) NewestSecurityPatch ¶
NewestSecurityPatch gets the newest target from the current major version which is a security patch (nil if Current was not supplied or if no matches were found). Note that this target may not actually be newer than the current target.
func (*Visitor) NextMajor ¶
NextMajor gets the newest target from the next major version (nil if Current was not supplied or no matches were found).