Documentation
¶
Index ¶
- Constants
- func Check(ctx context.Context, currentVersion string, cliVersioner Versioner) (current, latest semver.Version, shouldUpdate bool, err error)
- func CheckAsync(ctx context.Context, file config.File, configFilePath string, ...) (printResults func(io.Writer))
- type GitHub
- func (g *GitHub) Binary() string
- func (g GitHub) Download(ctx context.Context, version semver.Version) (filename string, err error)
- func (g GitHub) LatestVersion(ctx context.Context) (semver.Version, error)
- func (g GitHub) Name() string
- func (g *GitHub) RenameLocalBinary(binName string) error
- func (g *GitHub) SetAsset(name string)
- type GitHubOpts
- type RootCommand
- type Versioner
Constants ¶
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) LatestVersion ¶
LatestVersion implements the Versioner interface.
func (*GitHub) RenameLocalBinary ¶ added in v0.27.0
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
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
GitHubOpts represents options to be passed to NewGitHub.
type RootCommand ¶
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.
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.