The updater is component-driven: it compares the daemon and agent versions and
acts only when they differ, so a host whose individual binaries disagree looks
healthy. Carina ran a hand-installed archie-messaging 1.35.0 against a 1.30.0
state store and crash-looped on an RPC the older store does not serve, while
the updater reported "no approved component changes; nothing to install".
The reason a comparison was impossible: three of the six host binaries carried
no version at all. archie-ui, archie-messaging and archie-playbooks did not link
internal/app/archied, so the release ldflags never reached them; the gateway and
state store linked the variable but exposed no flag. Only archied could say what
it was.
- internal/buildinfo carries Version, stamped by all three build sites: the
zip, install.sh, and the updater itself.
- Every host binary answers -version ("<name> <version>"). archied's existing
two-line output is unchanged, because something parses it.
- archie-update-install reads each installed binary before it can report
"nothing to install" and refuses, naming every binary that disagrees with the
daemon's version; after an install it verifies the same set against the
release it just installed, so a binary the release did not rebuild is skew
rather than success.
- TestDistZipShipsEveryHostCommand pins stamping across the three build sites
and requires each cmd/ to report, so a seventh command cannot arrive unstamped.
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
// Package buildinfo carries the release version stamped into every host
|
|
// binary. The updater asks each installed binary what it is, rather than
|
|
// trusting one component's word for a whole install whose binaries may have
|
|
// been replaced by hand (archie-core-k94o).
|
|
package buildinfo
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
// Version and Runtime are stamped per release with
|
|
// -X github.com/samcharles93/archie-core/internal/buildinfo.Version=<version>.
|
|
// The unstamped value is "dev", which is itself informative: a binary built
|
|
// outside a release says so rather than guessing.
|
|
var (
|
|
Version = "dev"
|
|
Runtime = "dev"
|
|
)
|
|
|
|
// Print writes the machine-readable "name version" line the updater reads.
|
|
func Print(name string) {
|
|
fmt.Printf("%s %s\n", name, Version)
|
|
}
|
|
|
|
// RegisterVersionFlag adds -version to the standard flag set. Call the returned
|
|
// function after flag.Parse to print and exit when it was set.
|
|
func RegisterVersionFlag(name string) func() {
|
|
show := flag.Bool("version", false, "print the version and exit")
|
|
return func() {
|
|
if *show {
|
|
Print(name)
|
|
os.Exit(0)
|
|
}
|
|
}
|
|
}
|