update

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(ctx context.Context, currentVersion string, v 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, v Versioner) (printResults func(io.Writer))

CheckAsync is a helper function for Check. If the LastVersionCheck time is more than 24 hours ago, 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(ctx context.Context) *GitHub

NewGitHub returns a usable GitHub versioner utilizing the provided token.

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.

type RootCommand

type RootCommand struct {
	common.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 common.Registerer, v Versioner, client api.HTTPClient) *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 {
	LatestVersion(context.Context) (semver.Version, error)
	Download(context.Context, semver.Version) (filename string, err error)
}

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