Documentation
¶
Overview ¶
Package upgrade replaces the running octo binary with the latest GitHub release: resolve the latest version from the releases/latest redirect, download the platform archive plus checksums.txt, verify the archive's SHA-256, extract the binary, and atomically swap it into place. The trust anchor is GitHub's TLS plus the release assets' integrity — there is no signature layer. See dev-docs/octo-upgrade-design.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BaseURL = "https://github.com/Leihb/octo-agent"
BaseURL is the release origin. A var so tests point it at httptest.
var ErrUpToDate = errors.New("already up to date")
ErrUpToDate reports that the installed version is already the latest. Callers treat it as success, not failure.
Functions ¶
func Check ¶
Check resolves the latest released version (no leading "v") by following none of the releases/latest redirect: the target tag is in the Location header. No GitHub API, so no rate-limit coupling.
func CompareVersions ¶
CompareVersions returns -1/0/+1 for a<b, a==b, a>b on the numeric major.minor.patch triple. Non-numeric parts compare as 0.
func Eligible ¶
func Eligible() error
Eligible reports whether the running build may be auto-upgraded: a release build carries a plain SemVer version AND a commit SHA. Dev builds (-dev/-snapshot suffix from make, or a bare `go build` with no ldflags at all) refuse so a local build isn't silently replaced by an older release.
Types ¶
type Options ¶
type Options struct {
// Force proceeds despite a dev build or an already-latest version.
Force bool
// Log receives one human-readable progress line per step. Nil is fine.
Log func(string)
// TargetPath overrides the binary to replace. Defaults to
// os.Executable() (symlinks resolved); tests point it at a temp file.
TargetPath string
}
Options configures Run.
type Prepared ¶
type Prepared struct {
// Latest is the version Install will put in place.
Latest string
// contains filtered or unexported fields
}
Prepared holds a verified, extracted new binary ready to install. The split from Run exists so the server can do the slow part (download) outside the restart drain gate and hold the gate only for the seconds-long Install.