autoupdate

package
v1.53.1 Latest Latest
Warning

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

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

Documentation

Overview

Package autoupdate implements automatic version updates for Stripe CLI binaries installed with the install script.

Index

Constants

This section is empty.

Variables

View Source
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 ClearMarker

func ClearMarker()

ClearMarker removes the pending update marker.

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

func VerifyChecksum(filePath, expected string) bool

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.

Jump to

Keyboard shortcuts

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