upgrade

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: MPL-2.0 Imports: 22 Imported by: 3

Documentation

Overview

Package upgrade downloads and compares releases, and upgrades the running binary.

Index

Constants

View Source
const DisabledByCompilation = false

Variables

View Source
var (
	ErrNoReleaseDownload  = errors.New("couldn't find a release to download")
	ErrNoVersionToSelect  = errors.New("no version to select")
	ErrUpgradeUnsupported = errors.New("upgrade unsupported")
	ErrUpgradeInProgress  = errors.New("upgrade already in progress")
)
View Source
var SigningKey = []byte(`-----BEGIN EC PUBLIC KEY-----
MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQA1iRk+p+DsmolixxVKcpEVlMDPOeQ
1dWthURMqsjxoJuDAe5I98P/A0kXSdBI7avm5hXhX2opJ5TAyBZLHPpDTRoBg4WN
7jUpeAjtPoVVxvOh37qDeDVcjCgJbbDTPKbjxq/Ae3SHlQMRcoes7lVY1+YJ8dPk
2oPfjA6jtmo9aVbf/uo=
-----END EC PUBLIC KEY-----`)

SigningKey is the public key used to verify signed upgrades. It must match the private key used to sign binaries for the built in upgrade mechanism to accept an upgrade. Keys and signatures can be created and verified with the stsigtool utility. The build script creates signed binaries when given the -sign option.

Functions

func To

func To(rel Release) error

func ToURL

func ToURL(url string) error

Types

type Asset

type Asset struct {
	URL  string `json:"url"`
	Name string `json:"name"`

	// The browser URL is needed for human readable links in the output created
	// by cmd/stupgrades.
	BrowserURL string `json:"browser_download_url"`
}

type Relation

type Relation int
const (
	MajorOlder Relation = -2 // Older by a major version (x in x.y.z or 0.x.y).
	Older      Relation = -1 // Older by a minor version (y or z in x.y.z, or y in 0.x.y)
	Equal      Relation = 0  // Versions are semantically equal
	Newer      Relation = 1  // Newer by a minor version (y or z in x.y.z, or y in 0.x.y)
	MajorNewer Relation = 2  // Newer by a major version (x in x.y.z or 0.x.y).
)

func CompareVersions

func CompareVersions(a, b string) Relation

CompareVersions returns a relation describing how a compares to b.

type Release

type Release struct {
	Tag        string  `json:"tag_name"`
	Prerelease bool    `json:"prerelease"`
	Assets     []Asset `json:"assets"`

	// The HTML URL is needed for human readable links in the output created
	// by cmd/stupgrades.
	HTMLURL string `json:"html_url"`
}

func FetchLatestReleases added in v0.12.5

func FetchLatestReleases(releasesURL, current string) []Release

FetchLatestReleases returns the latest releases. The "current" parameter is used for setting the User-Agent only.

func LatestRelease

func LatestRelease(releasesURL, current string, upgradeToPreReleases bool) (Release, error)

func SelectLatestRelease

func SelectLatestRelease(rels []Release, current string, upgradeToPreReleases bool) (Release, error)

type SortByRelease

type SortByRelease []Release

func (SortByRelease) Len

func (s SortByRelease) Len() int

func (SortByRelease) Less

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

func (SortByRelease) Swap

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

Jump to

Keyboard shortcuts

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