Documentation
¶
Overview ¶
Package selfupdate replaces the running orb with a signed release: it fetches the same archive and checksums.txt that scripts/install.sh does, verifies the signature and sha256, and swaps the binary by atomic rename. Deliberately absent: backups, retries, elevation.
Index ¶
- Constants
- Variables
- func BuildVersion(stamped string, info *debug.BuildInfo, ok bool) string
- func IsDevelopment(value string) bool
- func LatestTag(ctx context.Context, currentVersion string, client *http.Client, ...) (string, error)
- func Plain(value string) string
- func Swap(target string, payload []byte, before os.FileInfo) error
- type Updater
Constants ¶
const ( MetadataWait = 30 * time.Second DownloadWait = 5 * time.Minute LatestReleaseURL = "https://api.github.com/repos/OrdalieTech/orb/releases/latest" )
Variables ¶
Functions ¶
func BuildVersion ¶
BuildVersion recovers the version for `go install ...@latest`, which builds without the release ldflags: the module proxy stamps the tag into the build info. A "(devel)" build has none and skips.
func IsDevelopment ¶
Types ¶
type Updater ¶
type Updater struct {
Key ed25519.PublicKey
CurrentVersion string
ReleaseURL string
ReleaseBase string
Client *http.Client
Offline bool
Executable func() (string, error)
ResolveLinks func(string) (string, error)
}
Updater injects every effect an update has, so a test never resolves or overwrites the binary running it.
func (Updater) Download ¶
Download fetches and verifies the orb binary of release tag for goos/goarch, from the exact URLs scripts/install.sh builds.
func (Updater) Update ¶
func (u Updater) Update(ctx context.Context, step func(string) func()) (tag, target string, err error)
Update brings the running binary to the latest release. step announces "checking release", "fetching release" and "replacing binary" as each begins and returns the func that ends it. It returns the release installed and the file replaced; ErrDevelopment, ErrOffline and ErrCurrent leave everything as it was.