/update could report success at the correct target version while the archie-agent container running it never actually changed: the update mechanism trusted the configured installer's exit code and reported whatever version number the release claimed, with nothing verifying the two agreed. The first piece of the fix: a new internal/installtype package reports how a binary was built for distribution (Type(), defaulting to "unknown"), stamped once per release artifact via "-ldflags -X .../installtype.buildType=<value>" rather than guessed at runtime by probing the environment -- restic and Tailscale both treat "which install shape is this" as a build-time decision for the same reason: a probed signal is guessable, a compiled-in one is not. releaseupdate.Service.Install now refuses to run the configured Installer at all when InstallType is unset or installtype.Unknown, so an unstamped or misconfigured build can no longer silently attempt an update it has no way to know is even the right kind for how this instance was deployed. Wired through every real archied build path so the gate doesn't just exist in principle: Taskfile.yml's build task (binary), Dockerfile.archied (container), and install.sh (binary) all now stamp it; cmd/archied/telegram_setup.go wires Service.InstallType from installtype.Type(). Configuration-page display of install type/version and post-update verification against the actually-running reference (not just the installer's reported version) remain open -- this lands the correctness gate, not the full observability surface. Refs #522
32 lines
1.3 KiB
Go
32 lines
1.3 KiB
Go
// Package installtype identifies how the running binary was distributed, so
|
|
// code that must never guess at deployment shape -- most notably the
|
|
// self-update dispatcher -- can fail closed instead of assuming.
|
|
//
|
|
// The install type is decided once, at release-build time, and baked into
|
|
// the binary. It is deliberately never detected at runtime by probing the
|
|
// environment (checking for a container marker file, a systemd env var,
|
|
// and so on): those signals are guessable and can be present for reasons
|
|
// that have nothing to do with how the binary would actually be updated. A
|
|
// binary that was never stamped by the release pipeline (a local
|
|
// `go build`, for instance) reports Unknown, and callers that would
|
|
// otherwise silently guess must instead refuse.
|
|
package installtype
|
|
|
|
// Unknown is what Type reports when a build was never stamped.
|
|
const Unknown = "unknown"
|
|
|
|
// buildType is stamped per release artifact via
|
|
// "-ldflags -X github.com/samcharles93/archie-core/internal/installtype.buildType=<value>",
|
|
// one value per build target -- e.g. "binary" for a native build,
|
|
// "container" for a Docker image build. Never set anywhere else.
|
|
var buildType = Unknown
|
|
|
|
// Type reports how this binary was built for distribution: Unknown unless
|
|
// stamped by the release pipeline.
|
|
func Type() string {
|
|
if buildType == "" {
|
|
return Unknown
|
|
}
|
|
return buildType
|
|
}
|