Documentation ¶
Overview ¶
Package resolver implements a way to resolve versions using a set of criteria. Note that only semantic versioning is supported for tags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Criteria ¶
type Criteria struct { // Constraint is a semantic versioning constraint that the version // must satisfy. // // Example: ">=1.0.0 <2.0.0" Constraint string // Branch is the branch that the version must point to. This // constraint will only be satisfied if the branch currently points to // the commit being considered. // // If a branch is provided, it will always be used over other // versions. For this reason, top-level modules should only ever use // branches. Branch string // contains filtered or unexported fields }
Criteria represents a set of criteria that a version must satisfy to be able to be selected.
func (*Criteria) Check ¶
Check returns true if the version satisfies the criteria. If a prerelease is included then the provided criteria will be mutated to support pre-releases as well as ensure that the prerelease string matches the provided version. If a branch is provided, then the criteria will always be satisfied unless the criteria is looking for a specific branch, in which case it will be satisfied only if the branches match.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver is an instance of a version resolver that resolves versions based on the provided criteria. Version lists are fetched exactly once and are cached for the lifetime of the resolver.
func (*Resolver) Resolve ¶
func (r *Resolver) Resolve(ctx context.Context, uri string, criteria ...*Criteria) (*Version, error)
Resolve returns the latest version matching the provided criteria. If multiple criteria are provided, the version must satisfy all of them. If no versions are found, an error is returned.
TODO(jaredallard): Return resolution errors as a type that can be unwrapped for getting information about why it failed.
type Version ¶
type Version struct { // Commit is the underlying commit hash for this version. Commit string `yaml:"commit,omitempty"` // Tag is the underlying tag for this version, if set. Tag string `yaml:"tag,omitempty"` // Virtual is version that was injected either through the local // file-system or through a replacement. The value of this is set // depending on the context of how this was set. A virtual version is // never returned from a resolver. Virtual string `yaml:"virtual,omitempty"` // Branch is the underlying branch for this version, if set. Branch string `yaml:"branch,omitempty"` // contains filtered or unexported fields }
Version represents a version found in a Git repository. Versions are only discovered if a tag or branch points to a commit (individual commits will never be automatically discovered unless they are manually passed in).