selfupdate

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package selfupdate implements `dockercmd --self-upgrade`: download the latest GitHub release asset for this OS/arch, verify its SHA-256 and atomically replace the running executable.

Self-update executes downloaded code, so the checksum check is mandatory: the binary is only swapped in once its SHA-256 matches the digest GitHub records for the asset. The download lands in the target directory (same filesystem) so the final swap is an atomic rename.

Index

Constants

This section is empty.

Variables

View Source
var ErrUpToDate = errors.New("already up to date")

ErrUpToDate is returned by Apply when the running version is already current.

Functions

func Run

func Run(ctx context.Context, current string, w io.Writer, checkOnly bool) error

Run checks for a newer release and, unless checkOnly is set, downloads and installs it. Progress is written to w; it is a no-op (with a message) when the running version is already current. This is the CLI (`--self-upgrade`) entry.

Types

type Result added in v1.5.0

type Result struct {
	From   string `json:"from"`   // version before the upgrade
	To     string `json:"to"`     // version now staged on disk
	Asset  string `json:"asset"`  // release asset that was installed
	SHA256 string `json:"sha256"` // verified checksum of the new binary
}

Result describes a completed upgrade.

func Apply added in v1.5.0

func Apply(ctx context.Context, current string) (Result, error)

Apply downloads, verifies and installs the latest release, returning a Result describing the upgrade. It is the programmatic (in-app) entry point and writes no progress output. ErrUpToDate is returned when nothing newer exists.

Jump to

Keyboard shortcuts

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