update

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAssetFormat = "%s_v%s_%s-%s.tar.gz"

DefaultAssetFormat represents the standard GitHub release asset name format.

Variables

This section is empty.

Functions

func Check

func Check(ctx context.Context, currentVersion string, cliVersioner Versioner) (current, latest semver.Version, shouldUpdate bool, err error)

Check if the CLI can be updated.

func CheckAsync

func CheckAsync(ctx context.Context, file config.File, configFilePath string, currentVersion string, cliVersioner Versioner, in io.Reader, out io.Writer) (printResults func(io.Writer))

CheckAsync is a helper function for Check. If the app config's LastChecked time has past the specified TTL, launch a goroutine to perform the Check using the provided context. Return a function that will print an informative message to the writer if there is a newer version available.

Callers should invoke CheckAsync via

f := CheckAsync(...)
defer f()

Types

type GitHub

type GitHub struct {
	// contains filtered or unexported fields
}

GitHub is a versioner that uses GitHub releases.

func NewGitHub

func NewGitHub(opts GitHubOpts) *GitHub

NewGitHub returns a usable GitHub versioner utilizing the provided token.

func (*GitHub) Binary added in v0.34.0

func (g *GitHub) Binary() string

Binary returns the configured binary output name.

func (GitHub) Download

func (g GitHub) Download(ctx context.Context, version semver.Version) (filename string, err error)

Download implements the Versioner interface.

func (GitHub) LatestVersion

func (g GitHub) LatestVersion(ctx context.Context) (semver.Version, error)

LatestVersion implements the Versioner interface.

func (GitHub) Name added in v0.34.0

func (g GitHub) Name() string

Name will return the name of the binary.

func (*GitHub) RenameLocalBinary added in v0.27.0

func (g *GitHub) RenameLocalBinary(binName string) error

RenameLocalBinary will rename the downloaded binary.

NOTE: This exists so that we can, for example, rename a binary such as 'viceroy' to something less ambiguous like 'fastly-localtesting'.

func (*GitHub) SetAsset added in v0.34.0

func (g *GitHub) SetAsset(name string)

SetAsset allows configuring the release asset format.

NOTE: This existed because the CLI project was originally using a different release asset name format to the Viceroy project. Although the two projects are now aligned we've kept this feature in case there are any changes between the two projects in the future, or if we have to call out to more external binaries from within the CLI.

type GitHubOpts added in v0.34.0

type GitHubOpts struct {
	Org    string
	Repo   string
	Binary string
}

GitHubOpts represents options to be passed to NewGitHub.

type RootCommand

type RootCommand struct {
	cmd.Base
	// contains filtered or unexported fields
}

RootCommand is the parent command for all subcommands in this package. It should be installed under the primary root command.

func NewRootCommand

func NewRootCommand(parent cmd.Registerer, configFilePath string, cliVersioner Versioner, client api.HTTPClient, globals *config.Data) *RootCommand

NewRootCommand returns a new command registered in the parent.

func (*RootCommand) Exec

func (c *RootCommand) Exec(in io.Reader, out io.Writer) error

Exec implements the command interface.

type Versioner

type Versioner interface {
	Binary() string
	Download(context.Context, semver.Version) (filename string, err error)
	LatestVersion(context.Context) (semver.Version, error)
	Name() string
	RenameLocalBinary(binName string) error
	SetAsset(name string)
}

Versioner describes a source of CLI release artifacts.

Jump to

Keyboard shortcuts

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