selfupdate

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package selfupdate updates the running draugr binary to a released version. Downloads are verified against the release's SHA-256 checksums (mandatory) and its keyless cosign signature (best-effort, when the cosign CLI is present) before the binary is replaced.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CurrentVersion

func CurrentVersion() string

CurrentVersion is the running binary's version (build stamp), without a leading "v".

func LatestVersion

func LatestVersion(ctx context.Context, client *http.Client) (string, error)

LatestVersion resolves the latest published release version (no leading "v") via the github.com releases/latest redirect — deliberately not the api.github.com REST endpoint, which is rate-limited and has been flaky. Use a short timeout for interactive/offline paths.

Types

type Options

type Options struct {
	Version string       // "" = latest
	Client  *http.Client // nil = default
}

Options configure an update.

type Result

type Result struct {
	Previous          string // version before (may be "dev")
	Target            string // version updated (or would update) to
	NoChange          bool   // already on the target version
	SignatureVerified bool   // cosign signature verified (vs SHA-256-only)
	Note              string // provenance note (e.g. why cosign was skipped)
	Path              string // the binary that was replaced
}

Result describes a self-update outcome.

func Update

func Update(ctx context.Context, opts Options) (Result, error)

Update replaces the running binary with the target release (latest if unset), after verifying its checksum and (best-effort) cosign signature. It is a no-op when already on the target version.

Jump to

Keyboard shortcuts

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