Documentation
¶
Overview ¶
Description: Provides miscellaneous helpers for the updater
Package updater implements an updater for CLIs that support multiple channels and version checks
Index ¶
- Variables
- func UseUpdater(ctx context.Context, opts ...Option) (*updater, error)
- type BoolFlag
- type CLIArgs
- type CLICmd
- type Command
- type CommandAction
- type Config
- type Flag
- type Option
- func WithApp(app *cliV2.App) Option
- func WithAppV3(cmd *cliV3.Command) Option
- func WithChannel(channel string) Option
- func WithCheckInterval(interval time.Duration) Option
- func WithDisabled(disabled bool) Option
- func WithExecutableName(execName string) Optiondeprecated
- func WithExecutablePath(execPath string) Option
- func WithForceCheck(forceCheck bool) Option
- func WithLogger(logger logrus.FieldLogger) Option
- func WithNoProgressBar(noProgressBar bool) Option
- func WithPrereleases(_ bool) Optiondeprecated
- func WithRepoURL(repo string) Option
- func WithSkipInstall(skipInstall bool) Option
- func WithSkipMajorVersionPrompt(skip bool) Option
- func WithVersion(version string) Option
- type StringFlag
- type UpdateConfiguration
Constants ¶
This section is empty.
Variables ¶
var ( // ConfigVersion is the current version of the configuration schema. ConfigVersion = 1 // ConfigFile is the non-HOME containing path to the config file for the updater ConfigFile = filepath.Join(".outreach", ".config", "updater", "config.yaml") )
This block contains constants for the updater's configuration and cache files.
var Disabled = "false"
Disabled globally disables the automatic updater. This is helpful for when using an external package manager, such as brew. This should usually be done with an ldflag:
go run -ldflags "-X github.com/getoutreach/gobox/pkg/cli/updater.Disabled=true" ...
or you can do it in main() before UseUpdater is called:
updater.Disabled = "true"
Any value other than "true" is considered false. The type is string to allow for invoking via `go run -ldflags "-X ..."`.
var ForceFlag = BoolFlag{
Name: "force-update-check",
Usage: "Force checking for an update",
}
ForceFlag is a CLI flag used to force the updater check.
var SkipFlag = BoolFlag{
Name: "skip-update",
Usage: "Skips the updater check",
}
SkipFlag is a CLI flag used to skip the updater check.
var UpdaterFlags = []cliV2.Flag{ SkipFlag.ToUrfaveV2(), ForceFlag.ToUrfaveV2(), }
The urfave (V2) flags the updater will inject.
var UpdaterFlagsV3 = []cliV3.Flag{ SkipFlag.ToUrfaveV3(), ForceFlag.ToUrfaveV3(), }
The urfave (V3) flags the updater will inject.
Functions ¶
Types ¶
type BoolFlag ¶ added in v1.107.0
type BoolFlag struct {
// The name of the flag, sans the leading double-hyphen.
Name string
// The short description of the flag.
Usage string
}
BoolFlag is a CLI library-agnostic representation of a CLI boolean flag.
func (*BoolFlag) ToUrfaveV2 ¶ added in v1.107.0
func (*BoolFlag) ToUrfaveV3 ¶ added in v1.107.0
type CLIArgs ¶ added in v1.107.0
type CLIArgs interface {
First() string
// Get returns the value of the argument at the given index.
Get(index int) string
}
CLIArgs is an interface for urfave/cli/v2.Args and urfave/cli/v3.Args.
type CLICmd ¶ added in v1.107.0
CLICmd is an interface for urfave/cli/v2.Command and urfave/cli/v3.Command.
type Command ¶ added in v1.107.0
type Command struct {
Name string
Usage string
Commands []*Command
Flags []Flag
Action CommandAction
}
Command is a CLI library-agnostic representation of a CLI (sub)command.
func (*Command) ToUrfaveV2 ¶ added in v1.107.0
ToUrfaveV2 converts the command to a urfave/cli/v2.Command.
func (*Command) ToUrfaveV3 ¶ added in v1.107.0
ToUrfaveV3 converts the command to a urfave/cli/v3.Command.
type CommandAction ¶ added in v1.107.0
type Config ¶ added in v1.106.0
type Config struct {
Version int `yaml:"version"`
// GlobalConfig is the global configuration for the updater
GlobalConfig *UpdateConfiguration `yaml:"global"`
// PerRepositoryConfiguration is configuration for each repository
PerRepositoryConfiguration map[string]*UpdateConfiguration `yaml:"perRepository"`
// UpdaterCache contains the cache for the updater
UpdaterCache map[string]updateCache `yaml:"cache,omitempty"`
}
Config is the configuration for the updater.
func ReadConfig ¶ added in v1.106.0
ReadConfig loads the configuration for the updater.
func (*Config) Get ¶ added in v1.106.0
func (c *Config) Get(repoURL string) (UpdateConfiguration, bool)
Get returns a copy of a specific repository's configuration.
func (*Config) GetGlobal ¶ added in v1.106.0
func (c *Config) GetGlobal() UpdateConfiguration
/ GetGlobal returns a copy of the global configuration.
func (*Config) Set ¶ added in v1.106.0
func (c *Config) Set(repoURL string, conf *UpdateConfiguration)
Set updates a repository's configuration. Call Save() to save the changes.
func (*Config) SetGlobal ¶ added in v1.106.0
func (c *Config) SetGlobal(conf *UpdateConfiguration)
SetGlobal updates the global configuration. Call Save() to save the changes.
type Option ¶
type Option func(*updater)
Options configures an updater
func WithChannel ¶
WithChannel sets the channel to use for checking for updates
func WithCheckInterval ¶
WithCheckInterval sets the interval to check for updates. Defaults to 30 minutes.
func WithDisabled ¶
WithDisabled sets if we should disable the updater or not
func WithExecutableName
deprecated
func WithExecutablePath ¶ added in v1.53.2
WithExecutablePath overrides the path of the executable. See u.executablePath.
func WithForceCheck ¶
WithForceCheck sets whether or not to force the updater to check for updates otherwise updates are checked for only if the last check was more than the update check interval.
func WithLogger ¶
func WithLogger(logger logrus.FieldLogger) Option
WithLogger sets the logger to use for logging. If not set a io.Discard logger is created.
func WithNoProgressBar ¶
WithNoProgressBar sets whether or not to show the progress bar.
func WithPrereleases
deprecated
func WithRepoURL ¶
WithRepoURL sets the repository to use for checking for updates. The expected format is: https://<host>/<repo> Note: It should not contain .git at the end
func WithSkipInstall ¶
WithSkipInstall sets whether or not to skip the installation of the update
func WithSkipMajorVersionPrompt ¶
WithSkipMajorVersionPrompt sets whether or not to skip the prompt for major version upgrades
func WithVersion ¶
WithVersion sets the version to use as the current version when checking for updates. Defaults to app.Info().Version.
type StringFlag ¶ added in v1.107.0
type StringFlag struct {
// The name of the flag, sans the leading double-hyphen.
Name string
// The short description of the flag.
Usage string
// The default value of the flag.
Value string
}
StringFlag is a CLI library-agnostic representation of a CLI string flag.
func (*StringFlag) ToUrfaveV2 ¶ added in v1.107.0
func (f *StringFlag) ToUrfaveV2() cliV2.Flag
func (*StringFlag) ToUrfaveV3 ¶ added in v1.107.0
func (f *StringFlag) ToUrfaveV3() cliV3.Flag
type UpdateConfiguration ¶ added in v1.106.0
type UpdateConfiguration struct {
// CheckEvery is the interval at which the updater will check for updates
// for the provided tool.
CheckEvery time.Duration `yaml:"checkEvery,omitempty"`
// Channel is the channel to use for this tool
Channel string `yaml:"channel,omitempty"`
// SkipPaths is a list of path substrings to skip when checking for updates.
// For example, if you want to skip all installations from Homebrew, add the
// path "/usr/local/Cellar/" to this list.
// This is useful for tools that are installed in multiple ways, such as
// Homebrew and mise. This specifically checks the absolute executable path,
// as determined by `pkg/exec.ResolveExecutable()`.
SkipPaths []string `yaml:"skipPaths,omitempty"`
}
UpdateConfiguration is the configuration for a specific tool, or the global configuration.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package archive contains methods for extracting file(s) from arbitrary archive types.
|
Package archive contains methods for extracting file(s) from arbitrary archive types. |
|
Package release contains methods that interact with releases from VCS providers that do not exist natively in git.
|
Package release contains methods that interact with releases from VCS providers that do not exist natively in git. |
|
Package resolver contains a git tag aware version resolver that supports channels to determine the latest version.
|
Package resolver contains a git tag aware version resolver that supports channels to determine the latest version. |