resolver

package
v1.51.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package resolver contains a git tag aware version resolver that supports channels to determine the latest version.

Index

Constants

View Source
const StableChannel = "stable"

StableChannel is the default channel used when a version doesn't contain a channel.

Variables

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

func Sort

func Sort(versions []Version)

Sort sorts a slice of versions

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
}

Criteria is the criteria used to determine the latest version

type Version

type Version struct {

	// 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 Resolve

func Resolve(ctx context.Context, token cfg.SecretData, c *Criteria) (*Version, error)

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.

func (*Version) String

func (v *Version) String() string

String returns the user-friendly representation of a version, e.g. when using a version that came from a mutable tag use the commit hash+channel as opposed to just the tag.

type Versions

type Versions []Version

Versions represents multiple versions.

func (Versions) Len

func (s Versions) Len() int

Len returns length of version collection

func (Versions) Less

func (s Versions) Less(i, j int) bool

Less checks if version at index i is less than version at index j

func (Versions) Swap

func (s Versions) Swap(i, j int)

Swap swaps two versions inside the collection by its indices

Jump to

Keyboard shortcuts

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