update

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package update self-updates the CLI binary from its GitHub releases. It is the fleet-standard self-updater: fetch the latest release, verify the archive against checksums.txt (mandatory), then atomically replace the running binary.

PER-CLI: set githubRepo + binaryName below. Nothing else changes — findAssets is robust to the fleet's two archive-naming styles (with/without version, amd64/x86_64).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNewer

func IsNewer(latest, current string) bool

IsNewer reports whether release tag `latest` is a newer version than `current`. Exported so an `update check` command can tell the user an update is available.

Types

type Asset

type Asset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

type Release

type Release struct {
	TagName    string  `json:"tag_name"`
	Prerelease bool    `json:"prerelease"`
	Assets     []Asset `json:"assets"`
}

Release / Asset mirror the subset of the GitHub releases API we use.

type Result

type Result struct {
	Updated     bool
	FromVersion string
	ToVersion   string
	Error       error
}

Result reports the outcome of an update attempt.

type Updater

type Updater struct {
	CurrentVersion string
	HTTPClient     *http.Client
	ExecutablePath string // overridable for tests
}

Updater checks for and applies updates.

func NewUpdater

func NewUpdater(currentVersion string) *Updater

func (*Updater) CheckAndUpdate

func (u *Updater) CheckAndUpdate(ctx context.Context) *Result

CheckAndUpdate updates to the latest release if it is newer than the running version.

func (*Updater) GetLatestRelease

func (u *Updater) GetLatestRelease(ctx context.Context) (*Release, error)

GetLatestRelease fetches the newest non-draft release.

Jump to

Keyboard shortcuts

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