Documentation
¶
Overview ¶
Package updatecheck provides GitHub release checking for CLI application updates.
Index ¶
Constants ¶
const ( // DefaultCacheTTL is the default time-to-live for cached update check results. DefaultCacheTTL = 24 * time.Hour // DefaultAPITimeout bounds a release-metadata request. The payload is a // few KB, so a short timeout is appropriate. DefaultAPITimeout = 3 * time.Second // DefaultDownloadTimeout bounds a release asset download. http.Client's // Timeout covers the response body, so this has to accommodate a // multi-megabyte binary over a slow link — not the API timeout. DefaultDownloadTimeout = 15 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func DefaultCachePath ¶ added in v0.16.1
DefaultCachePath returns the stable on-disk cache path for a GitHub release checker. It honors an absolute XDG_CACHE_HOME and otherwise uses ~/.cache. The repository identity is hashed so owner/repo input cannot escape the updatecheck cache directory through path traversal.
func NewSecureClient ¶ added in v0.12.0
NewSecureClient returns the hardened HTTP client used for GitHub release requests: TLS 1.3 minimum, a short request timeout suited to the release metadata API, and a redirect policy that refuses to leave GitHub hosts.
Use NewSecureClientWithTimeout for asset downloads, which need a far longer timeout than a metadata call.
func NewSecureClientWithTimeout ¶ added in v0.12.0
NewSecureClientWithTimeout returns a client with the same hardening as NewSecureClient but a caller-chosen overall timeout. http.Client.Timeout covers reading the response body too, so a download needs a much larger value than a metadata request — see DefaultDownloadTimeout.
A non-positive timeout means no timeout.
The redirect policy refuses any redirect that leaves a GitHub host. The initial request URL is not restricted, so a consumer pointing at a different host still works; only being bounced off GitHub mid-request is refused.
Types ¶
type Checker ¶
type Checker struct {
HTTPClient httpDoer
LatestReleaseURL string
CacheTTL time.Duration
// CachePath is the JSON file used for the cross-process update cache. New
// checkers receive a stable XDG cache path; set it to an empty string to
// disable persistence or to an explicit path for isolated consumers.
CachePath string
// contains filtered or unexported fields
}
Checker checks for application updates via GitHub releases.
func NewChecker ¶
NewChecker creates a new update checker for the given GitHub repo. The URL format is https://api.github.com/repos/{owner}/{repo}/releases/latest.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cosign provides Cosign keyless signature verification for self-update workflows.
|
Package cosign provides Cosign keyless signature verification for self-update workflows. |
|
Package extract provides safe archive extraction (tar.gz and zip) for self-update workflows, with path-traversal protection and configurable binary detection.
|
Package extract provides safe archive extraction (tar.gz and zip) for self-update workflows, with path-traversal protection and configurable binary detection. |
|
Package installmethod detects how a binary was installed to determine whether self-update is safe or if the user should update via their package manager, Go toolchain, or by rebuilding from source.
|
Package installmethod detects how a binary was installed to determine whether self-update is safe or if the user should update via their package manager, Go toolchain, or by rebuilding from source. |
|
Package updateapply implements the apply half of self-update: given an updatecheck.Release, it downloads the matching asset, verifies its checksum against the release's goreleaser checksums.txt, and atomically replaces the running binary with backup + rollback.
|
Package updateapply implements the apply half of self-update: given an updatecheck.Release, it downloads the matching asset, verifies its checksum against the release's goreleaser checksums.txt, and atomically replaces the running binary with backup + rollback. |