Documentation
¶
Overview ¶
Package upgrade runs the read-only checks that gate a platform self-upgrade.
Index ¶
Constants ¶
const ( ChannelStable = "stable" ChannelBeta = "beta" ChannelEdge = "edge" )
Update channels a running build can compare itself against. ChannelStable is GitHub's own "latest release" concept (unchanged default behavior); ChannelBeta and ChannelEdge follow release.yml's own image-channel job scheme: a hyphenated SemVer tag (e.g. v1.2.3-beta.1) gets :beta, a main push gets :edge.
const ( StatusOK = "ok" StatusWarn = "warn" StatusFail = "fail" StatusUnknown = "unknown" )
Check statuses.
const ( ChecksumsAsset = "checksums.txt" SignatureAsset = "checksums.txt.sigstore.json" )
Asset names the release workflow publishes next to the binaries.
const DefaultCacheTTL = time.Hour
DefaultCacheTTL is how long a Cache entry stays fresh before a caller should fetch again: shared by GET /api/v1/updates, updatecheck.Scheduler, and alerting's kind=version_skew evaluator, so none of them hits GitHub more often than this regardless of its own call cadence.
Variables ¶
This section is empty.
Functions ¶
func UpdateAvailable ¶
UpdateAvailable reports whether latest represents a newer build than currentVersion. A "dev" build never reports an update available: there is no meaningful newer build to compare an unreleased build against. Two SemVer tags compare by precedence (beta.9 < beta.15); anything else (edge's main-<sha>) falls back to inequality.
func ValidChannel ¶
ValidChannel reports whether c is one of the three recognized channels.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache holds the last successful channel lookup, so GET /api/v1/updates and internal/updatecheck.Scheduler don't hit GitHub on every call. Keyed by channel (not just a bare TTL) so switching channels never serves a stale result cached for a different one.
type Check ¶
type Check struct {
Code string `json:"code"`
Name string `json:"name"`
Status string `json:"status"`
Message string `json:"message"`
}
Check is one preflight result.
type Fetchers ¶
type Fetchers struct {
Stable func(context.Context) (*Release, error)
Beta func(context.Context) (*Release, error)
Edge func(context.Context) (*Release, error)
}
Fetchers groups one fetch function per channel, the same overridable seam Router.fetchLatestRelease (internal/api/updates.go) already establishes for testing without a real outbound call.
func DefaultFetchers ¶
func DefaultFetchers() Fetchers
DefaultFetchers wires the three real GitHub lookups above.
type Inputs ¶
type Inputs struct {
Lookup func(string) (string, bool)
DockerVersion func(ctx context.Context) (string, error)
FreeBytes func() (int64, error)
NewestBackup func() (time.Time, bool, error)
Now time.Time
AssetNames []string
ReleaseKnown bool
}
Inputs is everything Run needs, injected so tests use fakes.
type Release ¶
Release is the subset of a GitHub release, or (for the edge channel) a main-branch commit treated as a pseudo-release, that a channel-aware update check needs.
func FetchLatestBeta ¶
FetchLatestBeta fetches the newest prerelease from GitHub's releases list, skipping drafts. nil, nil means no prerelease has ever been published.
func FetchLatestEdge ¶
FetchLatestEdge fetches the latest commit on main and reports it as a pseudo-release tagged "main-<short sha>", matching release.yml's own image-channel job scheme for what a main push's Docker image tag is (IMAGE_VERSION: main-<sha>). nil, nil means the lookup found nothing (an empty or inaccessible repo).
func FetchLatestStable ¶
FetchLatestStable fetches GitHub's /releases/latest: the newest non-prerelease, non-draft release. With no stable release it falls back to the newest pre-release (install.sh's rule). nil, nil means nothing has been published at all.