Documentation
¶
Overview ¶
Package autoupdate implements automatic version updates for Stripe CLI binaries installed with the install script.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GetStateDirFn = getStateDirDefault
GetStateDirFn is the active implementation; tests can override it.
Functions ¶
func ApplyIfPending ¶
func ApplyIfPending()
ApplyIfPending checks for a pending update marker and applies it. If an update is applied, it re-execs the current process with the new binary. This function only returns if no update was applied — or, on Windows, if the new binary could not be started, in which case this invocation carries on running the image it already has.
func CheckForUpdate ¶
func CheckForUpdate()
CheckForUpdate checks for a newer CLI version and writes a marker file if an update is available. Skips major version changes. This is called synchronously after command execution, rate-limited to once per day.
func GetStateDir ¶
func GetStateDir() string
GetStateDir returns the path to the autoupdate state directory.
func IsOptedOut ¶
func IsOptedOut() bool
IsOptedOut reports whether the user has disabled auto-update.
func IsScriptInstall ¶ added in v1.53.1
func IsScriptInstall() bool
IsScriptInstall reports whether the current binary was installed by the install script, the only install method that auto-update replaces the binary for.
func VerifyChecksum ¶
VerifyChecksum verifies the SHA256 checksum of a file.
func WriteMarker ¶
func WriteMarker(m UpdateMarker)
WriteMarker writes an update marker to the state directory.
Types ¶
type UpdateMarker ¶
type UpdateMarker struct {
Version string `json:"version"`
DownloadURL string `json:"download_url"`
Checksum string `json:"checksum"`
ReleaseNotes string `json:"release_notes"`
// StagedAt is when the check wrote this marker, as a Unix timestamp. The
// gap between it and the moment the update is applied is how long a user
// sat on a version we already knew was old, which is the number that says
// whether auto-update is actually keeping the fleet current.
//
// Omitted when empty so that a marker written by hand -- as the
// auto-upgrade canary does -- stays valid, and reported only when set.
StagedAt int64 `json:"staged_at,omitempty"`
}
UpdateMarker represents a staged update ready to be applied.
func ReadMarker ¶
func ReadMarker() *UpdateMarker
ReadMarker reads a pending update marker, or returns nil if none exists.