versioncontrol

package
v1.2.3-fred.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const LabelSecurityPatch = "security-patch"

LabelSecurityPatch indicates that a release is a security patch when set to 'yes'.

View Source
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

func IsValidTargetKey(key string) bool

IsValidTargetKey checks if a string is a valid installation target key.

func IsValidTargetVal

func IsValidTargetVal(val string) bool

IsValidTargetVal checks if a string is a valid installtion target value.

func Normalize

func Normalize(v string) string

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

type Target map[string]string

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

func (t Target) Major() string

Major gets the major version of this target (e.g. if version=v1.2.3 then Major() returns v1).

func (Target) NewerThan

func (t Target) NewerThan(other Target) bool

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

func (t Target) NextMajor() string

NextMajor gets the next major version string (e.g. if version=v2.3.4 then NextMajor() returns v3).

func (Target) Ok

func (t Target) Ok() bool

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

func (t Target) OlderThan(other Target) bool

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

func (t Target) Prerelease() bool

Prerelease checks if this target represents a prerelease installation target (e.g. v1.2.3-alpha.1).

func (Target) SecurityPatch

func (t Target) SecurityPatch() bool

SecurityPatch checks for the special label 'security-patch=yes'.

func (Target) Version

func (t Target) Version() string

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

func (t Target) VersionEquals(other Target) bool

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.

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) Newest

func (v *Visitor) Newest() Target

Newest gets the most recent version string from among those observed.

func (*Visitor) NewestCurrent

func (v *Visitor) NewestCurrent() Target

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

func (v *Visitor) NewestSecurityPatch() Target

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

func (v *Visitor) NextMajor() Target

NextMajor gets the newest target from the next major version (nil if Current was not supplied or no matches were found).

func (*Visitor) Oldest

func (v *Visitor) Oldest() Target

Oldest gets the oldest version string from among those observed.

func (*Visitor) Visit

func (v *Visitor) Visit(t Target) (ok bool)

Visit processes the supplied target. If ok is false, the target was ignored due to being invalid, or because it was a prerelease if the visitor is configured to ignore those.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL