Documentation
¶
Overview ¶
Package selfupgrade replaces the running rune binary with the latest stable release. Nothing is extracted or installed until the release's checksum list is proven to be signed by the release workflow and the downloaded archive matches it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PublicTrust ¶
PublicTrust returns a source of the public Sigstore trust root. It is fetched through TUF on every call and nothing is cached on disk, so a run writes nothing outside the install directory.
Types ¶
type Config ¶
type Config struct {
// Version is the version this binary reports; Stamped says whether it was
// set at build time (a release build) or read from module build info.
Version string
Stamped bool
ExePath string
GOOS string
GOARCH string
Getenv func(string) string
Now func() time.Time
HTTP *http.Client
APIBase string
DownloadBase string
// Trust returns the Sigstore trust root; Issuer and Subject are the only
// signer identity accepted.
Trust func(context.Context) (root.TrustedMaterial, error)
Issuer string
Subject string
// Logf receives progress lines, without a prefix or newline.
Logf func(format string, args ...any)
}
Config is everything an upgrade depends on. All of it is injected so tests run without the network and nothing lives in package globals.
type Error ¶
type Error struct {
Reason Reason
Installed string
Target string
// Subject is what the message is about: a host, a file, a directory, a
// path, or an os/arch pair, depending on Reason.
Subject string
Limit string
Until string
// Status is the HTTP status behind a failed request, when there was one.
Status int
Err error
}
Error is an expected failure of an upgrade. The installed binary is unchanged whenever one is returned, with one exception the message spells out: a Windows replacement that failed and could not be rolled back.
type Origin ¶
type Origin string
Origin is how the running binary was installed. Only a standalone install is upgraded in place; every other origin has its own upgrade path, and overwriting it would leave that tool's records wrong.
type Reason ¶
type Reason string
Reason names why an upgrade did not happen. Each has its own message.
const ( ReasonOffline Reason = "offline" ReasonTimeout Reason = "timeout" ReasonRateLimited Reason = "rate-limited" ReasonReleaseLookup Reason = "release-lookup" ReasonUnsupportedPlatform Reason = "unsupported-platform" ReasonUnverified Reason = "unverified" ReasonChecksumMismatch Reason = "checksum-mismatch" ReasonDownloadFailed Reason = "download-failed" ReasonTooLarge Reason = "too-large" ReasonBadArchive Reason = "bad-archive" ReasonNotWritable Reason = "not-writable" ReasonInProgress Reason = "in-progress" ReasonReplaceFailed Reason = "replace-failed" )
type Refused ¶
Refused is returned when the install is not Rune's to upgrade. The message names the command that upgrades it the way it was installed.
type Result ¶
Result describes a run. Installed and Path are set as soon as they are known, so they are meaningful next to an error too.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package upgradetest builds a signed fixture release on a local TLS server, in the layout a real Rune release has.
|
Package upgradetest builds a signed fixture release on a local TLS server, in the layout a real Rune release has. |