Documentation
¶
Overview ¶
Package updater installs releases of Compa published on github.com/xibodev/compa.
Every release ships one archive per platform, compa_<version>_<os>_<arch> (.zip on Windows, .tar.gz elsewhere), holding BOTH programs -- compa, the launcher, and compa-kernel, the harness it supervises -- plus a SHA256SUMS file listing the SHA-256 of every asset. An update installs both programs from the same verified archive, so the launcher and the kernel beside it cannot drift onto different versions.
Index ¶
Constants ¶
const ( // Owner and Repo name the only repository updates come from. Owner = "xibodev" Repo = "compa" // LauncherName and KernelName are the two programs every archive holds // (with ".exe" on Windows). LauncherName = "compa" KernelName = "compa-kernel" // ChecksumsName is the release asset listing the SHA-256 of every other // asset, in the format sha256sum writes. ChecksumsName = "SHA256SUMS" )
Variables ¶
This section is empty.
Functions ¶
func ArchiveName ¶
ArchiveName is the release asset holding both programs for goos/goarch.
func NewUpdateCommand ¶
NewUpdateCommand returns the "update" command. It installs a release into the directory of the running program -- both compa-kernel and compa, from the same archive -- whichever of the two binaryName is.
func NormalizeTag ¶
NormalizeTag turns "1.2.3" or "v1.2.3" into the release tag "v1.2.3". An empty string stays empty and means the latest release.
func TagFromURL ¶
TagFromURL returns the release a github.com/xibodev/compa release URL names, or "" for the latest release. Updates never come from anywhere else, so any other URL is an error. Accepted forms:
https://github.com/xibodev/compa[/releases[/latest]] https://github.com/xibodev/compa/releases/tag/<tag> https://api.github.com/repos/xibodev/compa/releases/latest https://api.github.com/repos/xibodev/compa/releases/tags/<tag>
Types ¶
type Options ¶
type Options struct {
// Tag is the release to install, such as "v1.2.3" ("1.2.3" works too).
// Empty installs the latest release.
Tag string
// Dir is the directory holding compa and compa-kernel. Empty means the
// directory of the running executable, which is where an install keeps
// both programs.
Dir string
// Log receives one line per step for a person to read. Nil discards them.
Log io.Writer
// APIBaseURL replaces https://api.github.com and HTTPClient replaces the
// default client. Tests point them at a fake release; nothing else
// should set them.
APIBaseURL string
HTTPClient *http.Client
}
Options selects the release to install and where to install it.
type Result ¶
type Result struct {
Tag string // release tag, e.g. "v1.2.3"
Version string // the tag without its leading "v"
Dir string // directory holding the updated programs
Archive string // the archive both programs came from
}
Result describes an installed release.
func Update ¶
Update installs one release of Compa into opts.Dir. It downloads the archive for the running OS and architecture, verifies it against the release's SHA256SUMS, and replaces compa-kernel and then compa -- the launcher last, because it is normally the program running the update. Both programs are replaced or neither is. Running programs keep the old version until they restart.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package updatertest serves fake GitHub releases of xibodev/compa, shaped like the ones the release workflow publishes, for tests of the updater and of the endpoints built on it.
|
Package updatertest serves fake GitHub releases of xibodev/compa, shaped like the ones the release workflow publishes, for tests of the updater and of the endpoints built on it. |