Documentation
¶
Overview ¶
Package updatecheck tells a self-hosted runtime whether a newer release is published: a periodic GET of the project's latest-release address, compared with the running version. It sends nothing but that request.
Index ¶
Constants ¶
const ( ChannelStable = "stable" ChannelLatest = "latest" )
The update channels of an installation. "latest" is every published release. "stable" is the release the stable pointer names: a small file beside the releases that moves only when somebody promotes a release (tools/relchannel, docs/update-channels.md), never by a merge.
const ( // DefaultInterval is the time between checks. DefaultInterval = 12 * time.Hour // Timeout bounds one request. Timeout = 10 * time.Second )
const DefaultStableURL = "https://github.com/ly-solutions/harnessly/releases/download/channels/stable.json"
DefaultStableURL is the project's stable pointer: an asset of the "channels" release, read without the API.
const DefaultURL = "https://api.github.com/repos/ly-solutions/harnessly/releases/latest"
DefaultURL is the project's latest published (non-draft, non-pre-release) release.
const DefaultWindow = 7 * 24 * time.Hour
DefaultWindow is how long a release must have been out before it may become stable.
const PointerSchema = 1
PointerSchema is the version of the pointer's format.
const WithdrawnMark = "[withdrawn]"
WithdrawnMark in the title or the notes of a release says it was withdrawn: it never becomes stable.
Variables ¶
var ErrNoStable = errors.New("no stable release is named")
ErrNoStable: the source of releases names no stable one, so an installation on the stable channel stays as it is.
var ErrRefused = errors.New("not promoted")
ErrRefused wraps every reason a release may not become stable.
Functions ¶
func Comparable ¶
Comparable says whether the running version can be compared with a release at all.
func ParseChannel ¶
ParseChannel reads a channel setting. Empty is the default, stable. ok is false for a word that is no channel; the answer is then stable too: the careful one.
Types ¶
type Candidate ¶
type Candidate struct {
TagName string `json:"tag_name"`
Name string `json:"name"`
Body string `json:"body"`
HTMLURL string `json:"html_url"`
PublishedAt string `json:"published_at"`
Draft bool `json:"draft"`
Prerelease bool `json:"prerelease"`
}
Candidate is a published release as the releases API describes it, the part a promotion reads.
type Checker ¶
type Checker struct {
// Current is the running version, as built in ("dev" or unparsable means there is nothing to compare).
Current string
// URL is the latest-release address; empty means DefaultURL.
URL string
// Channel is ChannelStable or ChannelLatest; empty reads the latest release, as a checker without channels did.
Channel string
// StableURL is the stable pointer's address. Empty means DefaultStableURL while URL is the project's own; a
// mirror named by URL has no pointer until StableURL names it.
StableURL string
// Client makes the request; nil means one that honours the proxy environment and times out.
Client *http.Client
// Interval is the time between checks; zero means DefaultInterval.
Interval time.Duration
// Log gets one line per failed check; may be nil.
Log func(msg string, err error)
// contains filtered or unexported fields
}
Checker asks for the newest release of its channel and keeps the answer. Set Current.
func (*Checker) Check ¶
Check makes one request and updates Status. A 304 keeps the previous answer.
type Pointer ¶
type Pointer struct {
Schema int `json:"schema"`
Channel string `json:"channel"`
// Version is the stable release, X.Y.Z.
Version string `json:"version"`
// URL is the release's page.
URL string `json:"url,omitempty"`
// ReleasedAt is when the release was published, PromotedAt when it became stable; RFC 3339.
ReleasedAt string `json:"released_at,omitempty"`
PromotedAt string `json:"promoted_at,omitempty"`
}
Pointer is the stable pointer's file.
func ParsePointer ¶
ParsePointer reads a stable pointer. Fields it does not know are ignored, so a later format that only adds reads too.
type Promotion ¶
type Promotion struct {
// Now is the time of the promotion.
Now time.Time
// Window is how long the release must have been out; zero means DefaultWindow.
Window time.Duration
// Current is the pointer in place, nil when there is none yet.
Current *Pointer
// AllowOlder lets the pointer move back to an older release (taking a bad stable one away).
AllowOlder bool
}
Promotion is what a promotion is decided by.
type Status ¶
type Status struct {
Current string `json:"current"`
Latest string `json:"latest,omitempty"`
URL string `json:"url,omitempty"`
PublishedAt string `json:"publishedAt,omitempty"`
UpdateAvailable bool `json:"updateAvailable"`
// Channel is the update channel the answer is of (channel.go); empty when the checker was given none.
Channel string `json:"channel,omitempty"`
// Note says, for the person, why the channel has no answer (no stable release was named yet, say).
Note string `json:"note,omitempty"`
}
Status is what the page is told.