Documentation ¶
Overview ¶
Package resolver contains a git tag aware version resolver that supports channels to determine the latest version.
Index ¶
Constants ¶
const StableChannel = "stable"
StableChannel is the default channel used when a version doesn't contain a channel.
Variables ¶
var ( // ErrNoVersions is returned when no versions are found ErrNoVersions = errors.New("no version found matching criteria") )
This block contains error types for the resolver package.
var GetVersions = getVersions
GetVersions returns all known channels and the versions that are available for each channel.
Note: token is _optional_, if you do not wish to authenticate with your VCS provider you can pass an empty string.
Functions ¶
Types ¶
type Criteria ¶
type Criteria struct { // URL is the URL to the repository to check for updates. URL string // Channel is the channel to use for determining the latest version. // Leave empty to use the StableChannel. Channel string // Constraints are the semver constraint(s) to use for determining the latest version. // See: https://pkg.go.dev/github.com/Masterminds/semver/v3#hdr-Checking_Version_Constraints_and_Comparing_Versions Constraints []string // AllowBranches is a flag to allow branches to be considered as versions, branches // will be represented as their own channel. AllowBranches bool }
Criteria is the criteria used to determine the latest version
type Version ¶
type Version struct { // Mutable denotes if this version is a reference pointing to a specific // sha that can't be compared as a semantic version. When encountering a // mutable version, it should always be used over a semantic version as // there is no way to compare the two. Mutable bool // Branch is the branch that the version is on, branches are special // versions that are always mutable. Branch string // Tag is the git tag that represents the version. Tag string `yaml:"version"` // Commit is the git commit that this tag refers to. Commit string `yaml:"commit"` // Channel is the channel that this version is associated with. Channel string `yaml:"channel"` // contains filtered or unexported fields }
Version is a resolved version from a git repository
func NewVersion ¶ added in v1.53.0
NewVersion creates a new version from a tag and commit.
func Resolve ¶
Resolve returns the latest version that satisfies the criteria
Note: token is _optional_, if you do not wish to authenticate with your VCS provider you can pass an empty string.
Criteria:
Constraints are supported as per the underlying semver library here: https://pkg.go.dev/github.com/Masterminds/semver/v3#hdr-Checking_Version_Constraints_and_Comparing_Versions
If a channel is provided, without a constraint, the latest version of that channel will be returned if it's greater than the `stable` channel (if present). As a special case, if a channel's latest version is mutable, that version will always be returned over any constraint.
Constraints, by default, do not include a pre-releases or allow selecting specific pre-releases tracks in the semver library used. In order to support this we parse the constraints to determine the allowed channels. By default `stable` is always considered, with whatever pre-release (e.g. `>=1.0.0-alpha` -> `alpha`) is specified in the pre-release constraint being added to the allowed channels. If a channel is specified, it is also added to the allowed channels. Due to this '&&' and '||' are not supported in constraints.