Documentation
¶
Overview ¶
Package updatecheck compares the running build with MagicHandy's latest compatible GitHub release. It only discovers releases; installing one remains an explicit user action through the release page.
Index ¶
Constants ¶
const ( // DefaultReleaseAPIURL lists enough releases to select the highest version // compatible with the running build's stable or prerelease channel. DefaultReleaseAPIURL = "https://api.github.com/repos/MagicHandy/MagicHandy/releases?per_page=100" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker serializes release requests and keeps their ETag-backed result in memory. A browser refresh therefore does not spend another unauthenticated GitHub API request.
type Options ¶
type Options struct {
CurrentVersion string
Endpoint string
HTTPClient *http.Client
Clock func() time.Time
CacheTTL time.Duration
}
Options configure a Checker. Endpoint, Clock, and CacheTTL are injectable so tests never contact GitHub.
type Release ¶
type Release struct {
Version string `json:"version"`
Tag string `json:"tag"`
Name string `json:"name,omitempty"`
URL string `json:"url"`
PublishedAt time.Time `json:"published_at,omitempty"`
}
Release is the small, trusted subset of GitHub release data the UI needs.
type State ¶
type State string
State describes the result without making network failure look like an app failure.
const ( // StateAvailable means a newer compatible release exists. StateAvailable State = "available" // StateCurrent means the running version is at least as new as the latest compatible release. StateCurrent State = "current" // StateDevelopment means the running build has no comparable semantic version. StateDevelopment State = "development" // StateNoRelease means the repository has no compatible published release. StateNoRelease State = "no_release" // StateError means the release check could not produce a result. StateError State = "error" )
type Status ¶
type Status struct {
State State `json:"state"`
CurrentVersion string `json:"current_version"`
Latest *Release `json:"latest,omitempty"`
CheckedAt time.Time `json:"checked_at,omitempty"`
Stale bool `json:"stale,omitempty"`
Message string `json:"message,omitempty"`
}
Status is returned by the local API for both startup and manual checks.