Skip to content

Modern Docker Management, Designed for Everyone

refactor: bump go.getarcane.app/updater to v0.7.0 (#3387)

Kyle Mendella3a56d6a1a90
diff --git a/backend/api/handlers/system.go b/backend/api/handlers/system.go
index 6e3a1499f..b42064f1a 100644
--- a/backend/api/handlers/system.go
+++ b/backend/api/handlers/system.go
@@ -26,7 +26,7 @@ import (
"go.getarcane.app/docker/convert"
converttypes "go.getarcane.app/docker/convert/types"
"go.getarcane.app/sys/cgroup"
- updatertypes "go.getarcane.app/updater/types"
+ "go.getarcane.app/updater"
)
// SystemHandler handles system management endpoints.
@@ -504,7 +504,7 @@ func (h *SystemHandler) TriggerUpgrade(ctx context.Context, input *TriggerUpgrad
slog.Info("System upgrade triggered", "user", user.Username, "userId", user.ID)
- err = h.upgradeService.TriggerUpgradeViaCLI(ctx, *user, updatertypes.SelfUpdateTarget{})
+ err = h.upgradeService.TriggerUpgradeViaCLI(ctx, *user, updater.SelfUpdateTarget{})
if err != nil {
slog.Error("System upgrade failed", "error", err, "user", user.Username)
diff --git a/backend/cli/upgrade/logfile.go b/backend/cli/upgrade/logfile.go
new file mode 100644
index 000000000..888d4fdca
--- /dev/null
+++ b/backend/cli/upgrade/logfile.go
@@ -0,0 +1,185 @@
+package upgrade
+
+import (
+ "context"
+ "errors"
+ "fmt"
+ "io"
+ "log/slog"
+ "os"
+ "path/filepath"
+ "strconv"
+ "strings"
+ "sync"
+ "time"
+
+ "go.getarcane.app/sys/atomic"
+)
+
+const logFilePerm = 0o644
+
+// messageOnlyHandler renders a record as its message plus flattened attrs, with
+// none of the level/time/source framing a text handler adds. The upgrade log is
+// read by humans watching an upgrade, so it stays terse.
+type messageOnlyHandler struct {
+ mu *sync.Mutex
+ w io.Writer
+ minLevel slog.Level
+ attrs []slog.Attr
+ groups []string
+}
+
+// LogWriter accumulates the upgrade log in memory and rewrites the whole file
+// through atomic.WriteFile on every entry. The upgrade recreates the container
+// it is reporting on, so a run can be cut short at any point -- rewriting
+// atomically per entry means the file on disk is always a complete, untorn log
+// up to the last entry emitted, with no partial line ever visible to whoever
+// reads it afterwards.
+type LogWriter struct {
+ mu sync.Mutex
+ path string
+ buf []byte
+}
+
+func (w *LogWriter) Write(p []byte) (int, error) {
+ w.mu.Lock()
+ defer w.mu.Unlock()
+
+ w.buf = append(w.buf, p...)
+ if err := atomic.WriteFile(w.path, w.buf, logFilePerm); err != nil {
+ return 0, err
+ }
+ return len(p), nil
+}
+
+// Name reports the path of the log file.
+func (w *LogWriter) Name() string { return w.path }
+
+// SetupMessageOnlyLogFile writes normal slog output to stdout and message-only
+// output to a timestamped file under dataDir. Every entry is persisted as it is
+// logged, so the returned writer needs no closing -- it is returned so the
+// caller can report where the log landed.
+func SetupMessageOnlyLogFile(dataDir string, filePrefix string, minLevel slog.Level) (*LogWriter, error) {
+ if strings.TrimSpace(dataDir) == "" {
+ return nil, errors.New("dataDir is required")
+ }
+ if strings.TrimSpace(filePrefix) == "" {
+ filePrefix = "arcane-upgrade"
+ }
+ if err := os.MkdirAll(dataDir, 0o755); err != nil {
+ return nil, fmt.Errorf("create data directory: %w", err)
+ }
+
+ logFile := &LogWriter{path: filepath.Join(dataDir, fmt.Sprintf("%s-%d.log", filePrefix, time.Now().Unix()))}
+ if err := atomic.WriteFile(logFile.path, nil, logFilePerm); err != nil {
+ return nil, fmt.Errorf("create log file: %w", err)
+ }
+
+ stdoutHandler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: minLevel, AddSource: true})
+ fileHandler := newMessageOnlyHandler(logFile, minLevel)
+ slog.SetDefault(slog.New(slog.NewMultiHandler(stdoutHandler, fileHandler)))
+ return logFile, nil
+}
+
+func newMessageOnlyHandler(w io.Writer, minLevel slog.Level) *messageOnlyHandler {
+ return &messageOnlyHandler{mu: &sync.Mutex{}, w: w, minLevel: minLevel}
+}
+
+func (h *messageOnlyHandler) Enabled(_ context.Context, level slog.Level) bool {
+ return level >= h.minLevel
+}
+
+func (h *messageOnlyHandler) Handle(_ context.Context, r slog.Record) error {
+ if h.mu != nil {
+ h.mu.Lock()
+ defer h.mu.Unlock()
+ }
+
+ line := r.Message
+ appendAttr := func(a slog.Attr) {
+ if a.Equal(slog.Attr{}) {
+ return
+ }
+ key := a.Key
+ if len(h.groups) > 0 {
+ key = strings.Join(h.groups, ".") + "." + key
+ }
+ line += " " + key + "=" + formatSlogValue(a.Value)
+ }
+
+ for _, a := range h.attrs {
+ appendAttr(a)
+ }
+ r.Attrs(func(a slog.Attr) bool {
+ if a.Value.Kind() == slog.KindGroup {
+ prev := h.groups
+ if a.Key != "" {
+ h.groups = append(h.groups, a.Key)
+ }
+ for _, grouped := range a.Value.Group() {
+ appendAttr(grouped)
+ }
+ h.groups = prev
+ return true
+ }
+ appendAttr(a)
+ return true
+ })
+
+ _, err := fmt.Fprintln(h.w, strings.TrimSpace(line))
+ return err
+}
+
+func (h *messageOnlyHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
+ return &messageOnlyHandler{
+ mu: h.mu,
+ w: h.w,
+ minLevel: h.minLevel,
+ attrs: append(append([]slog.Attr{}, h.attrs...), attrs...),
+ groups: append([]string{}, h.groups...),
+ }
+}
+
+func (h *messageOnlyHandler) WithGroup(name string) slog.Handler {
+ groups := append([]string{}, h.groups...)
+ if strings.TrimSpace(name) != "" {
+ groups = append(groups, name)
+ }
+ return &messageOnlyHandler{
+ mu: h.mu,
+ w: h.w,
+ minLevel: h.minLevel,
+ attrs: append([]slog.Attr{}, h.attrs...),
+ groups: groups,
+ }
+}
+
+func formatSlogValue(v slog.Value) string {
+ switch v.Kind() {
+ case slog.KindAny:
+ return strconv.Quote(fmt.Sprint(v.Any()))
+ case slog.KindString:
+ return strconv.Quote(v.String())
+ case slog.KindInt64:
+ return strconv.FormatInt(v.Int64(), 10)
+ case slog.KindUint64:
+ return strconv.FormatUint(v.Uint64(), 10)
+ case slog.KindFloat64:
+ return strconv.FormatFloat(v.Float64(), 'f', -1, 64)
+ case slog.KindTime:
+ return strconv.Quote(v.Time().Format(time.RFC3339Nano))
+ case slog.KindDuration:
+ return strconv.Quote(v.Duration().String())
+ case slog.KindBool:
+ if v.Bool() {
+ return "true"
+ }
+ return "false"
+ case slog.KindGroup:
+ return strconv.Quote(fmt.Sprint(v.Group()))
+ case slog.KindLogValuer:
+ return formatSlogValue(v.Resolve())
+ default:
+ return strconv.Quote(fmt.Sprint(v.Any()))
+ }
+}
diff --git a/backend/cli/upgrade/logfile_test.go b/backend/cli/upgrade/logfile_test.go
new file mode 100644
index 000000000..9c98a7cd2
--- /dev/null
+++ b/backend/cli/upgrade/logfile_test.go
@@ -0,0 +1,33 @@
+package upgrade
+
+import (
+ "log/slog"
+ "os"
+ "strings"
+ "testing"
+)
+
+func TestSetupMessageOnlyLogFile(t *testing.T) {
+ previousLogger := slog.Default()
+ t.Cleanup(func() {
+ slog.SetDefault(previousLogger)
+ })
+
+ logFile, err := SetupMessageOnlyLogFile(t.TempDir(), "upgrade-test", slog.LevelInfo)
+ if err != nil {
+ t.Fatalf("SetupMessageOnlyLogFile() error = %v", err)
+ }
+
+ // Each entry is written atomically as it is logged, so the file is readable
+ // in full without any flush or close.
+ slog.Info("container updated", "container", "web")
+
+ content, err := os.ReadFile(logFile.Name())
+ if err != nil {
+ t.Fatalf("read log file: %v", err)
+ }
+ got := string(content)
+ if !strings.Contains(got, "container updated") || !strings.Contains(got, `container="web"`) {
+ t.Fatalf("log file content = %q, want message-only entry with attrs", got)
+ }
+}
diff --git a/backend/cli/upgrade/upgrade.go b/backend/cli/upgrade/upgrade.go
index 7d88c71c1..641a0f180 100644
--- a/backend/cli/upgrade/upgrade.go
+++ b/backend/cli/upgrade/upgrade.go
@@ -19,8 +19,7 @@ import (
docker "github.com/getarcaneapp/arcane/backend/v2/pkg/dockerutil"
"github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane"
"go.getarcane.app/sys/cgroup"
- updaterlabels "go.getarcane.app/updater/pkg/labels"
- updaterlogs "go.getarcane.app/updater/pkg/logs"
+ "go.getarcane.app/updater/labels"
)
var (
@@ -60,16 +59,11 @@ func runUpgrade(cmd *cobra.Command, args []string) error {
// This prevents interruption when stopping the target container
ctx := context.Background()
- logFile, err := updaterlogs.SetupMessageOnlyLogFile("/app/data", "arcane-upgrade", slog.LevelInfo)
+ logFile, err := SetupMessageOnlyLogFile("/app/data", "arcane-upgrade", slog.LevelInfo)
if err != nil {
slog.Warn("Failed to setup file logging", "error", err)
- } else if logFile != nil {
- defer func() {
- if err := logFile.Close(); err != nil {
- slog.Warn("Failed to close upgrade log file", "error", err)
- }
- }()
- slog.Info("Upgrade log file created")
+ } else {
+ slog.Info("Upgrade log file created", "path", logFile.Name())
}
// Connect to Docker
@@ -152,20 +146,20 @@ func findArcaneContainer(ctx context.Context, dockerClient *client.Client) (cont
continue
}
- labels := map[string]string{}
+ containerLabels := map[string]string{}
if inspect.Config != nil && inspect.Config.Labels != nil {
- labels = inspect.Config.Labels
+ containerLabels = inspect.Config.Labels
}
// New label: com.getarcaneapp.arcane=true
- if updaterlabels.IsArcaneContainer(labels) {
+ if labels.IsArcaneContainer(containerLabels) {
slog.Info("Found Arcane container by label", "id", c.ID[:12], "image", c.Image, "names", c.Names)
return inspect, nil
}
// Legacy label (pre-migration): com.getarcaneapp.arcane.server=true
// NOTE: older agent images also used this label, so we must additionally exclude AGENT_MODE=true.
- if isLegacyServerLabel(labels) {
+ if isLegacyServerLabel(containerLabels) {
slog.Info("Found Arcane container by legacy label", "id", c.ID[:12], "image", c.Image, "names", c.Names)
return inspect, nil
}
@@ -180,29 +174,29 @@ func findArcaneContainer(ctx context.Context, dockerClient *client.Client) (cont
return container.InspectResponse{}, errors.New("no running Arcane container found")
}
-func isLegacyServerLabel(labels map[string]string) bool {
- if labels == nil {
+func isLegacyServerLabel(containerLabels map[string]string) bool {
+ if containerLabels == nil {
return false
}
- for k, v := range labels {
- if strings.EqualFold(k, updaterlabels.LabelArcaneLegacyServer) {
+ for k, v := range containerLabels {
+ if strings.EqualFold(k, labels.LabelArcaneLegacyServer) {
return strings.EqualFold(strings.TrimSpace(v), "true")
}
}
return false
}
-func normalizeRecreatedArcaneLabelsInternal(labels map[string]string) map[string]string {
- normalized := maps.Clone(labels)
+func normalizeRecreatedArcaneLabelsInternal(containerLabels map[string]string) map[string]string {
+ normalized := maps.Clone(containerLabels)
if normalized == nil {
return nil
}
- if updaterlabels.IsArcaneContainer(labels) || isLegacyServerLabel(labels) {
- normalized[updaterlabels.LabelArcane] = "true"
+ if labels.IsArcaneContainer(containerLabels) || isLegacyServerLabel(containerLabels) {
+ normalized[labels.LabelArcane] = "true"
}
- if updaterlabels.IsArcaneAgentContainer(labels) {
- normalized[updaterlabels.LabelArcaneAgent] = "true"
- normalized[updaterlabels.LabelArcane] = "true"
+ if labels.IsArcaneAgentContainer(containerLabels) {
+ normalized[labels.LabelArcaneAgent] = "true"
+ normalized[labels.LabelArcane] = "true"
}
return normalized
}
diff --git a/backend/cli/upgrade/upgrade_test.go b/backend/cli/upgrade/upgrade_test.go
index ff14471fa..d47c630a5 100644
--- a/backend/cli/upgrade/upgrade_test.go
+++ b/backend/cli/upgrade/upgrade_test.go
@@ -4,7 +4,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
- updaterlabels "go.getarcane.app/updater/pkg/labels"
+ "go.getarcane.app/updater/labels"
)
func TestNormalizeRecreatedArcaneLabelsInternal(t *testing.T) {
@@ -17,33 +17,33 @@ func TestNormalizeRecreatedArcaneLabelsInternal(t *testing.T) {
{
name: "legacy server gains current Arcane label",
labels: map[string]string{
- updaterlabels.LabelArcaneLegacyServer: "true",
- updaterlabels.LabelUpdater: "false",
- "com.example.unrelated": "keep",
+ labels.LabelArcaneLegacyServer: "true",
+ labels.LabelUpdater: "false",
+ "com.example.unrelated": "keep",
},
want: map[string]string{
- updaterlabels.LabelArcaneLegacyServer: "true",
- updaterlabels.LabelArcane: "true",
- updaterlabels.LabelUpdater: "false",
- "com.example.unrelated": "keep",
+ labels.LabelArcaneLegacyServer: "true",
+ labels.LabelArcane: "true",
+ labels.LabelUpdater: "false",
+ "com.example.unrelated": "keep",
},
wantSource: map[string]string{
- updaterlabels.LabelArcaneLegacyServer: "true",
- updaterlabels.LabelUpdater: "false",
- "com.example.unrelated": "keep",
+ labels.LabelArcaneLegacyServer: "true",
+ labels.LabelUpdater: "false",
+ "com.example.unrelated": "keep",
},
},
{
name: "agent gains current Arcane label",
labels: map[string]string{
- updaterlabels.LabelArcaneAgent: "true",
+ labels.LabelArcaneAgent: "true",
},
want: map[string]string{
- updaterlabels.LabelArcane: "true",
- updaterlabels.LabelArcaneAgent: "true",
+ labels.LabelArcane: "true",
+ labels.LabelArcaneAgent: "true",
},
wantSource: map[string]string{
- updaterlabels.LabelArcaneAgent: "true",
+ labels.LabelArcaneAgent: "true",
},
},
{
diff --git a/backend/go.mod b/backend/go.mod
index 3439f8462..8cadff02a 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -60,7 +60,7 @@ require (
go.getarcane.app/sys/atomic v0.1.0
go.getarcane.app/sys/cgroup v0.1.1
go.getarcane.app/sys/crypto v0.1.0
- go.getarcane.app/updater v0.6.1
+ go.getarcane.app/updater v0.7.0
go.uber.org/fx v1.24.0
go.yaml.in/yaml/v4 v4.0.0-rc.6
golang.org/x/crypto v0.54.0
@@ -128,7 +128,7 @@ require (
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.9.0 // indirect
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
- github.com/go-logr/logr v1.4.3 // indirect
+ github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
@@ -184,10 +184,10 @@ require (
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
- github.com/prometheus/client_golang v1.23.2 // indirect
+ github.com/prometheus/client_golang v1.24.1 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
- github.com/prometheus/common v0.67.5 // indirect
- github.com/prometheus/procfs v0.20.1 // indirect
+ github.com/prometheus/common v0.70.1 // indirect
+ github.com/prometheus/procfs v0.21.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/samber/go-singleflightx v0.3.2 // indirect
github.com/samber/lo v1.53.0 // indirect
@@ -234,7 +234,6 @@ require (
go.uber.org/dig v1.19.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
- go.yaml.in/yaml/v2 v2.4.4 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/term v0.45.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect
diff --git a/backend/go.sum b/backend/go.sum
index ad7d69ab2..b73998342 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -193,8 +193,8 @@ github.com/go-git/go-git/v5 v5.19.1/go.mod h1:Pb1v0c7/g8aGQJwx9Us09W85yGoyvSwuhE
github.com/go-jose/go-jose/v4 v4.1.4 h1:moDMcTHmvE6Groj34emNPLs/qtYXRVcd6S7NHbHz3kA=
github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
-github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
-github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
+github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
+github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
@@ -426,14 +426,14 @@ github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 h1:o4JXh1EVt
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/pressly/goose/v3 v3.27.2 h1:FjKNzcmMdGrQlSIu5alMSmakQtJFBgtw+A0bb1p/LC8=
github.com/pressly/goose/v3 v3.27.2/go.mod h1:qWW+/8dkVtJYjJrbIpwD5xxnEJTUKvxkQ9JKQp9LaIM=
-github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
-github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
+github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU=
+github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
-github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4=
-github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw=
-github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc=
-github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo=
+github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY=
+github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc=
+github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
+github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
@@ -559,8 +559,8 @@ go.getarcane.app/sys/cgroup v0.1.1 h1:c39W8FDqMXlKOZrpH+itaY+t8oC0tva0+6ztTrKvVI
go.getarcane.app/sys/cgroup v0.1.1/go.mod h1:2dUDhWV8qe9LRnLIqa5VQDhdWbTQ04EepttdIAe9dcM=
go.getarcane.app/sys/crypto v0.1.0 h1:HDQ2CKHkm+wZe5xb/qR7MzW5fKi0Wq8Jcyr7qDVgRWg=
go.getarcane.app/sys/crypto v0.1.0/go.mod h1:YtoRB0TENwfdNl0ZUTWkeas/8rT7NhCbI8ENsZzCCdU=
-go.getarcane.app/updater v0.6.1 h1:kcRYGwLV+lbkpz6zCdDKM7PgvHnsKBAcyURNmAO4fI4=
-go.getarcane.app/updater v0.6.1/go.mod h1:AVEBD3dbm+p8FOkkXGH7yDe2bHMadkYmLo5e9ajHnzI=
+go.getarcane.app/updater v0.7.0 h1:Rd6qJGtdJrMJ8SxfGpuP1+ZpJ604BNnhYb9UsB6O0Mg=
+go.getarcane.app/updater v0.7.0/go.mod h1:6b8zVFJEUMhLzDOi4jwKBA/GmbVgguv0FeGOoO67JW8=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/auto/sdk v1.2.1 h1:jXsnJ4Lmnqd11kwkBV2LgLoFMZKizbCi5fNZ/ipaZ64=
diff --git a/backend/internal/di/providers.go b/backend/internal/di/providers.go
index 9ce51511c..bd8c28026 100644
--- a/backend/internal/di/providers.go
+++ b/backend/internal/di/providers.go
@@ -70,7 +70,7 @@ func provideProjectServiceInternal(db *database.DB, settings *services.SettingsS
WithRegistryCredentialsProvider(environment.GetEnabledRegistryCredentials)
}
-func provideUpdaterServiceInternal(db *database.DB, settings *services.SettingsService, docker *services.DockerClientService, project *services.ProjectService, imageUpdate *services.ImageUpdateService, registry *services.ContainerRegistryService, event *services.EventService, image *services.ImageService, notification *services.NotificationService, systemUpgrade *services.SystemUpgradeService, activity *services.ActivityService) *services.UpdaterService {
+func provideUpdaterServiceInternal(db *database.DB, settings *services.SettingsService, docker *services.DockerClientService, project *services.ProjectService, imageUpdate *services.ImageUpdateService, registry *services.ContainerRegistryService, event *services.EventService, image *services.ImageService, notification *services.NotificationService, systemUpgrade *services.SystemUpgradeService, activity *services.ActivityService) (*services.UpdaterService, error) {
return services.NewUpdaterService(db, settings, docker, project, imageUpdate, registry, event, image, notification, systemUpgrade, activity)
}
diff --git a/backend/internal/services/container_registry_service.go b/backend/internal/services/container_registry_service.go
index 059c28d4d..6807c4dce 100644
--- a/backend/internal/services/container_registry_service.go
+++ b/backend/internal/services/container_registry_service.go
@@ -28,9 +28,9 @@ import (
dockerregistry "github.com/moby/moby/api/types/registry"
"github.com/moby/moby/client"
"go.getarcane.app/sys/crypto"
- updaterdigest "go.getarcane.app/updater/pkg/digest"
- updaterrefs "go.getarcane.app/updater/pkg/refs"
- updaterregistry "go.getarcane.app/updater/pkg/registry"
+ "go.getarcane.app/updater/digest"
+ "go.getarcane.app/updater/refs"
+ "go.getarcane.app/updater/registry"
)
const (
@@ -65,8 +65,8 @@ type resolvedRegistryCredential struct {
}
type registryRateLimitCacheEntryInternal struct {
- RateLimit updaterregistry.RateLimitInfo `json:"rateLimit"`
- CheckedAt time.Time `json:"checkedAt"`
+ RateLimit registry.RateLimitInfo `json:"rateLimit"`
+ CheckedAt time.Time `json:"checkedAt"`
}
type rateLimitRoundTripFuncInternal func(*http.Request) (*http.Response, error)
@@ -90,7 +90,7 @@ func NewContainerRegistryService(db *database.DB, dockerClient registryDaemonGet
service := &ContainerRegistryService{
db: db,
dockerClient: dockerClient,
- distributionHTTPClient: updaterregistry.NewRegistryHTTPClient(),
+ distributionHTTPClient: registry.NewHTTPClient(),
kvService: kvService,
}
backgroundLoader := func(imageRefs []string) (map[string]string, error) {
@@ -549,7 +549,7 @@ func (s *ContainerRegistryService) buildRegistryPullUsageInternal(ctx context.Co
return usage
}
-func ensureRateLimitUsedInternal(rateLimit *updaterregistry.RateLimitInfo) {
+func ensureRateLimitUsedInternal(rateLimit *registry.RateLimitInfo) {
if rateLimit == nil || rateLimit.Used != nil || rateLimit.Limit == nil || rateLimit.Remaining == nil {
return
}
@@ -570,7 +570,7 @@ func (s *ContainerRegistryService) getObservedPullsInternal(ctx context.Context,
return value
}
-func (s *ContainerRegistryService) dockerHubCredentialForRegistryInternal(reg models.ContainerRegistry) (*updaterregistry.Credentials, string, string, error) {
+func (s *ContainerRegistryService) dockerHubCredentialForRegistryInternal(reg models.ContainerRegistry) (*registry.Credentials, string, string, error) {
if reg.RegistryType != registryTypeGeneric {
return nil, "anonymous", "", nil
}
@@ -590,14 +590,14 @@ func (s *ContainerRegistryService) dockerHubCredentialForRegistryInternal(reg mo
return nil, "anonymous", "", nil
}
- return &updaterregistry.Credentials{
+ return &registry.Credentials{
Username: username,
Token: token,
}, "credential", username, nil
}
-func (s *ContainerRegistryService) fetchDockerHubRateLimitInternal(ctx context.Context, credential *updaterregistry.Credentials) (*updaterregistry.RateLimitInfo, error) {
- return updaterregistry.FetchRegistryRateLimit(ctx, "docker.io", dockerHubRateLimitRepository, dockerHubRateLimitTag, credential, dockerHubRateLimitHTTPClientInternal(s.distributionHTTPClient))
+func (s *ContainerRegistryService) fetchDockerHubRateLimitInternal(ctx context.Context, credential *registry.Credentials) (*registry.RateLimitInfo, error) {
+ return registry.FetchRegistryRateLimit(ctx, "docker.io", dockerHubRateLimitRepository, dockerHubRateLimitTag, credential, dockerHubRateLimitHTTPClientInternal(s.distributionHTTPClient))
}
func dockerHubRateLimitHTTPClientInternal(httpClient *http.Client) *http.Client {
@@ -625,7 +625,7 @@ func dockerHubRateLimitHTTPClientInternal(httpClient *http.Client) *http.Client
return &cloned
}
-func (s *ContainerRegistryService) getCachedRateLimitInternal(ctx context.Context, registryID string) (*updaterregistry.RateLimitInfo, time.Time, bool) {
+func (s *ContainerRegistryService) getCachedRateLimitInternal(ctx context.Context, registryID string) (*registry.RateLimitInfo, time.Time, bool) {
if s.kvService == nil || registryID == "" {
return nil, time.Time{}, false
}
@@ -651,7 +651,7 @@ func (s *ContainerRegistryService) getCachedRateLimitInternal(ctx context.Contex
return &entry.RateLimit, entry.CheckedAt, true
}
-func (s *ContainerRegistryService) setCachedRateLimitInternal(ctx context.Context, registryID string, rateLimit *updaterregistry.RateLimitInfo, checkedAt time.Time) {
+func (s *ContainerRegistryService) setCachedRateLimitInternal(ctx context.Context, registryID string, rateLimit *registry.RateLimitInfo, checkedAt time.Time) {
if s.kvService == nil || registryID == "" || rateLimit == nil {
return
}
@@ -763,9 +763,9 @@ func (s *ContainerRegistryService) TestECRRegistry(ctx context.Context, reg *mod
return nil
}
-// GetImageDigest fetches the current digest for an image:tag from the registry
+// ImageDigest fetches the current digest for an image:tag from the registry
// This is used for digest-based update detection for non-semver tags
-func (s *ContainerRegistryService) GetImageDigest(ctx context.Context, imageRef string) (string, error) {
+func (s *ContainerRegistryService) ImageDigest(ctx context.Context, imageRef string) (string, error) {
normalizedRef, _, err := normalizeImageReferenceForDistributionInternal(imageRef)
if err != nil {
return "", err
@@ -791,7 +791,7 @@ func (s *ContainerRegistryService) GetImageDigest(ctx context.Context, imageRef
}
func (s *ContainerRegistryService) inspectImageDigestInternal(ctx context.Context, imageRef string, externalCreds []containerregistry.Credential) (*registryDigestResult, error) {
- parts, err := updaterrefs.NormalizeReference(imageRef)
+ parts, err := refs.NormalizeReference(imageRef)
if err != nil {
return nil, err
}
@@ -880,7 +880,7 @@ func (s *ContainerRegistryService) inspectImageDigestViaDaemonInternal(ctx conte
inspectResult, err := dockerClient.DistributionInspect(ctx, normalizedRef, client.DistributionInspectOptions{})
if err == nil {
- digest, normalizeErr := updaterdigest.Normalize(inspectResult.Descriptor.Digest.String())
+ digest, normalizeErr := digest.Normalize(inspectResult.Descriptor.Digest.String())
if normalizeErr != nil {
return nil, errors.WrapIff(normalizeErr, "distribution inspect returned invalid digest for %s", normalizedRef)
}
@@ -918,7 +918,7 @@ func (s *ContainerRegistryService) inspectImageDigestWithCredentialsInternal(ctx
EncodedRegistryAuth: authHeader,
})
if err == nil {
- digest, normalizeErr := updaterdigest.Normalize(inspectResult.Descriptor.Digest.String())
+ digest, normalizeErr := digest.Normalize(inspectResult.Descriptor.Digest.String())
if normalizeErr != nil {
return nil, errors.WrapIff(normalizeErr, "distribution inspect returned invalid digest for %s", normalizedRef)
}
@@ -1284,7 +1284,7 @@ func (s *ContainerRegistryService) deleteUnsyncedInternal(ctx context.Context, e
}
func normalizeImageReferenceForDistributionInternal(imageRef string) (string, string, error) {
- parts, err := updaterrefs.NormalizeReference(imageRef)
+ parts, err := refs.NormalizeReference(imageRef)
if err != nil {
return "", "", err
}
@@ -1374,7 +1374,7 @@ func isDistributionFallbackEligibleInternal(err error) bool {
return false
}
- if updaterregistry.IsFallbackEligibleDaemonError(err) {
+ if registry.IsFallbackEligibleDaemonError(err) {
return true
}
@@ -1389,15 +1389,15 @@ func isDistributionFallbackEligibleInternal(err error) bool {
}
func (s *ContainerRegistryService) fetchDigestFromRegistryInternal(ctx context.Context, registryHost, repository, tag string, credential *resolvedRegistryCredential) (string, error) {
- var distributionCredential *updaterregistry.Credentials
+ var distributionCredential *registry.Credentials
if credential != nil {
- distributionCredential = &updaterregistry.Credentials{
+ distributionCredential = &registry.Credentials{
Username: strings.TrimSpace(credential.Username),
Token: strings.TrimSpace(credential.Token),
}
}
- return updaterregistry.FetchDigest(
+ return registry.FetchDigest(
ctx,
registryHost,
repository,
diff --git a/backend/internal/services/container_registry_service_test.go b/backend/internal/services/container_registry_service_test.go
index f0ee60264..18f828055 100644
--- a/backend/internal/services/container_registry_service_test.go
+++ b/backend/internal/services/container_registry_service_test.go
@@ -677,7 +677,7 @@ func TestContainerRegistryService_GetImageDigest_HonorsCallerCancellation(t *tes
defer cancel()
result := make(chan error, 1)
go func() {
- _, err := svc.GetImageDigest(ctx, "registry.example.com/team/app:latest")
+ _, err := svc.ImageDigest(ctx, "registry.example.com/team/app:latest")
result <- err
}()
diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.go
index 5f3ec99b0..75158a094 100644
--- a/backend/internal/services/container_service.go
+++ b/backend/internal/services/container_service.go
@@ -35,7 +35,7 @@ import (
"go.getarcane.app/streams/bus"
containerstats "go.getarcane.app/streams/stats"
"go.getarcane.app/sys/cgroup"
- libupdater "go.getarcane.app/updater/pkg/labels"
+ "go.getarcane.app/updater/labels"
)
type ContainerService struct {
@@ -590,7 +590,7 @@ func (s *ContainerService) RedeployContainer(ctx context.Context, containerID st
apiVersion := libarcane.DetectDockerAPIVersion(ctx, dockerClient)
currentContainerID, currentContainerErr := cgroup.CurrentContainerID()
- if libupdater.ShouldDisableArcaneServerRedeploy(containerInfo.Config.Labels, containerInfo.ID, currentContainerID, currentContainerErr) {
+ if labels.ShouldDisableArcaneServerRedeploy(containerInfo.Config.Labels, containerInfo.ID, currentContainerID, currentContainerErr) {
err = errors.New("arcane cannot redeploy itself; use the system upgrade flow (Settings -> Updates) instead")
s.eventService.LogErrorEvent(ctx, models.EventTypeContainerError, "container", containerID, containerName, user.ID, user.Username, "0", err, models.JSON{
"action": "redeploy",
@@ -723,7 +723,7 @@ func (s *ContainerService) GetContainerDetails(ctx context.Context, id string) (
details := containertypes.NewDetails(containerInspect)
currentContainerID, currentContainerErr := cgroup.CurrentContainerID()
- details.RedeployDisabled = libupdater.ShouldDisableArcaneServerRedeploy(details.Labels, details.ID, currentContainerID, currentContainerErr)
+ details.RedeployDisabled = labels.ShouldDisableArcaneServerRedeploy(details.Labels, details.ID, currentContainerID, currentContainerErr)
s.applyContainerDetailsIconInternal(ctx, &details)
return details, nil
@@ -1209,7 +1209,7 @@ func (s *ContainerService) buildContainerSummaries(containers []container.Summar
if info, exists := updateInfoMap[dc.ImageID]; exists {
summary.UpdateInfo = info
}
- summary.RedeployDisabled = libupdater.ShouldDisableArcaneServerRedeploy(summary.Labels, summary.ID, currentContainerID, currentContainerErr)
+ summary.RedeployDisabled = labels.ShouldDisableArcaneServerRedeploy(summary.Labels, summary.ID, currentContainerID, currentContainerErr)
items = append(items, summary)
}
return items
diff --git a/backend/internal/services/dashboard_service.go b/backend/internal/services/dashboard_service.go
index 1c0c98158..9620ac628 100644
--- a/backend/internal/services/dashboard_service.go
+++ b/backend/internal/services/dashboard_service.go
@@ -20,7 +20,7 @@ import (
versiontypes "github.com/getarcaneapp/arcane/types/v2/version"
volumetypes "github.com/getarcaneapp/arcane/types/v2/volume"
"go.getarcane.app/sys/cgroup"
- libupdater "go.getarcane.app/updater/pkg/labels"
+ "go.getarcane.app/updater/labels"
)
const defaultDashboardAPIKeyExpiryWindow = 14 * 24 * time.Hour
@@ -90,7 +90,7 @@ func (s *DashboardService) GetSnapshot(ctx context.Context, options DashboardAct
} else {
for _, container := range filteredContainers {
summary := containertypes.NewSummary(container)
- summary.RedeployDisabled = libupdater.ShouldDisableArcaneServerRedeploy(summary.Labels, summary.ID, currentContainerID, currentContainerErr)
+ summary.RedeployDisabled = labels.ShouldDisableArcaneServerRedeploy(summary.Labels, summary.ID, currentContainerID, currentContainerErr)
containerItems = append(containerItems, summary)
}
}
diff --git a/backend/internal/services/image_update_service.go b/backend/internal/services/image_update_service.go
index 4fbdb5dae..f5901e5d2 100644
--- a/backend/internal/services/image_update_service.go
+++ b/backend/internal/services/image_update_service.go
@@ -27,8 +27,8 @@ import (
"github.com/moby/moby/client"
"github.com/samber/mo"
"go.getarcane.app/sys/crypto"
- updaterdigest "go.getarcane.app/updater/pkg/digest"
- updaterrefs "go.getarcane.app/updater/pkg/refs"
+ "go.getarcane.app/updater/digest"
+ "go.getarcane.app/updater/refs"
"golang.org/x/sync/errgroup"
"gorm.io/gorm"
)
@@ -101,9 +101,9 @@ func (s *ImageUpdateService) dockerClientInternal(ctx context.Context) (*client.
}
func (s *ImageUpdateService) composeBuildImageRefsInternal(ctx context.Context) (map[string]struct{}, error) {
- refs := make(map[string]struct{})
+ buildRefs := make(map[string]struct{})
if s == nil || s.db == nil {
- return refs, nil
+ return buildRefs, nil
}
var projectRows []models.Project
@@ -119,14 +119,14 @@ func (s *ImageUpdateService) composeBuildImageRefsInternal(ctx context.Context)
continue
}
for _, imageRef := range projectspkg.ParseImageRefsJSON(*projectRows[i].BuildImageRefsJSON) {
- normalized := updaterrefs.NormalizeImageUpdateRef(imageRef)
+ normalized := refs.NormalizeImageUpdateRef(imageRef)
if normalized != "" {
- refs[normalized] = struct{}{}
+ buildRefs[normalized] = struct{}{}
}
}
}
- return refs, nil
+ return buildRefs, nil
}
func (s *ImageUpdateService) startImageUpdateActivityInternal(ctx context.Context, resourceName string, count int) string {
@@ -348,7 +348,7 @@ func (s *ImageUpdateService) resolveNotifiedImageIDInternal(ctx context.Context,
func digestPinnedImageUpdateResultInternal(imageRef string) mo.Option[*imageupdate.Response] {
imageRef = strings.TrimSpace(imageRef)
- pinnedDigest, ok := updaterdigest.FromReferenceSuffix(imageRef)
+ pinnedDigest, ok := digest.FromReferenceSuffix(imageRef)
if !ok {
return mo.None[*imageupdate.Response]()
}
@@ -486,7 +486,7 @@ func (s *ImageUpdateService) parseImageReference(imageRef string) *ImageParts {
// Fallback parser for cases where the official parser fails
func (s *ImageUpdateService) parseImageReferenceFallback(imageRef string) *ImageParts {
var registryHost, repository, tag string
- if _, ok := updaterdigest.FromReferenceSuffix(imageRef); ok {
+ if _, ok := digest.FromReferenceSuffix(imageRef); ok {
digestParts := strings.Split(imageRef, "@")
if len(digestParts) != 2 {
return nil
@@ -665,7 +665,7 @@ func (s *ImageUpdateService) inspectLocalImageSnapshotInternal(ctx context.Conte
// Extract all digests from RepoDigests
if len(inspectResponse.RepoDigests) > 0 {
for _, repoDigest := range inspectResponse.RepoDigests {
- digest, ok := updaterdigest.FromReferenceSuffix(repoDigest)
+ digest, ok := digest.FromReferenceSuffix(repoDigest)
if !ok {
continue
}
@@ -685,7 +685,7 @@ func (s *ImageUpdateService) inspectLocalImageSnapshotInternal(ctx context.Conte
primaryDigest = inspectResponse.ID
allDigests = []string{primaryDigest}
}
- if normalizedRef := updaterrefs.NormalizeImageUpdateRef(imageRef); normalizedRef != "" {
+ if normalizedRef := refs.NormalizeImageUpdateRef(imageRef); normalizedRef != "" {
_, isComposeBuild := composeBuildRefs[normalizedRef]
isLocalBuild = isLocalBuild || isComposeBuild
}
@@ -1332,7 +1332,7 @@ func (s *ImageUpdateService) recordInitialBatchResultsInternal(ctx context.Conte
if strings.TrimSpace(result.Error) != "" {
continue
}
- if _, ok := updaterdigest.FromReferenceSuffix(imageRef); !ok {
+ if _, ok := digest.FromReferenceSuffix(imageRef); !ok {
continue
}
diff --git a/backend/internal/services/project_service.go b/backend/internal/services/project_service.go
index 75ea7a51a..bf037c445 100644
--- a/backend/internal/services/project_service.go
+++ b/backend/internal/services/project_service.go
@@ -47,7 +47,7 @@ import (
"github.com/samber/mo"
buildtypes "go.getarcane.app/builds/types"
"go.getarcane.app/sys/cgroup"
- libupdater "go.getarcane.app/updater/pkg/labels"
+ "go.getarcane.app/updater/labels"
"gorm.io/gorm"
)
@@ -911,7 +911,7 @@ func (s *ProjectService) GetProjectServices(ctx context.Context, projectID strin
IconDarkURL: resolvedIcon.IconDarkURL,
ServiceConfig: svcConfig,
Labels: c.Labels,
- RedeployDisabled: libupdater.ShouldDisableArcaneServerRedeploy(c.Labels, c.ID, currentContainerID, currentContainerErr),
+ RedeployDisabled: labels.ShouldDisableArcaneServerRedeploy(c.Labels, c.ID, currentContainerID, currentContainerErr),
})
have[c.Service] = true
}
@@ -2347,7 +2347,7 @@ func (s *ProjectService) projectRedeployDisabledInternal(ctx context.Context, pr
currentContainerID, currentContainerErr := cgroup.CurrentContainerID()
for _, container := range lookupProjectContainers(proj, containersByProject) {
- if libupdater.ShouldDisableArcaneServerRedeploy(container.Labels, container.ID, currentContainerID, currentContainerErr) {
+ if labels.ShouldDisableArcaneServerRedeploy(container.Labels, container.ID, currentContainerID, currentContainerErr) {
return true
}
}
@@ -4711,7 +4711,7 @@ func (s *ProjectService) mapProjectToDto(ctx context.Context, projectsDir string
containerName := dockerutil.ContainerNameFromNames(c.Names)
- redeployDisabled := libupdater.ShouldDisableArcaneServerRedeploy(c.Labels, c.ID, currentContainerID, currentContainerErr)
+ redeployDisabled := labels.ShouldDisableArcaneServerRedeploy(c.Labels, c.ID, currentContainerID, currentContainerErr)
if redeployDisabled {
resp.RedeployDisabled = true
}
diff --git a/backend/internal/services/project_service_test.go b/backend/internal/services/project_service_test.go
index 96283b1f2..77d5c389e 100644
--- a/backend/internal/services/project_service_test.go
+++ b/backend/internal/services/project_service_test.go
@@ -39,7 +39,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
buildtypes "go.getarcane.app/builds/types"
- libupdater "go.getarcane.app/updater/pkg/labels"
+ "go.getarcane.app/updater/labels"
"gorm.io/gorm"
"github.com/getarcaneapp/arcane/backend/v2/internal/database"
@@ -4232,7 +4232,7 @@ func TestProjectService_MapProjectToDto_SetsRedeployDisabledFromRuntimeServices(
labels: map[string]string{
"com.docker.compose.project": "arcane",
"com.docker.compose.service": "server",
- libupdater.LabelArcane: "true",
+ labels.LabelArcane: "true",
},
wantProject: true,
wantService: true,
@@ -4242,9 +4242,9 @@ func TestProjectService_MapProjectToDto_SetsRedeployDisabledFromRuntimeServices(
containerID: "arcane1234567890",
currentContainerID: "arcane1234567890",
labels: map[string]string{
- "com.docker.compose.project": "arcane",
- "com.docker.compose.service": "server",
- libupdater.LabelArcaneLegacyServer: "true",
+ "com.docker.compose.project": "arcane",
+ "com.docker.compose.service": "server",
+ labels.LabelArcaneLegacyServer: "true",
},
wantProject: true,
wantService: true,
@@ -4256,7 +4256,7 @@ func TestProjectService_MapProjectToDto_SetsRedeployDisabledFromRuntimeServices(
labels: map[string]string{
"com.docker.compose.project": "arcane",
"com.docker.compose.service": "server",
- libupdater.LabelArcane: "true",
+ labels.LabelArcane: "true",
},
wantProject: true,
wantService: true,
@@ -4268,8 +4268,8 @@ func TestProjectService_MapProjectToDto_SetsRedeployDisabledFromRuntimeServices(
labels: map[string]string{
"com.docker.compose.project": "arcane",
"com.docker.compose.service": "agent",
- libupdater.LabelArcane: "true",
- libupdater.LabelArcaneAgent: "true",
+ labels.LabelArcane: "true",
+ labels.LabelArcaneAgent: "true",
},
},
{
diff --git a/backend/internal/services/system_service.go b/backend/internal/services/system_service.go
index 4e22894fe..be8c7d687 100644
--- a/backend/internal/services/system_service.go
+++ b/backend/internal/services/system_service.go
@@ -18,7 +18,7 @@ import (
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/client"
"github.com/samber/mo"
- "go.getarcane.app/updater/pkg/labels"
+ "go.getarcane.app/updater/labels"
"golang.org/x/sync/errgroup"
)
diff --git a/backend/internal/services/system_upgrade_service.go b/backend/internal/services/system_upgrade_service.go
index adedcb12a..b2def8e06 100644
--- a/backend/internal/services/system_upgrade_service.go
+++ b/backend/internal/services/system_upgrade_service.go
@@ -21,16 +21,16 @@ import (
dockerutils "github.com/getarcaneapp/arcane/backend/v2/pkg/dockerutil"
"github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane"
"github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/timeouts"
- vuln "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/vuln"
+ "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/vuln"
"github.com/getarcaneapp/arcane/backend/v2/pkg/projects"
"github.com/getarcaneapp/arcane/backend/v2/pkg/remenv"
"github.com/getarcaneapp/arcane/types/v2/version"
- containertypes "github.com/moby/moby/api/types/container"
- mounttypes "github.com/moby/moby/api/types/mount"
+ "github.com/moby/moby/api/types/container"
+ "github.com/moby/moby/api/types/mount"
"github.com/moby/moby/client"
"go.getarcane.app/sys/cgroup"
- libupdater "go.getarcane.app/updater/pkg/labels"
- updatertypes "go.getarcane.app/updater/types"
+ "go.getarcane.app/updater"
+ "go.getarcane.app/updater/labels"
)
const defaultArcaneUpgraderImageInternal = "ghcr.io/getarcaneapp/arcane:latest"
@@ -47,8 +47,8 @@ type SystemUpgradeService struct {
type upgraderRuntimeOptionsInternal struct {
ContainerEnv []string
- Mounts []mounttypes.Mount
- NetworkMode containertypes.NetworkMode
+ Mounts []mount.Mount
+ NetworkMode container.NetworkMode
}
func NewSystemUpgradeService(
@@ -94,7 +94,7 @@ func (s *SystemUpgradeService) CanUpgrade(ctx context.Context) (bool, error) {
// This avoids self-termination issues by running the upgrade from outside.
// A zero-value target upgrades the current container to its own image tag;
// the updater engine passes an explicit target with the resolved new image.
-func (s *SystemUpgradeService) TriggerUpgradeViaCLI(ctx context.Context, user models.User, target updatertypes.SelfUpdateTarget) error {
+func (s *SystemUpgradeService) TriggerUpgradeViaCLI(ctx context.Context, user models.User, target updater.SelfUpdateTarget) error {
if !s.upgrading.CompareAndSwap(false, true) {
return common.Classify(common.ErrUpgradeInProgress, errors.New("an upgrade is already in progress"))
}
@@ -214,7 +214,7 @@ func (s *SystemUpgradeService) TriggerUpgradeViaCLI(ctx context.Context, user mo
upgradeCmd = append(upgradeCmd, "--image", targetImage)
}
- config := &containertypes.Config{
+ config := &container.Config{
Image: upgraderImage,
Cmd: upgradeCmd,
// The upgrader needs root for the Docker socket; unlike the server it
@@ -228,7 +228,7 @@ func (s *SystemUpgradeService) TriggerUpgradeViaCLI(ctx context.Context, user mo
},
}
- mounts := append([]mounttypes.Mount{}, runtimeOptions.Mounts...)
+ mounts := append([]mount.Mount{}, runtimeOptions.Mounts...)
if appDataMount != nil {
mounts = append(mounts, *appDataMount)
}
@@ -238,7 +238,7 @@ func (s *SystemUpgradeService) TriggerUpgradeViaCLI(ctx context.Context, user mo
slog.Info("Keeping upgrader container after exit (ARCANE_UPGRADE_KEEP_CONTAINER=true)")
}
- hostConfig := &containertypes.HostConfig{
+ hostConfig := &container.HostConfig{
AutoRemove: !keepUpgraderContainer, // default: clean up after completion
Mounts: mounts,
NetworkMode: runtimeOptions.NetworkMode,
@@ -299,8 +299,8 @@ func daemonHasSELinuxEnabledInternal(ctx context.Context, dockerClient *client.C
return slices.Contains(infoResult.Info.SecurityOptions, "name=selinux")
}
-func determineUpgradeBinaryPathInternal(labels map[string]string) string {
- if libupdater.IsArcaneAgentContainer(labels) {
+func determineUpgradeBinaryPathInternal(containerLabels map[string]string) string {
+ if labels.IsArcaneAgentContainer(containerLabels) {
return "/app/arcane-agent"
}
@@ -310,7 +310,7 @@ func determineUpgradeBinaryPathInternal(labels map[string]string) string {
func resolveSystemUpgraderRuntimeOptionsInternal(
ctx context.Context,
dockerHost string,
- currentContainer *containertypes.InspectResponse,
+ currentContainer *container.InspectResponse,
discoverHostPath func(context.Context, string) (string, error),
isRunningInDocker func() bool,
) (upgraderRuntimeOptionsInternal, error) {
@@ -324,7 +324,7 @@ func resolveSystemUpgraderRuntimeOptionsInternal(
}
if scheme != "unix" {
- options.NetworkMode = containertypes.NetworkMode(selectTrivyAutoNetworkModeInternal(currentContainer))
+ options.NetworkMode = container.NetworkMode(selectTrivyAutoNetworkModeInternal(currentContainer))
return options, nil
}
@@ -338,8 +338,8 @@ func resolveSystemUpgraderRuntimeOptionsInternal(
return upgraderRuntimeOptionsInternal{}, errors.WrapIf(err, "resolve unix socket source")
}
- options.Mounts = append(options.Mounts, mounttypes.Mount{
- Type: mounttypes.TypeBind,
+ options.Mounts = append(options.Mounts, mount.Mount{
+ Type: mount.TypeBind,
Source: socketSource,
Target: socketPath,
})
@@ -357,16 +357,16 @@ func (s *SystemUpgradeService) getCurrentContainerIDInternal() (string, error) {
}
// findArcaneContainer finds the container using the ID
-func (s *SystemUpgradeService) findArcaneContainerInternal(ctx context.Context, containerId string) (containertypes.InspectResponse, error) {
+func (s *SystemUpgradeService) findArcaneContainerInternal(ctx context.Context, containerId string) (container.InspectResponse, error) {
dockerClient, err := s.dockerService.GetClient(ctx)
if err != nil {
- return containertypes.InspectResponse{}, err
+ return container.InspectResponse{}, err
}
// Try to inspect the container directly
- container, err := libarcane.ContainerInspectWithCompatibility(ctx, dockerClient, containerId, client.ContainerInspectOptions{})
+ inspectResult, err := libarcane.ContainerInspectWithCompatibility(ctx, dockerClient, containerId, client.ContainerInspectOptions{})
if err == nil {
- return container.Container, nil
+ return inspectResult.Container, nil
}
// Fallback: search for containers with arcane image
@@ -378,14 +378,14 @@ func (s *SystemUpgradeService) findArcaneContainerInternal(ctx context.Context,
Filters: filter,
})
if err != nil {
- return containertypes.InspectResponse{}, err
+ return container.InspectResponse{}, err
}
for _, c := range containers.Items {
if strings.HasPrefix(c.ID, containerId) {
inspect, inspectErr := libarcane.ContainerInspectWithCompatibility(ctx, dockerClient, c.ID, client.ContainerInspectOptions{})
if inspectErr != nil {
- return containertypes.InspectResponse{}, inspectErr
+ return container.InspectResponse{}, inspectErr
}
return inspect.Container, nil
}
@@ -394,20 +394,20 @@ func (s *SystemUpgradeService) findArcaneContainerInternal(ctx context.Context,
// Try without filter - search all containers
allContainers, err := dockerClient.ContainerList(ctx, client.ContainerListOptions{All: true})
if err != nil {
- return containertypes.InspectResponse{}, err
+ return container.InspectResponse{}, err
}
for _, c := range allContainers.Items {
if strings.HasPrefix(c.ID, containerId) || c.ID == containerId {
inspect, inspectErr := libarcane.ContainerInspectWithCompatibility(ctx, dockerClient, c.ID, client.ContainerInspectOptions{})
if inspectErr != nil {
- return containertypes.InspectResponse{}, inspectErr
+ return container.InspectResponse{}, inspectErr
}
return inspect.Container, nil
}
}
- return containertypes.InspectResponse{}, common.Classify(common.ErrNotFound, errors.
+ return container.InspectResponse{}, common.Classify(common.ErrNotFound, errors.
// --- Fleet-wide "update all environments" orchestration ---
//
@@ -621,7 +621,7 @@ func (s *SystemUpgradeService) runAgentsPhaseInternal(ctx context.Context, jobID
slog.WarnContext(ctx, "update-all: failed to persist pending_restart before manager upgrade", "jobId", job.ID, "error", err)
}
- if err := s.TriggerUpgradeViaCLI(ctx, user, updatertypes.SelfUpdateTarget{}); err != nil {
+ if err := s.TriggerUpgradeViaCLI(ctx, user, updater.SelfUpdateTarget{}); err != nil {
// Agents already ran and no restart is coming, so finalize now. This flips
// the manager's updating row to failed with the reason.
s.markUpdateAllFailedInternal(ctx, job, fmt.Sprintf("manager upgrade trigger failed: %v", err))
diff --git a/backend/internal/services/system_upgrade_service_test.go b/backend/internal/services/system_upgrade_service_test.go
index 147d31e11..9b2b8432d 100644
--- a/backend/internal/services/system_upgrade_service_test.go
+++ b/backend/internal/services/system_upgrade_service_test.go
@@ -14,7 +14,7 @@ import (
mounttypes "github.com/moby/moby/api/types/mount"
networktypes "github.com/moby/moby/api/types/network"
"github.com/stretchr/testify/require"
- libupdater "go.getarcane.app/updater/pkg/labels"
+ "go.getarcane.app/updater/labels"
)
// TestSystemUpgradeService_UpgradeFlag tests the upgrading flag behavior
@@ -171,14 +171,14 @@ func TestDetermineUpgradeBinaryPath(t *testing.T) {
{
name: "agent container uses agent binary",
labels: map[string]string{
- libupdater.LabelArcaneAgent: "true",
+ labels.LabelArcaneAgent: "true",
},
want: "/app/arcane-agent",
},
{
name: "main container uses main binary",
labels: map[string]string{
- libupdater.LabelArcane: "true",
+ labels.LabelArcane: "true",
},
want: "/app/arcane",
},
diff --git a/backend/internal/services/updater_service.go b/backend/internal/services/updater_service.go
index 6c98f0dc4..61ae2347b 100644
--- a/backend/internal/services/updater_service.go
+++ b/backend/internal/services/updater_service.go
@@ -23,22 +23,20 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/timeouts"
projectspkg "github.com/getarcaneapp/arcane/backend/v2/pkg/projects"
"github.com/getarcaneapp/arcane/backend/v2/pkg/utils"
- "github.com/getarcaneapp/arcane/types/v2/updater"
+ arcaneupdater "github.com/getarcaneapp/arcane/types/v2/updater"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/client"
"github.com/samber/mo"
"go.getarcane.app/sys/cgroup"
- moduleapi "go.getarcane.app/updater/api"
- updaterdigest "go.getarcane.app/updater/pkg/digest"
- "go.getarcane.app/updater/pkg/labels"
- "go.getarcane.app/updater/pkg/refs"
- moduletypes "go.getarcane.app/updater/types"
+ "go.getarcane.app/updater"
+ "go.getarcane.app/updater/labels"
+ "go.getarcane.app/updater/refs"
)
// UpdaterService is Arcane's handler-facing service for the standalone updater engine.
type UpdaterService struct {
deps updaterDependenciesInternal
- engine *moduleapi.Service
+ engine *updater.Service
}
type updaterDependenciesInternal struct {
@@ -58,7 +56,7 @@ type updaterDependenciesInternal struct {
}
type selfUpgradeServiceInternal interface {
- TriggerUpgradeViaCLI(ctx context.Context, user models.User, target moduletypes.SelfUpdateTarget) error
+ TriggerUpgradeViaCLI(ctx context.Context, user models.User, target updater.SelfUpdateTarget) error
}
// NewUpdaterService constructs the Arcane updater facade.
@@ -74,7 +72,7 @@ func NewUpdaterService(
notifications *NotificationService,
upgrade selfUpgradeServiceInternal,
activityService *ActivityService,
-) *UpdaterService {
+) (*UpdaterService, error) {
service := &UpdaterService{
deps: updaterDependenciesInternal{
DB: db,
@@ -91,12 +89,16 @@ func NewUpdaterService(
SystemUser: systemUser,
},
}
- service.engine = moduleapi.NewService(service.configInternal())
- return service
+ engine, err := updater.New(service.configInternal())
+ if err != nil {
+ return nil, errors.WrapIf(err, "configure updater engine")
+ }
+ service.engine = engine
+ return service, nil
}
-func (s *UpdaterService) configInternal() moduleapi.Config {
- return moduleapi.Config{
+func (s *UpdaterService) configInternal() updater.Config {
+ return updater.Config{
DockerClientProvider: s,
ImagePuller: s,
PendingStore: s,
@@ -107,8 +109,8 @@ func (s *UpdaterService) configInternal() moduleapi.Config {
SelfUpdater: s,
Notifier: s,
EventRecorder: s,
- UsedImageCollector: moduleapi.UsedImageCollectorFunc(s.CollectUsedImages),
- LabelPolicy: labels.DefaultLabelPolicy(),
+ UsedImageCollector: updater.UsedImageCollectorFunc(s.CollectUsedImages),
+ LabelPolicy: updater.DefaultLabelPolicy(),
SelfContainerID: selfContainerIDInternal(),
Logger: s.loggerInternal(),
}
@@ -125,7 +127,7 @@ func selfContainerIDInternal() string {
return id
}
-func (s *UpdaterService) engineInternal() *moduleapi.Service {
+func (s *UpdaterService) engineInternal() *updater.Service {
return s.engine
}
@@ -136,7 +138,7 @@ func (s *UpdaterService) loggerInternal() *slog.Logger {
return slog.Default()
}
-func (s *UpdaterService) registryDigestResolverInternal() updaterdigest.RemoteResolver {
+func (s *UpdaterService) registryDigestResolverInternal() updater.RegistryDigestResolver {
if s == nil || s.deps.RegistryDigestResolver == nil {
return nil
}
@@ -148,16 +150,16 @@ func (s *UpdaterService) registryDigestResolverInternal() updaterdigest.RemoteRe
// filtering (it would apply every pending update), so scoped requests resolve
// to concrete containers and go through the engine's single-container path
// instead — same activity, events, and cleanup either way.
-func (s *UpdaterService) ApplyPending(ctx context.Context, options updater.Options) (out *updater.Result, err error) {
+func (s *UpdaterService) ApplyPending(ctx context.Context, options arcaneupdater.Options) (out *arcaneupdater.Result, err error) {
start := time.Now()
activityID := s.startAutoUpdateActivityInternal(ctx, options.DryRun)
- out = &updater.Result{Items: []updater.ResourceResult{}, ActivityID: mo.EmptyableToOption(strings.TrimSpace(activityID)).ToPointer()}
+ out = &arcaneupdater.Result{Items: []arcaneupdater.ResourceResult{}, ActivityID: mo.EmptyableToOption(strings.TrimSpace(activityID)).ToPointer()}
ctx = s.trackActivityInternal(ctx, activityID)
ctx = contextWithActivityIDInternal(ctx, activityID)
defer func() {
if out == nil {
- out = &updater.Result{Items: []updater.ResourceResult{}}
+ out = &arcaneupdater.Result{Items: []arcaneupdater.ResourceResult{}}
}
if out.Duration == "" {
out.Duration = time.Since(start).String()
@@ -231,7 +233,7 @@ func (s *UpdaterService) ApplyPending(ctx context.Context, options updater.Optio
// applyScopedUpdatesInternal runs a scoped update into the caller's result:
// resolves the requested resources to container IDs and updates each through
// the engine's single-container path.
-func (s *UpdaterService) applyScopedUpdatesInternal(ctx context.Context, options updater.Options, out *updater.Result) error {
+func (s *UpdaterService) applyScopedUpdatesInternal(ctx context.Context, options arcaneupdater.Options, out *arcaneupdater.Result) error {
containerIDs, err := s.resolveScopedContainerIDsInternal(ctx, options)
if err != nil {
return err
@@ -240,7 +242,7 @@ func (s *UpdaterService) applyScopedUpdatesInternal(ctx context.Context, options
return errors.Errorf("no containers matched the requested %s resources", strings.TrimSpace(options.Type))
}
- engineOpts := moduletypes.Options{Force: options.ForceUpdate, DryRun: options.DryRun}
+ engineOpts := updater.Options{Force: options.ForceUpdate, DryRun: options.DryRun}
var engineErrs []error
for _, containerID := range containerIDs {
moduleResult, engineErr := s.engineInternal().UpdateContainer(ctx, containerID, engineOpts)
@@ -255,10 +257,10 @@ func (s *UpdaterService) applyScopedUpdatesInternal(ctx context.Context, options
}
if engineErr != nil {
out.Failed++
- out.Items = append(out.Items, updater.ResourceResult{
+ out.Items = append(out.Items, arcaneupdater.ResourceResult{
ResourceID: containerID,
ResourceType: "container",
- Status: updater.StatusFailed,
+ Status: arcaneupdater.StatusFailed,
Error: engineErr.Error(),
})
engineErrs = append(engineErrs, errors.WrapIff(engineErr, "%s", containerID))
@@ -273,7 +275,7 @@ func (s *UpdaterService) applyScopedUpdatesInternal(ctx context.Context, options
// resolveScopedContainerIDsInternal maps a scoped options payload to the
// container IDs it covers.
-func (s *UpdaterService) resolveScopedContainerIDsInternal(ctx context.Context, options updater.Options) ([]string, error) {
+func (s *UpdaterService) resolveScopedContainerIDsInternal(ctx context.Context, options arcaneupdater.Options) ([]string, error) {
requested := make([]string, 0, len(options.ResourceIds))
for _, id := range options.ResourceIds {
if trimmed := strings.TrimSpace(id); trimmed != "" {
@@ -377,17 +379,17 @@ func (s *UpdaterService) containerIDsForImagesInternal(ctx context.Context, imag
}
// UpdateSingleContainer updates a single container by ID to the latest available image.
-func (s *UpdaterService) UpdateSingleContainer(ctx context.Context, containerID string) (out *updater.Result, err error) {
+func (s *UpdaterService) UpdateSingleContainer(ctx context.Context, containerID string) (out *arcaneupdater.Result, err error) {
start := time.Now()
activityID := s.startSingleContainerUpdateActivityInternal(ctx, containerID)
- out = &updater.Result{Items: []updater.ResourceResult{}, ActivityID: mo.EmptyableToOption(strings.TrimSpace(activityID)).ToPointer()}
+ out = &arcaneupdater.Result{Items: []arcaneupdater.ResourceResult{}, ActivityID: mo.EmptyableToOption(strings.TrimSpace(activityID)).ToPointer()}
ctx = s.trackActivityInternal(ctx, activityID)
ctx = contextWithActivityIDInternal(ctx, activityID)
activitylib.AwaitHandlerActivitySlot(ctx, s.deps.Activity, activityID, "0")
defer func() {
if out == nil {
- out = &updater.Result{Items: []updater.ResourceResult{}}
+ out = &arcaneupdater.Result{Items: []arcaneupdater.ResourceResult{}}
}
if out.Duration == "" {
out.Duration = time.Since(start).String()
@@ -396,7 +398,7 @@ func (s *UpdaterService) UpdateSingleContainer(ctx context.Context, containerID
s.completeAutoUpdateActivityInternal(ctx, activityID, out, err)
}()
- moduleResult, engineErr := s.engineInternal().UpdateContainer(ctx, containerID, moduletypes.Options{})
+ moduleResult, engineErr := s.engineInternal().UpdateContainer(ctx, containerID, updater.Options{})
if moduleResult != nil {
out = resultFromModuleInternal(moduleResult)
out.ActivityID = mo.EmptyableToOption(strings.TrimSpace(activityID)).ToPointer()
@@ -410,7 +412,7 @@ func (s *UpdaterService) UpdateSingleContainer(ctx context.Context, containerID
}
// GetStatus returns the current in-memory update activity snapshot.
-func (s *UpdaterService) GetStatus() updater.Status {
+func (s *UpdaterService) GetStatus() arcaneupdater.Status {
return statusFromModuleInternal(s.engineInternal().Status())
}
@@ -428,7 +430,7 @@ func (s *UpdaterService) GetHistory(ctx context.Context, limit int) ([]models.Au
}
// RestartContainersUsingOldIDs restarts containers matching old image IDs or refs.
-func (s *UpdaterService) RestartContainersUsingOldIDs(ctx context.Context, oldIDToNewRef map[string]string, oldRefToNewRef map[string]string) ([]updater.ResourceResult, error) {
+func (s *UpdaterService) RestartContainersUsingOldIDs(ctx context.Context, oldIDToNewRef map[string]string, oldRefToNewRef map[string]string) ([]arcaneupdater.ResourceResult, error) {
results, err := s.engineInternal().RestartContainersUsingOldImages(ctx, oldIDToNewRef, oldRefToNewRef)
return resourceResultsFromModuleInternal(results), err
}
@@ -438,7 +440,7 @@ func (s *UpdaterService) TriggerSelfUpdateViaCLI(ctx context.Context, source, co
if !labels.IsArcaneContainer(labelMap) {
return errors.Errorf("%s: container is not an Arcane self-update target", source)
}
- return s.TriggerSelfUpdate(ctx, moduletypes.SelfUpdateTarget{
+ return s.TriggerSelfUpdate(ctx, updater.SelfUpdateTarget{
ContainerID: containerID,
ContainerName: containerName,
InstanceType: instanceTypeFromLabelsInternal(labelMap),
@@ -571,7 +573,7 @@ func (s *UpdaterService) PullImage(ctx context.Context, imageRef string, progres
}
// PendingImageUpdates returns pending image update records from Arcane's database.
-func (s *UpdaterService) PendingImageUpdates(ctx context.Context) ([]moduletypes.ImageUpdateRecord, error) {
+func (s *UpdaterService) PendingImageUpdates(ctx context.Context) ([]updater.ImageUpdateRecord, error) {
if s == nil || s.deps.DB == nil {
return nil, common.Classify(common.ErrUnavailable, errors.New("database unavailable"))
}
@@ -595,7 +597,7 @@ func (s *UpdaterService) PendingImageUpdates(ctx context.Context) ([]moduletypes
10,
)
- out := make([]moduletypes.ImageUpdateRecord, 0, len(records))
+ out := make([]updater.ImageUpdateRecord, 0, len(records))
for _, record := range records {
out = append(out, imageUpdateRecordToModuleInternal(record))
}
@@ -603,7 +605,7 @@ func (s *UpdaterService) PendingImageUpdates(ctx context.Context) ([]moduletypes
}
// ClearImageUpdateRecord clears a pending image update record after it is handled.
-func (s *UpdaterService) ClearImageUpdateRecord(ctx context.Context, record moduletypes.ImageUpdateRecord) error {
+func (s *UpdaterService) ClearImageUpdateRecord(ctx context.Context, record updater.ImageUpdateRecord) error {
if s == nil {
return common.Classify(common.ErrUnavailable, errors.New("updater service unavailable"))
}
@@ -611,7 +613,7 @@ func (s *UpdaterService) ClearImageUpdateRecord(ctx context.Context, record modu
}
// RecordUpdateRun persists one updater resource result into Arcane history.
-func (s *UpdaterService) RecordUpdateRun(ctx context.Context, result moduletypes.ResourceResult) error {
+func (s *UpdaterService) RecordUpdateRun(ctx context.Context, result updater.ResourceResult) error {
if s == nil || s.deps.DB == nil {
return nil
}
@@ -635,18 +637,18 @@ func (s *UpdaterService) ExcludedContainers(ctx context.Context) ([]string, erro
}
// ProjectByComposeName resolves an Arcane project from a Docker Compose project name.
-func (s *UpdaterService) ProjectByComposeName(ctx context.Context, composeName string) (moduletypes.ComposeProject, error) {
+func (s *UpdaterService) ProjectByComposeName(ctx context.Context, composeName string) (updater.ComposeProject, error) {
if s == nil || s.deps.Projects == nil {
- return moduletypes.ComposeProject{}, common.Classify(common.ErrUnavailable, errors.New("project service unavailable"))
+ return updater.ComposeProject{}, common.Classify(common.ErrUnavailable, errors.New("project service unavailable"))
}
project, err := s.deps.Projects.GetProjectByComposeName(ctx, composeName)
if err != nil {
- return moduletypes.ComposeProject{}, err
+ return updater.ComposeProject{}, err
}
if project == nil {
- return moduletypes.ComposeProject{}, errors.Errorf("compose project not found: %s", composeName)
+ return updater.ComposeProject{}, errors.Errorf("compose project not found: %s", composeName)
}
- return moduletypes.ComposeProject{ID: project.ID, Name: project.Name}, nil
+ return updater.ComposeProject{ID: project.ID, Name: project.Name}, nil
}
// UpdateServices redeploys selected services through Arcane's project service.
@@ -658,7 +660,7 @@ func (s *UpdaterService) UpdateServices(ctx context.Context, projectID string, s
}
// TriggerSelfUpdate runs Arcane's CLI-backed self-update hook.
-func (s *UpdaterService) TriggerSelfUpdate(ctx context.Context, target moduletypes.SelfUpdateTarget) error {
+func (s *UpdaterService) TriggerSelfUpdate(ctx context.Context, target updater.SelfUpdateTarget) error {
if s == nil || s.deps.SelfUpgrade == nil {
instanceType := strings.TrimSpace(target.InstanceType)
if instanceType == "" {
@@ -680,7 +682,7 @@ func (s *UpdaterService) TriggerSelfUpdate(ctx context.Context, target moduletyp
return nil
}
-func (s *UpdaterService) markSelfUpdateTriggeredInternal(ctx context.Context, target moduletypes.SelfUpdateTarget) {
+func (s *UpdaterService) markSelfUpdateTriggeredInternal(ctx context.Context, target updater.SelfUpdateTarget) {
activityID := activityIDFromContextInternal(ctx)
if s.deps.Activity == nil || activityID == "" {
return
@@ -696,7 +698,7 @@ func (s *UpdaterService) markSelfUpdateTriggeredInternal(ctx context.Context, ta
}
// Notify sends Arcane's container update notification.
-func (s *UpdaterService) Notify(ctx context.Context, notification moduletypes.Notification) error {
+func (s *UpdaterService) Notify(ctx context.Context, notification updater.Notification) error {
if s == nil || s.deps.Notifications == nil {
return nil
}
@@ -710,7 +712,7 @@ func (s *UpdaterService) Notify(ctx context.Context, notification moduletypes.No
}
// RecordEvent records updater lifecycle events in Arcane's event stream.
-func (s *UpdaterService) RecordEvent(ctx context.Context, event moduletypes.Event) error {
+func (s *UpdaterService) RecordEvent(ctx context.Context, event updater.Event) error {
if s == nil {
return nil
}
@@ -841,7 +843,7 @@ func (s *UpdaterService) appendAutoUpdateActivityMessageInternal(ctx context.Con
}
}
-func (s *UpdaterService) completeAutoUpdateActivityInternal(ctx context.Context, activityID string, result *updater.Result, applyErr error) {
+func (s *UpdaterService) completeAutoUpdateActivityInternal(ctx context.Context, activityID string, result *arcaneupdater.Result, applyErr error) {
if s.deps.Activity == nil || strings.TrimSpace(activityID) == "" {
return
}
@@ -880,13 +882,13 @@ func (s *UpdaterService) trackActivityInternal(ctx context.Context, activityID s
return s.deps.Activity.Track(ctx, activityID)
}
-func imageUpdateRecordToModuleInternal(record models.ImageUpdateRecord) moduletypes.ImageUpdateRecord {
- return moduletypes.ImageUpdateRecord{
+func imageUpdateRecordToModuleInternal(record models.ImageUpdateRecord) updater.ImageUpdateRecord {
+ return updater.ImageUpdateRecord{
ID: record.ID,
Repository: record.Repository,
Tag: record.Tag,
HasUpdate: record.HasUpdate,
- UpdateType: record.UpdateType,
+ UpdateType: updater.UpdateType(record.UpdateType),
CurrentVersion: record.CurrentVersion,
LatestVersion: record.LatestVersion,
CurrentDigest: record.CurrentDigest,
@@ -896,59 +898,81 @@ func imageUpdateRecordToModuleInternal(record models.ImageUpdateRecord) modulety
}
}
-func moduleOptionsFromUpdaterOptionsInternal(options updater.Options) moduletypes.Options {
- return moduletypes.Options{
- Type: options.Type,
- ResourceIDs: slices.Clone(options.ResourceIds),
- Force: options.ForceUpdate,
- DryRun: options.DryRun,
+// moduleOptionsFromUpdaterOptionsInternal narrows Arcane's request options to
+// what the engine acts on. Options.Type and Options.ResourceIds stay behind:
+// the engine never read them, and ApplyPending already routes a scoped request
+// through applyScopedUpdatesInternal before reaching the engine.
+func moduleOptionsFromUpdaterOptionsInternal(options arcaneupdater.Options) updater.Options {
+ return updater.Options{
+ Force: options.ForceUpdate,
+ DryRun: options.DryRun,
}
}
-func resultFromModuleInternal(result *moduletypes.Result) *updater.Result {
+// resultFromModuleInternal converts an engine result to Arcane's wire type. The
+// engine reports times as time.Time and a Duration method; Arcane's API has
+// always carried them as strings, so they are formatted here. ActivityID is not
+// an engine concept; every caller sets it on the returned value.
+func resultFromModuleInternal(result *updater.Result) *arcaneupdater.Result {
if result == nil {
- return &updater.Result{Items: []updater.ResourceResult{}}
+ return &arcaneupdater.Result{Items: []arcaneupdater.ResourceResult{}}
+ }
+ return &arcaneupdater.Result{
+ Success: result.Success,
+ Checked: result.Checked,
+ Updated: result.Updated,
+ Restarted: result.Restarted,
+ Skipped: result.Skipped,
+ Failed: result.Failed,
+ StartTime: formatModuleTimeInternal(result.StartTime),
+ EndTime: formatModuleTimeInternal(result.EndTime),
+ Duration: result.Duration().String(),
+ Items: resourceResultsFromModuleInternal(result.Items),
}
- return &updater.Result{
- Success: result.Success,
- Checked: result.Checked,
- Updated: result.Updated,
- Restarted: result.Restarted,
- Skipped: result.Skipped,
- Failed: result.Failed,
- StartTime: result.StartTime,
- EndTime: result.EndTime,
- Duration: result.Duration,
- Items: resourceResultsFromModuleInternal(result.Items),
- ActivityID: result.ActivityID,
+}
+
+func formatModuleTimeInternal(value time.Time) string {
+ if value.IsZero() {
+ return ""
}
+ return value.UTC().Format(time.RFC3339)
}
-func resourceResultsFromModuleInternal(results []moduletypes.ResourceResult) []updater.ResourceResult {
- out := make([]updater.ResourceResult, 0, len(results))
+func resourceResultsFromModuleInternal(results []updater.ResourceResult) []arcaneupdater.ResourceResult {
+ out := make([]arcaneupdater.ResourceResult, 0, len(results))
for _, result := range results {
out = append(out, resourceResultFromModuleInternal(result))
}
return out
}
-func resourceResultFromModuleInternal(result moduletypes.ResourceResult) updater.ResourceResult {
- return updater.ResourceResult{
+// resourceResultFromModuleInternal converts one engine result to Arcane's wire
+// type. The engine now reports a single old/new image; Arcane's API carries
+// maps, which only ever held the "main" entry, so that shape is rebuilt here.
+func resourceResultFromModuleInternal(result updater.ResourceResult) arcaneupdater.ResourceResult {
+ return arcaneupdater.ResourceResult{
ResourceID: result.ResourceID,
ResourceName: result.ResourceName,
- ResourceType: result.ResourceType,
- Status: result.Status,
+ ResourceType: string(result.ResourceType),
+ Status: string(result.Status),
UpdateAvailable: result.UpdateAvailable,
UpdateApplied: result.UpdateApplied,
- OldImages: result.OldImages,
- NewImages: result.NewImages,
+ OldImages: mainImageMapInternal(result.OldImage),
+ NewImages: mainImageMapInternal(result.NewImage),
Error: result.Error,
Details: result.Details,
}
}
-func statusFromModuleInternal(status moduletypes.Status) updater.Status {
- return updater.Status{
+func mainImageMapInternal(imageRef string) map[string]string {
+ if imageRef == "" {
+ return nil
+ }
+ return map[string]string{"main": imageRef}
+}
+
+func statusFromModuleInternal(status updater.Status) arcaneupdater.Status {
+ return arcaneupdater.Status{
UpdatingContainers: status.UpdatingContainers,
UpdatingProjects: status.UpdatingProjects,
ContainerIds: status.ContainerIDs,
@@ -956,7 +980,7 @@ func statusFromModuleInternal(status moduletypes.Status) updater.Status {
}
}
-func (s *UpdaterService) recordRunInternal(ctx context.Context, item updater.ResourceResult) error {
+func (s *UpdaterService) recordRunInternal(ctx context.Context, item arcaneupdater.ResourceResult) error {
now := time.Now()
record := &models.AutoUpdateRecord{
ResourceID: item.ResourceID,
@@ -965,7 +989,7 @@ func (s *UpdaterService) recordRunInternal(ctx context.Context, item updater.Res
Status: models.AutoUpdateStatus(item.Status),
StartTime: now,
EndTime: &now,
- UpdateAvailable: item.UpdateAvailable || item.Status == moduletypes.StatusUpdated || item.Status == moduletypes.StatusUpdateAvailable,
+ UpdateAvailable: item.UpdateAvailable || item.Status == string(updater.StatusUpdated) || item.Status == string(updater.StatusUpdateAvailable),
UpdateApplied: item.UpdateApplied,
OldImageVersions: mapToJSONInternal(item.OldImages),
NewImageVersions: mapToJSONInternal(item.NewImages),
@@ -977,7 +1001,7 @@ func (s *UpdaterService) recordRunInternal(ctx context.Context, item updater.Res
return s.deps.DB.WithContext(ctx).Create(record).Error
}
-func (s *UpdaterService) clearImageUpdateRecordForModuleInternal(ctx context.Context, record moduletypes.ImageUpdateRecord) error {
+func (s *UpdaterService) clearImageUpdateRecordForModuleInternal(ctx context.Context, record updater.ImageUpdateRecord) error {
if s.deps.DB == nil {
return nil
}
@@ -1009,16 +1033,16 @@ func detailsToJSONInternal(values map[string]any) models.JSON {
return out
}
-func (s *UpdaterService) logResultItemsInternal(ctx context.Context, result *updater.Result) {
+func (s *UpdaterService) logResultItemsInternal(ctx context.Context, result *arcaneupdater.Result) {
if result == nil {
return
}
for _, item := range result.Items {
severity := models.EventSeverityInfo
switch item.Status {
- case moduletypes.StatusFailed:
+ case string(updater.StatusFailed):
severity = models.EventSeverityError
- case moduletypes.StatusUpdated:
+ case string(updater.StatusUpdated):
severity = models.EventSeveritySuccess
}
s.recordAutoUpdateEventInternal(ctx, severity, models.JSON{
diff --git a/backend/internal/services/updater_service_test.go b/backend/internal/services/updater_service_test.go
index 0c69353f4..2e8575df1 100644
--- a/backend/internal/services/updater_service_test.go
+++ b/backend/internal/services/updater_service_test.go
@@ -23,9 +23,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.getarcane.app/sys/crypto"
- moduleapi "go.getarcane.app/updater/api"
- updaterlabels "go.getarcane.app/updater/pkg/labels"
- moduletypes "go.getarcane.app/updater/types"
+ "go.getarcane.app/updater"
+ "go.getarcane.app/updater/labels"
+ "go.getarcane.app/updater/refs"
)
type fakeDockerClientProviderInternal struct {
@@ -54,10 +54,10 @@ func (f *fakeImagePullerInternal) PullImage(_ context.Context, imageRef string,
}
type fakeRunRecorderInternal struct {
- results []moduletypes.ResourceResult
+ results []updater.ResourceResult
}
-func (f *fakeRunRecorderInternal) RecordUpdateRun(_ context.Context, result moduletypes.ResourceResult) error {
+func (f *fakeRunRecorderInternal) RecordUpdateRun(_ context.Context, result updater.ResourceResult) error {
f.results = append(f.results, result)
return nil
}
@@ -77,16 +77,16 @@ func (f fakeUsedImageCollectorInternal) UsedImages(context.Context) (map[string]
}
type fakeProjectUpdaterInternal struct {
- projects map[string]moduletypes.ComposeProject
+ projects map[string]updater.ComposeProject
updateErrs map[string]error
calls []string
}
-func (f *fakeProjectUpdaterInternal) ProjectByComposeName(_ context.Context, composeName string) (moduletypes.ComposeProject, error) {
+func (f *fakeProjectUpdaterInternal) ProjectByComposeName(_ context.Context, composeName string) (updater.ComposeProject, error) {
if project, ok := f.projects[composeName]; ok {
return project, nil
}
- return moduletypes.ComposeProject{}, errors.New("project not found")
+ return updater.ComposeProject{}, errors.New("project not found")
}
func (f *fakeProjectUpdaterInternal) UpdateServices(_ context.Context, projectID string, services []string) error {
@@ -178,10 +178,10 @@ type mockSystemUpgradeServiceInternal struct {
triggerCalled bool
triggerError error
capturedUser *models.User
- capturedTarget *moduletypes.SelfUpdateTarget
+ capturedTarget *updater.SelfUpdateTarget
}
-func (m *mockSystemUpgradeServiceInternal) TriggerUpgradeViaCLI(_ context.Context, user models.User, target moduletypes.SelfUpdateTarget) error {
+func (m *mockSystemUpgradeServiceInternal) TriggerUpgradeViaCLI(_ context.Context, user models.User, target updater.SelfUpdateTarget) error {
m.triggerCalled = true
m.capturedUser = &user
m.capturedTarget = &target
@@ -191,7 +191,8 @@ func (m *mockSystemUpgradeServiceInternal) TriggerUpgradeViaCLI(_ context.Contex
func TestUpdaterService_ApplyPendingNoRecordsInternal(t *testing.T) {
ctx := context.Background()
db := setupProjectTestDB(t)
- svc := NewUpdaterService(db, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ svc, svcErr := NewUpdaterService(db, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ require.NoError(t, svcErr)
result, err := svc.ApplyPending(ctx, arcaneupdater.Options{DryRun: true})
@@ -204,32 +205,31 @@ func TestUpdaterService_ApplyPendingNoRecordsInternal(t *testing.T) {
assert.Empty(t, result.Items)
}
+// Type and ResourceIds are Arcane-side scoping the engine never acted on;
+// ApplyPending handles a scoped request itself before reaching the engine.
func TestUpdaterService_ModuleOptionsFromUpdaterOptionsInternal(t *testing.T) {
got := moduleOptionsFromUpdaterOptionsInternal(arcaneupdater.Options{
- Type: moduletypes.ResourceTypeImage,
+ Type: string(updater.ResourceTypeImage),
ResourceIds: []string{"image-1", "image-2"},
ForceUpdate: true,
DryRun: true,
})
- assert.Equal(t, moduletypes.ResourceTypeImage, got.Type)
- assert.Equal(t, []string{"image-1", "image-2"}, got.ResourceIDs)
- assert.True(t, got.Force)
- assert.True(t, got.DryRun)
+ assert.Equal(t, updater.Options{Force: true, DryRun: true}, got)
}
func TestUpdaterService_ResultFromModulePreservesRestartedInternal(t *testing.T) {
- got := resultFromModuleInternal(&moduletypes.Result{
+ got := resultFromModuleInternal(&updater.Result{
Success: true,
Checked: 2,
Updated: 1,
Restarted: 1,
- Items: []moduletypes.ResourceResult{
+ Items: []updater.ResourceResult{
{
ResourceID: "web-id",
ResourceName: "web",
- ResourceType: moduletypes.ResourceTypeContainer,
- Status: moduletypes.StatusRestarted,
+ ResourceType: updater.ResourceTypeContainer,
+ Status: updater.StatusRestarted,
UpdateApplied: true,
},
},
@@ -247,10 +247,11 @@ func TestUpdaterService_TriggerSelfUpdateViaCLIInternal(t *testing.T) {
t.Run("server label triggers upgrade with system user", func(t *testing.T) {
mockUpgrade := &mockSystemUpgradeServiceInternal{}
- svc := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, mockUpgrade, nil)
+ svc, svcErr := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, mockUpgrade, nil)
+ require.NoError(t, svcErr)
err := svc.TriggerSelfUpdateViaCLI(ctx, "test", "container-1", "arcane", map[string]string{
- updaterlabels.LabelArcane: "true",
+ labels.LabelArcane: "true",
})
require.NoError(t, err)
@@ -265,10 +266,11 @@ func TestUpdaterService_TriggerSelfUpdateViaCLIInternal(t *testing.T) {
t.Run("agent label triggers upgrade", func(t *testing.T) {
mockUpgrade := &mockSystemUpgradeServiceInternal{}
- svc := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, mockUpgrade, nil)
+ svc, svcErr := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, mockUpgrade, nil)
+ require.NoError(t, svcErr)
err := svc.TriggerSelfUpdateViaCLI(ctx, "test", "container-1", "arcane-agent", map[string]string{
- updaterlabels.LabelArcaneAgent: "true",
+ labels.LabelArcaneAgent: "true",
})
require.NoError(t, err)
@@ -277,7 +279,8 @@ func TestUpdaterService_TriggerSelfUpdateViaCLIInternal(t *testing.T) {
t.Run("non Arcane labels fail without triggering upgrade", func(t *testing.T) {
mockUpgrade := &mockSystemUpgradeServiceInternal{}
- svc := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, mockUpgrade, nil)
+ svc, svcErr := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, mockUpgrade, nil)
+ require.NoError(t, svcErr)
err := svc.TriggerSelfUpdateViaCLI(ctx, "test", "container-1", "demo", map[string]string{
"com.example.app": "demo",
@@ -289,10 +292,11 @@ func TestUpdaterService_TriggerSelfUpdateViaCLIInternal(t *testing.T) {
})
t.Run("missing upgrade service reports required hook", func(t *testing.T) {
- svc := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ svc, svcErr := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ require.NoError(t, svcErr)
err := svc.TriggerSelfUpdateViaCLI(ctx, "test", "container-1", "arcane", map[string]string{
- updaterlabels.LabelArcane: "true",
+ labels.LabelArcane: "true",
})
require.Error(t, err)
@@ -301,10 +305,11 @@ func TestUpdaterService_TriggerSelfUpdateViaCLIInternal(t *testing.T) {
t.Run("upgrade errors are wrapped", func(t *testing.T) {
mockUpgrade := &mockSystemUpgradeServiceInternal{triggerError: errors.New("upgrade failed")}
- svc := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, mockUpgrade, nil)
+ svc, svcErr := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, mockUpgrade, nil)
+ require.NoError(t, svcErr)
err := svc.TriggerSelfUpdateViaCLI(ctx, "test", "container-1", "arcane", map[string]string{
- updaterlabels.LabelArcane: "true",
+ labels.LabelArcane: "true",
})
require.Error(t, err)
@@ -313,7 +318,8 @@ func TestUpdaterService_TriggerSelfUpdateViaCLIInternal(t *testing.T) {
}
func TestUpdaterService_StatusTrackingInternal(t *testing.T) {
- svc := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ svc, svcErr := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ require.NoError(t, svcErr)
stopContainer := svc.BeginContainerUpdate("container-1")
stopProject := svc.BeginProjectUpdate("project-a")
@@ -338,7 +344,8 @@ func TestUpdaterService_DockerClientAdapterInternal(t *testing.T) {
ctx := context.Background()
t.Run("missing docker service returns unavailable error", func(t *testing.T) {
- svc := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ svc, svcErr := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ require.NoError(t, svcErr)
cli, err := svc.DockerClient(ctx)
@@ -351,7 +358,8 @@ func TestUpdaterService_DockerClientAdapterInternal(t *testing.T) {
server := newProjectImagePullServer(t, nil)
wantClient := newTestDockerClient(t, server)
dockerSvc := &DockerClientService{client: wantClient}
- svc := NewUpdaterService(nil, nil, dockerSvc, nil, nil, nil, nil, nil, nil, nil, nil)
+ svc, svcErr := NewUpdaterService(nil, nil, dockerSvc, nil, nil, nil, nil, nil, nil, nil, nil)
+ require.NoError(t, svcErr)
gotClient, err := svc.DockerClient(ctx)
@@ -364,7 +372,8 @@ func TestUpdaterService_PullImageAdapterInternal(t *testing.T) {
ctx := context.Background()
t.Run("missing image service returns unavailable error", func(t *testing.T) {
- svc := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ svc, svcErr := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ require.NoError(t, svcErr)
err := svc.PullImage(ctx, "registry.example.com/app:1.2.3", nil)
@@ -377,7 +386,8 @@ func TestUpdaterService_PullImageAdapterInternal(t *testing.T) {
server := newProjectImagePullServer(t, nil)
dockerSvc := &DockerClientService{client: newTestDockerClient(t, server)}
imageSvc := NewImageService(db, dockerSvc, nil, nil, nil, NewEventService(db, nil, nil))
- svc := NewUpdaterService(db, nil, dockerSvc, nil, nil, nil, nil, imageSvc, nil, nil, nil)
+ svc, svcErr := NewUpdaterService(db, nil, dockerSvc, nil, nil, nil, nil, imageSvc, nil, nil, nil)
+ require.NoError(t, svcErr)
var progress bytes.Buffer
err := svc.PullImage(ctx, "nginx:latest", &progress)
@@ -408,7 +418,8 @@ func TestUpdaterService_PullImageAdapterInternal(t *testing.T) {
envSvc := NewEnvironmentService(db, nil, nil, nil, nil, nil)
projectSvc := NewProjectService(db, nil, nil, nil, nil, nil, nil, nil, nil).
WithRegistryCredentialsProvider(envSvc.GetEnabledRegistryCredentials)
- svc := NewUpdaterService(db, nil, dockerSvc, projectSvc, nil, nil, nil, imageSvc, nil, nil, nil)
+ svc, svcErr := NewUpdaterService(db, nil, dockerSvc, projectSvc, nil, nil, nil, imageSvc, nil, nil, nil)
+ require.NoError(t, svcErr)
var progress bytes.Buffer
err := svc.PullImage(ctx, imageRef, &progress)
@@ -451,7 +462,8 @@ func TestUpdaterService_PendingImageUpdatesAdapterInternal(t *testing.T) {
UpdateType: models.UpdateTypeDigest,
CheckTime: checkTime,
}).Error)
- svc := NewUpdaterService(db, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ svc, svcErr := NewUpdaterService(db, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ require.NoError(t, svcErr)
records, err := svc.PendingImageUpdates(ctx)
@@ -461,7 +473,7 @@ func TestUpdaterService_PendingImageUpdatesAdapterInternal(t *testing.T) {
assert.Equal(t, "registry.example.com/team/app", records[0].Repository)
assert.Equal(t, "1.2.3", records[0].Tag)
assert.True(t, records[0].HasUpdate)
- assert.Equal(t, moduletypes.UpdateTypeTag, records[0].UpdateType)
+ assert.Equal(t, updater.UpdateTypeTag, records[0].UpdateType)
assert.Equal(t, "1.2.3", records[0].CurrentVersion)
assert.Equal(t, &latest, records[0].LatestVersion)
assert.Equal(t, &currentDigest, records[0].CurrentDigest)
@@ -496,7 +508,8 @@ func TestUpdaterService_PendingImageUpdatesFlushesPendingNotificationsInternal(t
notif := NewNotificationService(db, nil, nil, nil)
imageUpdates := NewImageUpdateService(db, nil, nil, nil, nil, notif, nil)
- svc := NewUpdaterService(db, nil, nil, nil, imageUpdates, nil, nil, nil, notif, nil, nil)
+ svc, svcErr := NewUpdaterService(db, nil, nil, nil, imageUpdates, nil, nil, nil, notif, nil, nil)
+ require.NoError(t, svcErr)
require.NoError(t, db.Create(&models.ImageUpdateRecord{
ID: "sha256:pending-unnotified",
@@ -526,7 +539,8 @@ func TestUpdaterService_PendingImageUpdatesNoProvidersLeavesUnnotifiedInternal(t
notif := NewNotificationService(db, nil, nil, nil)
imageUpdates := NewImageUpdateService(db, nil, nil, nil, nil, notif, nil)
- svc := NewUpdaterService(db, nil, nil, nil, imageUpdates, nil, nil, nil, notif, nil, nil)
+ svc, svcErr := NewUpdaterService(db, nil, nil, nil, imageUpdates, nil, nil, nil, notif, nil, nil)
+ require.NoError(t, svcErr)
require.NoError(t, db.Create(&models.ImageUpdateRecord{
ID: "sha256:pending-no-provider",
@@ -549,17 +563,18 @@ func TestUpdaterService_RecordUpdateRunAdapterInternal(t *testing.T) {
ctx := context.Background()
db := setupProjectTestDB(t)
require.NoError(t, db.AutoMigrate(&models.AutoUpdateRecord{}))
- svc := NewUpdaterService(db, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ svc, svcErr := NewUpdaterService(db, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ require.NoError(t, svcErr)
- err := svc.RecordUpdateRun(ctx, moduletypes.ResourceResult{
+ err := svc.RecordUpdateRun(ctx, updater.ResourceResult{
ResourceID: "container-1",
ResourceName: "web",
- ResourceType: moduletypes.ResourceTypeContainer,
- Status: moduletypes.StatusUpdated,
+ ResourceType: updater.ResourceTypeContainer,
+ Status: updater.StatusUpdated,
UpdateAvailable: true,
UpdateApplied: true,
- OldImages: map[string]string{"main": "nginx:1.2.3"},
- NewImages: map[string]string{"main": "nginx:1.2.4"},
+ OldImage: "nginx:1.2.3",
+ NewImage: "nginx:1.2.4",
Details: map[string]any{"source": "test"},
})
@@ -568,7 +583,7 @@ func TestUpdaterService_RecordUpdateRunAdapterInternal(t *testing.T) {
require.NoError(t, db.First(&record, "resource_id = ?", "container-1").Error)
assert.Equal(t, "web", record.ResourceName)
assert.Equal(t, "container", record.ResourceType)
- assert.Equal(t, models.AutoUpdateStatus(moduletypes.StatusUpdated), record.Status)
+ assert.Equal(t, models.AutoUpdateStatus(string(updater.StatusUpdated)), record.Status)
assert.True(t, record.UpdateAvailable)
assert.True(t, record.UpdateApplied)
assert.Equal(t, "nginx:1.2.3", record.OldImageVersions["main"])
@@ -664,7 +679,7 @@ func TestUpdaterService_ApplyPending_ProjectFailureDoesNotBlockOtherProjectsInte
puller := &fakeImagePullerInternal{}
recorder := &fakeRunRecorderInternal{}
projectUpdater := &fakeProjectUpdaterInternal{
- projects: map[string]moduletypes.ComposeProject{
+ projects: map[string]updater.ComposeProject{
"proj-fail": {ID: "project-fail", Name: "proj-fail"},
"proj-success": {ID: "project-success", Name: "proj-success"},
},
@@ -673,26 +688,27 @@ func TestUpdaterService_ApplyPending_ProjectFailureDoesNotBlockOtherProjectsInte
},
}
- svc := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
- svc.engine = moduleapi.NewService(moduleapi.Config{
+ svc, svcErr := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
+ require.NoError(t, svcErr)
+ engine, engineErr := updater.New(updater.Config{
DockerClientProvider: dockerProvider,
ImagePuller: puller,
- PendingStore: moduleapi.NewMemoryPendingStore(
- moduletypes.ImageUpdateRecord{
+ PendingStore: updater.NewMemoryPendingStore(
+ updater.ImageUpdateRecord{
ID: oldImageIDFailed,
Repository: "registry.example.com/team/fail",
Tag: "1.0.0",
HasUpdate: true,
- UpdateType: moduletypes.UpdateTypeTag,
+ UpdateType: updater.UpdateTypeTag,
CurrentVersion: "1.0.0",
LatestVersion: ptr("1.0.1"),
},
- moduletypes.ImageUpdateRecord{
+ updater.ImageUpdateRecord{
ID: oldImageIDUpdated,
Repository: "registry.example.com/team/success",
Tag: "2.0.0",
HasUpdate: true,
- UpdateType: moduletypes.UpdateTypeTag,
+ UpdateType: updater.UpdateTypeTag,
CurrentVersion: "2.0.0",
LatestVersion: ptr("2.0.1"),
},
@@ -704,8 +720,13 @@ func TestUpdaterService_ApplyPending_ProjectFailureDoesNotBlockOtherProjectsInte
oldRefFailed: {},
oldRefUpdated: {},
}},
- LabelPolicy: updaterlabels.DefaultLabelPolicy(),
+ LabelPolicy: updater.DefaultLabelPolicy(),
})
+ require.NoError(t, engineErr)
+ t.Cleanup(func() {
+ require.NoError(t, engine.Close())
+ })
+ svc.engine = engine
result, err := svc.ApplyPending(ctx, arcaneupdater.Options{})
require.NoError(t, err)
@@ -723,16 +744,16 @@ func TestUpdaterService_ApplyPending_ProjectFailureDoesNotBlockOtherProjectsInte
errorByResource[item.ResourceID] = item.Error
}
- assert.Equal(t, moduletypes.StatusFailed, statusByResource["container-fail"])
+ assert.Equal(t, string(updater.StatusFailed), statusByResource["container-fail"])
assert.Contains(t, errorByResource["container-fail"], "project-level update failed")
- assert.Equal(t, moduletypes.StatusUpdated, statusByResource["container-success"])
+ assert.Equal(t, string(updater.StatusUpdated), statusByResource["container-success"])
- var recordedStatuses []string
+ var recordedStatuses []updater.ResourceStatus
for _, recorded := range recorder.results {
recordedStatuses = append(recordedStatuses, recorded.Status)
}
- assert.Contains(t, recordedStatuses, moduletypes.StatusFailed)
- assert.Contains(t, recordedStatuses, moduletypes.StatusUpdated)
+ assert.Contains(t, recordedStatuses, updater.StatusFailed)
+ assert.Contains(t, recordedStatuses, updater.StatusUpdated)
}
func TestUpdaterService_ApplyPending_RoutesLegacyArcaneServerThroughSelfUpgradeInternal(t *testing.T) {
@@ -743,9 +764,9 @@ func TestUpdaterService_ApplyPending_RoutesLegacyArcaneServerThroughSelfUpgradeI
oldImageID := "sha256:old-arcane"
newImageID := "sha256:new-arcane"
arcaneLabels := map[string]string{
- "com.docker.compose.project": "arcane",
- "com.docker.compose.service": "server",
- updaterlabels.LabelArcaneLegacyServer: "true",
+ "com.docker.compose.project": "arcane",
+ "com.docker.compose.service": "server",
+ labels.LabelArcaneLegacyServer: "true",
}
containers := []container.Summary{
@@ -792,22 +813,23 @@ func TestUpdaterService_ApplyPending_RoutesLegacyArcaneServerThroughSelfUpgradeI
dockerProvider := fakeDockerClientProviderInternal{client: newTestDockerClient(t, server)}
puller := &fakeImagePullerInternal{}
projectUpdater := &fakeProjectUpdaterInternal{
- projects: map[string]moduletypes.ComposeProject{
+ projects: map[string]updater.ComposeProject{
"arcane": {ID: "project-arcane", Name: "arcane"},
},
}
mockUpgrade := &mockSystemUpgradeServiceInternal{}
- svc := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, mockUpgrade, nil)
- svc.engine = moduleapi.NewService(moduleapi.Config{
+ svc, svcErr := NewUpdaterService(nil, nil, nil, nil, nil, nil, nil, nil, nil, mockUpgrade, nil)
+ require.NoError(t, svcErr)
+ engine, engineErr := updater.New(updater.Config{
DockerClientProvider: dockerProvider,
ImagePuller: puller,
- PendingStore: moduleapi.NewMemoryPendingStore(moduletypes.ImageUpdateRecord{
+ PendingStore: updater.NewMemoryPendingStore(updater.ImageUpdateRecord{
ID: oldImageID,
Repository: "ghcr.io/getarcaneapp/arcane",
Tag: "1.0.0",
HasUpdate: true,
- UpdateType: moduletypes.UpdateTypeTag,
+ UpdateType: updater.UpdateTypeTag,
CurrentVersion: "1.0.0",
LatestVersion: ptr("1.0.1"),
}),
@@ -817,8 +839,13 @@ func TestUpdaterService_ApplyPending_RoutesLegacyArcaneServerThroughSelfUpgradeI
UsedImageCollector: fakeUsedImageCollectorInternal{images: map[string]struct{}{
oldRef: {},
}},
- LabelPolicy: updaterlabels.DefaultLabelPolicy(),
+ LabelPolicy: updater.DefaultLabelPolicy(),
+ })
+ require.NoError(t, engineErr)
+ t.Cleanup(func() {
+ require.NoError(t, engine.Close())
})
+ svc.engine = engine
result, err := svc.ApplyPending(ctx, arcaneupdater.Options{})
require.NoError(t, err)
@@ -827,36 +854,34 @@ func TestUpdaterService_ApplyPending_RoutesLegacyArcaneServerThroughSelfUpgradeI
assert.Empty(t, projectUpdater.calls, "legacy Arcane server should not be updated through project services")
}
-func TestResolvePullableImageRefInternal(t *testing.T) {
+// The engine picks the reference Arcane's updates are applied to, so its choice
+// is worth pinning here as well as in the library.
+func TestPullableImageRefInternal(t *testing.T) {
tests := []struct {
- name string
- summaryImage string
- inspectImage string
- repoTags []string
- expectedRef string
- expectedSource string
+ name string
+ summaryImage string
+ inspectImage string
+ repoTags []string
+ expectedRef string
}{
{
- name: "inspect config image wins",
- summaryImage: "nginx:latest",
- inspectImage: "registry.example.com/nginx:stable",
- expectedRef: "registry.example.com/nginx:stable",
- expectedSource: "container_inspect_config",
+ name: "inspect config image wins",
+ summaryImage: "nginx:latest",
+ inspectImage: "registry.example.com/nginx:stable",
+ expectedRef: "registry.example.com/nginx:stable",
},
{
- name: "summary image used when inspect is image ID",
- summaryImage: "redis:7",
- inspectImage: "sha256:abcdef",
- expectedRef: "redis:7",
- expectedSource: "container_summary",
+ name: "summary image used when inspect is image ID",
+ summaryImage: "redis:7",
+ inspectImage: "sha256:abcdef",
+ expectedRef: "redis:7",
},
{
- name: "repo tag fallback skips none tag",
- summaryImage: "sha256:abcdef",
- inspectImage: "sha256:abcdef",
- repoTags: []string{"<none>:<none>", "postgres:16"},
- expectedRef: "postgres:16",
- expectedSource: "image_repo_tag",
+ name: "repo tag fallback skips none tag",
+ summaryImage: "sha256:abcdef",
+ inspectImage: "sha256:abcdef",
+ repoTags: []string{"<none>:<none>", "postgres:16"},
+ expectedRef: "postgres:16",
},
{
name: "no pullable ref",
@@ -868,9 +893,7 @@ func TestResolvePullableImageRefInternal(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- gotRef, gotSource := moduleapi.ResolvePullableImageRef(tt.summaryImage, tt.inspectImage, tt.repoTags)
- assert.Equal(t, tt.expectedRef, gotRef)
- assert.Equal(t, tt.expectedSource, gotSource)
+ assert.Equal(t, tt.expectedRef, refs.PullableImageRef(tt.summaryImage, tt.inspectImage, tt.repoTags))
})
}
}
diff --git a/backend/internal/services/version_service.go b/backend/internal/services/version_service.go
index 617ab5033..f8785f048 100644
--- a/backend/internal/services/version_service.go
+++ b/backend/internal/services/version_service.go
@@ -23,7 +23,7 @@ import (
"github.com/getarcaneapp/arcane/types/v2/version"
"github.com/samber/hot"
"go.getarcane.app/sys/cgroup"
- libupdater "go.getarcane.app/updater/pkg/labels"
+ "go.getarcane.app/updater/labels"
)
const (
@@ -399,7 +399,7 @@ func (s *VersionService) detectContainerID(ctx context.Context, dockerClient *cl
// findArcaneContainerByLabel searches for the Arcane container using labels
func (s *VersionService) findArcaneContainerByLabel(ctx context.Context, dockerClient *client.Client) string {
f := make(client.Filters)
- f = f.Add("label", libupdater.LabelArcane+"=true")
+ f = f.Add("label", labels.LabelArcane+"=true")
list, err := dockerClient.ContainerList(ctx, client.ContainerListOptions{All: true, Filters: f})
if err != nil {
slog.Debug("findArcaneContainerByLabel: failed to list containers", "error", err)
@@ -495,7 +495,7 @@ func (s *VersionService) checkDigestBasedUpdate(ctx context.Context, currentTag,
imageRef := fmt.Sprintf("%s:%s", currentImageRef, currentTag)
// Fetch latest digest from registry
- latestDigest, err := s.containerRegistryService.GetImageDigest(ctx, imageRef)
+ latestDigest, err := s.containerRegistryService.ImageDigest(ctx, imageRef)
if err != nil {
slog.WarnContext(ctx, "Failed to fetch latest digest for tag", "tag", currentTag, "error", err)
return false, ""
diff --git a/backend/internal/services/version_service_test.go b/backend/internal/services/version_service_test.go
index af95b3d0c..5f48902d8 100644
--- a/backend/internal/services/version_service_test.go
+++ b/backend/internal/services/version_service_test.go
@@ -17,7 +17,7 @@ import (
"github.com/opencontainers/go-digest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
- libupdater "go.getarcane.app/updater/pkg/labels"
+ "go.getarcane.app/updater/labels"
)
func TestVersionService_GetAppVersionInfoDoesNotUseStoredDigestUpdateForSemverBuildInternal(t *testing.T) {
@@ -41,7 +41,7 @@ func TestVersionService_GetAppVersionInfoDoesNotUseStoredDigestUpdateForSemverBu
ID: containerID,
State: container.StateRunning,
Labels: map[string]string{
- libupdater.LabelArcane: "true",
+ labels.LabelArcane: "true",
},
},
}))
@@ -53,7 +53,7 @@ func TestVersionService_GetAppVersionInfoDoesNotUseStoredDigestUpdateForSemverBu
Config: &container.Config{
Image: imageRef,
Labels: map[string]string{
- libupdater.LabelArcane: "true",
+ labels.LabelArcane: "true",
},
},
}))
diff --git a/backend/internal/services/vulnerability_service.go b/backend/internal/services/vulnerability_service.go
index cafdd87fe..59ceeb483 100644
--- a/backend/internal/services/vulnerability_service.go
+++ b/backend/internal/services/vulnerability_service.go
@@ -43,7 +43,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/pkg/utils"
"github.com/getarcaneapp/arcane/types/v2/vulnerability"
"go.getarcane.app/sys/cgroup"
- libupdater "go.getarcane.app/updater/pkg/labels"
+ "go.getarcane.app/updater/labels"
)
const (
@@ -1848,7 +1848,7 @@ func findArcaneContainerByLabelInternal(ctx context.Context, dockerClient *clien
}
filters := make(client.Filters)
- filters = filters.Add("label", libupdater.LabelArcane+"=true")
+ filters = filters.Add("label", labels.LabelArcane+"=true")
containerList, err := dockerClient.ContainerList(ctx, client.ContainerListOptions{
All: true,
diff --git a/cli/go.mod b/cli/go.mod
index dd39a2423..ef32feb6f 100644
--- a/cli/go.mod
+++ b/cli/go.mod
@@ -48,7 +48,7 @@ require (
github.com/felixge/httpsnoop v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/go-logfmt/logfmt v0.6.1 // indirect
- github.com/go-logr/logr v1.4.3 // indirect
+ github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
@@ -70,10 +70,10 @@ require (
github.com/pelletier/go-toml/v2 v2.3.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
- github.com/prometheus/client_golang v1.23.2 // indirect
+ github.com/prometheus/client_golang v1.24.1 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
- github.com/prometheus/common v0.67.5 // indirect
- github.com/prometheus/procfs v0.20.1 // indirect
+ github.com/prometheus/common v0.70.1 // indirect
+ github.com/prometheus/procfs v0.21.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/sahilm/fuzzy v0.1.3 // indirect
@@ -90,7 +90,6 @@ require (
go.opentelemetry.io/otel/metric v1.44.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
- go.yaml.in/yaml/v2 v2.4.4 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
go.yaml.in/yaml/v4 v4.0.0-rc.6 // indirect
golang.org/x/exp v0.0.0-20260603202125-055de637280b // indirect
diff --git a/cli/go.sum b/cli/go.sum
index d40222d21..322416183 100644
--- a/cli/go.sum
+++ b/cli/go.sum
@@ -74,8 +74,8 @@ github.com/getarcaneapp/arcane/types/v2 v2.5.0/go.mod h1:jjLII+bNg5vqP2edUt3tKg6
github.com/go-logfmt/logfmt v0.6.1 h1:4hvbpePJKnIzH1B+8OR/JPbTx37NktoI9LE2QZBBkvE=
github.com/go-logfmt/logfmt v0.6.1/go.mod h1:EV2pOAQoZaT1ZXZbqDl5hrymndi4SY9ED9/z6CO0XAk=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
-github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
-github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
+github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
+github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=
@@ -134,14 +134,14 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/prometheus/client_golang v1.23.2 h1:Je96obch5RDVy3FDMndoUsjAhG5Edi49h0RJWRi/o0o=
-github.com/prometheus/client_golang v1.23.2/go.mod h1:Tb1a6LWHB3/SPIzCoaDXI4I8UHKeFTEQ1YCr+0Gyqmg=
+github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU=
+github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE=
github.com/prometheus/client_model v0.6.2 h1:oBsgwpGs7iVziMvrGhE53c/GrLUsZdHnqNwqPLxwZyk=
github.com/prometheus/client_model v0.6.2/go.mod h1:y3m2F6Gdpfy6Ut/GBsUqTWZqCUvMVzSfMLjcu6wAwpE=
-github.com/prometheus/common v0.67.5 h1:pIgK94WWlQt1WLwAC5j2ynLaBRDiinoAb86HZHTUGI4=
-github.com/prometheus/common v0.67.5/go.mod h1:SjE/0MzDEEAyrdr5Gqc6G+sXI67maCxzaT3A2+HqjUw=
-github.com/prometheus/procfs v0.20.1 h1:XwbrGOIplXW/AU3YhIhLODXMJYyC1isLFfYCsTEycfc=
-github.com/prometheus/procfs v0.20.1/go.mod h1:o9EMBZGRyvDrSPH1RqdxhojkuXstoe4UlK79eF5TGGo=
+github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY=
+github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc=
+github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
+github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
diff --git a/frontend/src/lib/components/arcane-button/variants.ts b/frontend/src/lib/components/arcane-button/variants.ts
index f26108914..705fab803 100644
--- a/frontend/src/lib/components/arcane-button/variants.ts
+++ b/frontend/src/lib/components/arcane-button/variants.ts
@@ -83,6 +83,10 @@ export const arcaneButtonVariants = tv({
'bg-violet-500/5 text-foreground! border-violet-500/20 hover:bg-violet-500/10 hover:border-violet-500/40 ' +
'dark:bg-violet-500/10 dark:text-violet-300 dark:border-violet-500/30 dark:hover:bg-violet-500/20 ' +
'shadow-sm hover:shadow-md',
+ 'outline-sync':
+ 'bg-purple-500/5 text-foreground! border-purple-500/20 hover:bg-purple-500/10 hover:border-purple-500/40 ' +
+ 'dark:bg-purple-500/10 dark:text-purple-300 dark:border-purple-500/30 dark:hover:bg-purple-500/20 ' +
+ 'shadow-sm hover:shadow-md',
'outline-archive':
'bg-slate-500/5 text-foreground! border-slate-500/20 hover:bg-slate-500/10 hover:border-slate-500/40 ' +
'dark:bg-slate-500/10 dark:text-slate-300 dark:border-slate-500/30 dark:hover:bg-slate-500/20 ' +
@@ -248,6 +252,12 @@ export const actionConfigs = {
tone: 'outline-primary',
loadingLabel: m.common_refresh()
},
+ sync: {
+ defaultLabel: m.resource_sync_cap(),
+ IconComponent: RefreshIcon,
+ tone: 'outline-sync',
+ loadingLabel: m.common_syncing()
+ },
inspect: {
defaultLabel: m.common_inspect(),
IconComponent: InspectIcon,
diff --git a/frontend/src/routes/(app)/environments/[id]/+page.svelte b/frontend/src/routes/(app)/environments/[id]/+page.svelte
index 336e7ee05..fd5624cfa 100644
--- a/frontend/src/routes/(app)/environments/[id]/+page.svelte
+++ b/frontend/src/routes/(app)/environments/[id]/+page.svelte
@@ -37,7 +37,6 @@
import {
ArrowLeftIcon,
AlertIcon,
- RefreshIcon,
DockerBrandIcon,
SecurityIcon,
GitBranchIcon,
@@ -107,16 +106,6 @@
}
if (environment.id !== '0') {
- actions.push({
- id: 'sync',
- action: 'base',
- label: m.resource_sync_cap(),
- onclick: syncEnvironment,
- disabled: isSyncing,
- loading: isSyncing,
- icon: RefreshIcon
- });
-
// Edge environments manage mTLS downloads and API key regeneration in the Connection & Edge tab.
if (!runtimeEnvironment.isEdge) {
actions.push({
@@ -603,7 +592,7 @@
</div>
<div class="flex min-w-0 flex-col items-start gap-3 sm:items-end">
- <div class="hidden flex-wrap items-center gap-2 self-start sm:flex sm:self-end">
+ <div class="flex flex-wrap items-center gap-2 self-start sm:self-end">
{#if settingsForm.hasChanges}
<span class="text-xs text-orange-600 dark:text-orange-400">{m.common_unsaved_changes()}</span>
{:else}
@@ -632,6 +621,10 @@
<ArcaneButton action="test" onclick={testConnection} disabled={isTestingConnection} loading={isTestingConnection} />
<ArcaneButton action="refresh" onclick={refreshEnvironment} disabled={isRefreshing} loading={isRefreshing} />
+
+ {#if environment.id !== '0'}
+ <ArcaneButton action="sync" onclick={syncEnvironment} disabled={isSyncing} loading={isSyncing} />
+ {/if}
</div>
</div>
</div>
diff --git a/go.work.sum b/go.work.sum
index c210ab706..4a695cf2e 100644
--- a/go.work.sum
+++ b/go.work.sum
@@ -1035,6 +1035,8 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
+github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
+github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
@@ -1741,6 +1743,8 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
github.com/prometheus/client_golang v1.20.4/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE=
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
+github.com/prometheus/client_golang v1.24.1 h1:JnJkREXzWxUdCuPFpIWZiPispT9xVV59uiuyR2bPlnU=
+github.com/prometheus/client_golang v1.24.1/go.mod h1:F+oSRECHg4sse5ucfYpYDeIv/hu68Zo0uoHKetWnzcE=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -1749,6 +1753,8 @@ github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
+github.com/prometheus/common v0.70.1 h1:1HvjP4D5oL3t8RsPlwxA9onvvStjtIHYE5XuuwOi/PY=
+github.com/prometheus/common v0.70.1/go.mod h1:VdFUQDMZK3VLkurFUVhia6uys/0suUp86TJz5qbJRhc=
github.com/prometheus/otlptranslator v0.0.2 h1:+1CdeLVrRQ6Psmhnobldo0kTp96Rj80DRXRd5OSnMEQ=
github.com/prometheus/otlptranslator v0.0.2/go.mod h1:P8AwMgdD7XEr6QRUJ2QWLpiAZTgTE2UYgjlu3svompI=
github.com/prometheus/otlptranslator v1.0.0 h1:s0LJW/iN9dkIH+EnhiD3BlkkP5QVIUVEoIwkU+A6qos=
@@ -1761,6 +1767,9 @@ github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoG
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/prometheus/procfs v0.17.0/go.mod h1:oPQLaDAMRbA+u8H5Pbfq+dl3VDAvHxMUOVhe0wYB2zw=
github.com/prometheus/procfs v0.19.2/go.mod h1:M0aotyiemPhBCM0z5w87kL22CxfcH05ZpYlu+b4J7mw=
+github.com/prometheus/procfs v0.21.0/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
+github.com/prometheus/procfs v0.21.1 h1:GljZCt+zSTS+NZq88cyQ1LjZ+RCHp3uVuabBWA5+OJI=
+github.com/prometheus/procfs v0.21.1/go.mod h1:aB55Cww9pdSJVHk0hUf0inxWyyjPogFIjmHKYgMKmtY=
github.com/prometheus/prometheus v0.51.0 h1:aRdjTnmHLved29ILtdzZN2GNvOjWATtA/z+3fYuexOc=
github.com/prometheus/prometheus v0.51.0/go.mod h1:yv4MwOn3yHMQ6MZGHPg/U7Fcyqf+rxqiZfSur6myVtc=
github.com/pseudomuto/protoc-gen-doc v1.5.1 h1:Ah259kcrio7Ix1Rhb6u8FCaOkzf9qRBqXnvAufg061w=
@@ -2110,12 +2119,12 @@ go.etcd.io/gofail v0.2.0 h1:p19drv16FKK345a09a1iubchlw/vmRuksmRzgBIGjcA=
go.etcd.io/gofail v0.2.0/go.mod h1:nL3ILMGfkXTekKI3clMBNazKnjUZjYLKmBHzsVAnC1o=
go.etcd.io/raft/v3 v3.6.0 h1:5NtvbDVYpnfZWcIHgGRk9DyzkBIXOi8j+DDp1IcnUWQ=
go.etcd.io/raft/v3 v3.6.0/go.mod h1:nLvLevg6+xrVtHUmVaTcTz603gQPHfh7kUAwV6YpfGo=
-go.getarcane.app/builds v0.3.0 h1:6fCgHy6PaEr3LpCtiF1iCdT4nuV3D3xvUHnV+E/0cqk=
-go.getarcane.app/builds v0.3.0/go.mod h1:yZJDSh9XX/sgZlwx7lghHEucgZeQ74Gr/Fx+XdR2bdk=
go.getarcane.app/updater v0.3.6 h1:+BqoycaRsHj+cLVSzcYQuqbHxUKbtmaozMNblz5bVSw=
go.getarcane.app/updater v0.3.6/go.mod h1:2ENitZR/lA5MuBn60OZYR5wvU3ZCE+pAgfrebfOlRDA=
go.getarcane.app/updater v0.3.7 h1:WqHsxudvt8gvCR7iSHdxdzwH0+hM0FAh64bSypBX9Mo=
go.getarcane.app/updater v0.3.7/go.mod h1:9RZOKaBbpUJfVA4Q9/jvqtjvWBwCnVw0OkPeQCnqAAo=
+go.getarcane.app/updater v0.7.0 h1:Rd6qJGtdJrMJ8SxfGpuP1+ZpJ604BNnhYb9UsB6O0Mg=
+go.getarcane.app/updater v0.7.0/go.mod h1:6b8zVFJEUMhLzDOi4jwKBA/GmbVgguv0FeGOoO67JW8=
go.mongodb.org/mongo-driver v1.7.5 h1:ny3p0reEpgsR2cfA5cjgwFZg3Cv/ofFh/8jbhGtz9VI=
go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng=
go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUpsss=
@@ -2371,6 +2380,7 @@ golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
+golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -2430,6 +2440,7 @@ golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/sys v0.43.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/sys v0.44.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
+golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8 h1:LvzTn0GQhWuvKH/kVRS3R3bVAsdQWI7hvfLHGgh9+lU=
golang.org/x/telemetry v0.0.0-20251008203120-078029d740a8/go.mod h1:Pi4ztBfryZoJEkyFTI5/Ocsu2jXyDr6iSdgJiYE/uwE=
diff --git a/types/go.mod b/types/go.mod
index 668fa792e..b638b4293 100644
--- a/types/go.mod
+++ b/types/go.mod
@@ -19,7 +19,7 @@ require (
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-connections v0.7.0 // indirect
github.com/felixge/httpsnoop v1.1.0 // indirect
- github.com/go-logr/logr v1.4.3 // indirect
+ github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/mattn/go-shellwords v1.0.13 // indirect
diff --git a/types/go.sum b/types/go.sum
index 8e3e1a1b9..cab445fb3 100644
--- a/types/go.sum
+++ b/types/go.sum
@@ -23,8 +23,8 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD
github.com/felixge/httpsnoop v1.1.0 h1:3YtUj32ZZkqZtt3sZZsClsymw/QDuVfpNhoA31zeORc=
github.com/felixge/httpsnoop v1.1.0/go.mod h1:Zqxgdd+1Rkcz8euOqdr7lqgCRJztwr5hp9vDSi5UZCE=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
-github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
-github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
+github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8=
+github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPEgAXnvj1Ro=