/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
29 lines
1.1 KiB
Go
29 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/samcharles93/archie-core/internal/config"
|
|
"github.com/samcharles93/archie-core/internal/installtype"
|
|
)
|
|
|
|
// TestMakeUpdateServiceWiresInstallType is the regression test for
|
|
// archie-core-522's fail-closed guarantee actually reaching production: a
|
|
// Service built without InstallType always refuses to install (see
|
|
// releaseupdate.ErrUnknownInstallType), so wiring it here is what makes
|
|
// /update work at all for a correctly-stamped build, not just a detail.
|
|
func TestMakeUpdateServiceWiresInstallType(t *testing.T) {
|
|
cfg := config.Config{}
|
|
cfg.Chat.Telegram.UpdateCheckCommand = []string{"archie-update-check"}
|
|
cfg.Chat.Telegram.UpdateInstallCommand = []string{"archie-update-install"}
|
|
|
|
service := makeUpdateService(telegramSetup{Cfg: config.NewHolder(cfg)})
|
|
|
|
if service == nil {
|
|
t.Fatal("makeUpdateService returned nil despite a configured check command")
|
|
}
|
|
if service.InstallType != installtype.Type() {
|
|
t.Errorf("Service.InstallType = %q, want installtype.Type() = %q", service.InstallType, installtype.Type())
|
|
}
|
|
}
|