update

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 14 Imported by: 0

README

Update Command

Updates the tool to the latest or specified version.

For detailed information on update processes and migration, see the Built-in Commands Documentation.

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

func UpdateConfig(ctx context.Context, props *p.Props, binPath string, opts ...UpdateConfigOption)

UpdateConfig re-runs the init flow after a successful update to ensure config compatibility.

Types

type NewOfflineUpdaterFunc added in v0.17.0

type NewOfflineUpdaterFunc func(props *p.Props) Updater

NewOfflineUpdaterFunc constructs an Updater for offline, file-based updates.

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.

type UpdateConfigOption

type UpdateConfigOption func(*updateConfigOptions)

UpdateConfigOption configures the UpdateConfig function.

func WithExecCommand

func WithExecCommand(fn func(context.Context, string, ...string) *exec.Cmd) UpdateConfigOption

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.

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. 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.

func Update

func Update(ctx context.Context, props *p.Props, version string, force bool, out io.Writer, opts ...UpdateConfigOption) (*UpdateResult, error)

Update downloads and installs the specified version (or latest) of the tool.

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.

Jump to

Keyboard shortcuts

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