Documentation
¶
Overview ¶
Package release looks up the latest published advisor release. It only reads: it never downloads or replaces the binary.
Index ¶
- Constants
- func BackTo(running string, rels []Rel, pulls Pulls) (string, bool)
- func Changelog(ctx context.Context, client *http.Client, url, version string) (string, error)
- func Compare(a, b string) (cmp int, ok bool)
- type Item
- type Notice
- type Options
- type Pull
- type PulledRunning
- type Pulls
- type Rel
- type Result
- type Source
- type Status
Constants ¶
const ( // ListURL is the unauthenticated GitHub endpoint for the newest published releases. ListURL = "https://api.github.com/repos/WoW-Companion/advisor/releases?per_page=30" // ChangelogURL is the CHANGELOG.md at a release tag; %s is the bare version. ChangelogURL = "https://raw.githubusercontent.com/WoW-Companion/advisor/v%s/CHANGELOG.md" // PullsURL is the pulled-version file on the main branch. PullsURL = "https://raw.githubusercontent.com/WoW-Companion/advisor/main/updates/updates.json" // SettleDelay is how long a release must have been public before it is offered, unless the // player asked for updates right away. SettleDelay = 24 * time.Hour // ListSize is how many other versions the Settings list shows beside the running one. ListSize = 5 )
const LatestURL = "https://api.github.com/repos/WoW-Companion/advisor/releases/latest"
LatestURL is the unauthenticated GitHub endpoint for the newest release.
Variables ¶
This section is empty.
Functions ¶
func BackTo ¶ added in v0.7.54
BackTo is the version to go back to from a pulled running version: the pull's own back_to, or when that is missing or itself pulled, the newest older release that is not pulled.
Types ¶
type Item ¶ added in v0.7.54
type Item struct {
Version string `json:"version"`
Date string `json:"date"`
Current bool `json:"current,omitempty"`
}
Item is one row of the Settings version list.
type Notice ¶ added in v0.3.0
Notice is what the overlay's version line needs: whether to say a newer release is available, and which. A failed lookup, a development build or a release that is not newer all read as no notice, so the line stays quiet.
type Options ¶ added in v0.7.54
type Options struct {
Running string
Skipped []string
Immediate bool // "Get updates right away": no settle delay
Now time.Time
}
Options are the player's side of the offer rule.
type Pull ¶ added in v0.7.54
type Pull struct {
Version string `json:"version"`
Reason string `json:"reason"`
BackTo string `json:"back_to"`
}
Pull is one pulled version: a release that must not be offered, and where to go back to.
type PulledRunning ¶ added in v0.7.54
type PulledRunning struct {
Version string `json:"version"`
Reason string `json:"reason"`
BackTo string `json:"back_to"`
}
PulledRunning is what the red banner needs when the running version has been pulled.
type Pulls ¶ added in v0.7.54
type Pulls struct {
Schema int `json:"schema"`
Pulled []Pull `json:"pulled"`
AddonPulled []json.RawMessage `json:"addon_pulled"`
Notice json.RawMessage `json:"notice"`
// Addon is addon_pulled read leniently: an entry that is not a usable object is dropped, never
// an error. It has the same shape as a pulled app version.
Addon []Pull `json:"-"`
}
Pulls is updates/updates.json.
func FetchPulls ¶ added in v0.7.54
FetchPulls reads the pull file; any failure reads as nothing pulled.
func ParsePulls ¶ added in v0.7.54
ParsePulls reads the pull file. A file that cannot be parsed pulls nothing: a broken file must never block an update.
type Rel ¶ added in v0.7.54
type Rel struct {
Version string // "0.7.53", with no leading "v"
Published time.Time // published_at
Body string // the release notes
}
Rel is one published release.
type Result ¶
type Result struct {
Latest string // the release tag, for example "v0.1.0"
Newer bool // Latest is newer than the running version
Known bool // the running version is a release number that can be compared
}
Result is what a lookup found.
type Source ¶ added in v0.7.54
type Source struct {
Client *http.Client
ListURL, PullsURL string
TTL time.Duration // default 10 minutes
// contains filtered or unexported fields
}
Source reads the release list and the pull file, and keeps the answer for a few minutes so the 4-hourly check, a wake-up and "Check now" together stay far inside GitHub's 60-an-hour limit.
type Status ¶ added in v0.7.54
type Status struct {
Available bool `json:"available"`
Latest string `json:"latest"`
Published string `json:"published,omitempty"`
Notes string `json:"notes,omitempty"` // that version's CHANGELOG section; the caller fills it, never the release body
Pulled *PulledRunning `json:"pulled,omitempty"`
Versions []Item `json:"versions,omitempty"`
}
Status is /api/update's answer. Available and Latest keep the shape of the older notice.