Documentation
¶
Overview ¶
Package selfupdate replaces the running argus binary with the latest published release.
This is the most security-sensitive thing in the codebase, and it sits in a tool whose entire pitch is that it cannot write anything. So the rules here are strict and deliberately fail closed:
- HTTPS only, and only to the release host.
- The published SHA-256 must be fetched and must match. If the checksum cannot be retrieved, the update is abandoned — an unverifiable download is treated as a hostile one.
- Nothing downloaded is ever executed during the update.
- The replacement is atomic: verify fully, write beside the target, then rename over it. A failure at any point leaves the existing binary untouched rather than truncated.
- A locally-built binary is never silently clobbered.
Note this writes only to the local filesystem. It gives argus no ability to write to a cluster, which remains enforced by TestNoMutatingVerbs.
Index ¶
Constants ¶
const Repo = "backendArchitect/argus"
Repo is the source of releases. A constant, not a flag: letting a caller redirect where the binary comes from would hand an attacker the whole update channel.
Variables ¶
This section is empty.
Functions ¶
func AssetName ¶
AssetName is the archive this platform needs, matching what the release workflow publishes.
func Decide ¶
Decide works out whether to install, and is separated from the download so the rules can be tested without a network. The ordering matters and got it wrong once: -check used to fail with the local-build refusal, when a dry run must never fail — it changes nothing, so there is nothing to protect against.
Returns a note to print and stop on, or ("", nil) to proceed with the install.
func IsRelease ¶
IsRelease reports whether a version string is a clean release tag rather than a local build.
Go stamps a locally-built binary with a pseudo-version ("v0.1.6-0.2026...") and appends "+dirty" when the tree has uncommitted changes. Overwriting that with a published release would silently throw away someone's work in progress, so Update refuses unless forced.
Types ¶
type Options ¶
type Options struct {
Current string // the running version
Force bool // replace even a locally-built binary
DryRun bool // check and report, change nothing
}
Options controls an update.