Documentation
¶
Overview ¶
Package update provides the Cobra command for self-updating the CLI binary to the latest released version from the configured release source (GitHub or GitLab), with support for private repositories via token authentication.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCmdUpdate ¶
func NewCmdUpdate(props *p.Props, opts ...UpdateConfigOption) *setup.Command
NewCmdUpdate creates the update command for self-updating the tool binary. The optional [UpdateConfigOption]s are threaded into both the online and offline update paths — pass WithUpdater / WithOfflineUpdater to inject test doubles without mutating any package-level seam (parallel-safe).
func UpdateConfig ¶
UpdateConfig re-runs the init flow after a successful update to ensure config compatibility.
Types ¶
type NewOfflineUpdaterFunc ¶ added in v0.17.0
NewOfflineUpdaterFunc constructs an Updater for offline, file-based updates.
var ExportNewOfflineUpdater NewOfflineUpdaterFunc = func(props *p.Props) Updater { return setup.NewOfflineUpdater(props.Tool, props.Logger, props.FS) }
Deprecated: ExportNewOfflineUpdater is a package-level test seam that races under parallel tests. Inject a factory with WithOfflineUpdater instead. Retained for one minor release for backward compatibility; it is consulted only as the default when no WithOfflineUpdater option is given.
type NewUpdaterFunc ¶ added in v0.17.0
type NewUpdaterFunc func(ctx context.Context, props *p.Props, version string, force bool) (Updater, error)
NewUpdaterFunc constructs an Updater for online updates.
var ExportNewUpdater NewUpdaterFunc = func(ctx context.Context, props *p.Props, version string, force bool) (Updater, error) { return setup.NewUpdater(ctx, props, version, force) }
Deprecated: ExportNewUpdater is a package-level test seam that races under parallel tests. Inject a factory with WithUpdater instead. Retained for one minor release for backward compatibility; it is consulted only as the default when no WithUpdater option is given.
type UpdateConfigOption ¶
type UpdateConfigOption func(*updateConfigOptions)
UpdateConfigOption configures the UpdateConfig function.
func WithExecCommand ¶
WithExecCommand overrides exec.CommandContext for testing.
func WithOfflineUpdater ¶ added in v0.17.0
func WithOfflineUpdater(fn NewOfflineUpdaterFunc) UpdateConfigOption
WithOfflineUpdater injects the offline Updater factory, replacing the default that builds a real setup.NewOfflineUpdater. The parallel-safe replacement for mutating the deprecated ExportNewOfflineUpdater package var.
func WithUpdater ¶ added in v0.17.0
func WithUpdater(fn NewUpdaterFunc) UpdateConfigOption
WithUpdater injects the online Updater factory, replacing the default that builds a real setup.NewUpdater. This is the parallel-safe replacement for mutating the deprecated ExportNewUpdater package var: each call site receives its own factory, so concurrent tests cannot clobber one another.
type UpdateResult ¶
type UpdateResult struct {
PreviousVersion string `json:"previous_version"`
NewVersion string `json:"new_version"`
Updated bool `json:"updated"`
}
UpdateResult contains the outcome of a successful update.
type Updater ¶
type Updater interface {
GetLatestVersionString(ctx context.Context) (string, error)
Update(ctx context.Context) (string, error)
UpdateFromFile(filePath string) (string, error)
GetReleaseNotes(ctx context.Context, from, to string) (string, error)
GetCurrentVersion() string
}
Updater defines the interface for self-updating functionality.