From 1c6281d098de3fdff1577d1008ba9dc7a1df8f68 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Sat, 24 Oct 2026 23:16:13 +1100 Subject: [PATCH] feat(archied): update agent-image sets the image new tasks run --- internal/app/archied/update.go | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/internal/app/archied/update.go b/internal/app/archied/update.go index a0160b67a..489ab2b76 100644 --- a/internal/app/archied/update.go +++ b/internal/app/archied/update.go @@ -35,11 +35,13 @@ const ( const updateUsage = `usage: archied update check [-channel stable|next|exact-pin] [-pin version] archied update install -version X [-config FILE] [-report FILE -channel C -chat ID -thread ID] - archied update watchdog [-config FILE] [-recover]` + archied update watchdog [-config FILE] [-recover] + archied update agent-image [-config FILE] REF` // RunUpdate serves `archied update`: check prints the release snapshot, // install verifies and stages a release and hands it to the watchdog, and // watchdog switches over, watches the daemon and commits or rolls back. +// agent-image points new tasks at an agent image built outside a release. func RunUpdate(args []string, out, stderr io.Writer) int { if len(args) == 0 { fmt.Fprintln(stderr, updateUsage) @@ -52,12 +54,42 @@ func RunUpdate(args []string, out, stderr io.Writer) int { return runUpdateInstall(args[1:], out, stderr) case "watchdog": return runUpdateWatchdog(args[1:], stderr) + case "agent-image": + return runUpdateAgentImage(args[1:], out, stderr) default: fmt.Fprintln(stderr, updateUsage) return 2 } } +// runUpdateAgentImage sets the image new tasks run. A release install pins +// its image by digest, so a locally loaded build is otherwise never used. +func runUpdateAgentImage(args []string, out, stderr io.Writer) int { + flags := flag.NewFlagSet("update agent-image", flag.ContinueOnError) + flags.SetOutput(stderr) + configPath := flags.String("config", configuration.DefaultConfigPath(), "bootstrap config file") + if err := flags.Parse(args); err != nil { + return 2 + } + if flags.NArg() != 1 { + fmt.Fprintln(stderr, updateUsage) + return 2 + } + ctx := context.Background() + policy := imagePolicy{configPath: *configPath} + current, err := policy.Image(ctx) + if err != nil { + fmt.Fprintln(stderr, err) + return 1 + } + if err := policy.SetImage(ctx, current, flags.Arg(0)); err != nil { + fmt.Fprintln(stderr, err) + return 1 + } + fmt.Fprintf(out, "agent image: %s -> %s\n", current, flags.Arg(0)) + return 0 +} + func runUpdateInstall(args []string, out, stderr io.Writer) int { flags := flag.NewFlagSet("update install", flag.ContinueOnError) flags.SetOutput(stderr)