Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: honor update-check in x-arcane compose metadata (#4457)
Kyle Mendellaa5e3862de26
diff --git a/backend/pkg/projects/custom_labels.go b/backend/pkg/projects/custom_labels.goindex d3d9836ea..7aecef1f5 100644--- a/backend/pkg/projects/custom_labels.go+++ b/backend/pkg/projects/custom_labels.go@@ -22,6 +22,7 @@ import ("github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane""github.com/getarcaneapp/arcane/backend/v2/pkg/utils/iconcatalog"+ "github.com/getarcaneapp/arcane/backend/v2/pkg/utils/imageref")const (@@ -518,58 +519,65 @@ func NormalizeProjectTagColor(color projecttypes.TagColor) (projecttypes.TagColoreturn normalized, nil}-// applyServiceLabelMetadataInternal translates Compose metadata into the labels the+// applyServiceLabelMetadata translates Compose metadata into the labels the// services consume, before previews or deployment use the model.-func applyServiceLabelMetadataInternal(project *composetypes.Project) error {- defaults, err := updaterMetadataLabelsInternal(project.Extensions[arcaneBlockKey])- if err != nil {- return fmt.Errorf("x-arcane.updater: %w", err)+func applyServiceLabelMetadata(project *composetypes.Project) error {+ blockLabels := func(block any) (map[string]string, error) {+ labels, err := updaterMetadataLabels(block)+ if err != nil {+ return nil, fmt.Errorf("x-arcane.updater: %w", err)+ }+ arcane, _ := kit.AsStringMap(block)+ for _, metadata := range []struct {+ key string+ label string+ }{+ {key: "hidden", label: libarcane.HiddenResourceLabel},+ {key: "update-check", label: imageref.UpdateCheckLabel},+ } {+ value, present := arcane[metadata.key]+ if !present {+ continue+ }+ enabled, boolErr := metadataBool(value)+ if boolErr != nil {+ return nil, fmt.Errorf("x-arcane.%s: %w", metadata.key, boolErr)+ }+ labels[metadata.label] = strconv.FormatBool(enabled)+ }+ return labels, nil}- hiddenDefaults, err := hiddenMetadataLabelInternal(project.Extensions[arcaneBlockKey])++ defaults, err := blockLabels(project.Extensions[arcaneBlockKey])if err != nil {- return fmt.Errorf("x-arcane.hidden: %w", err)- }- if defaults == nil {- defaults = map[string]string{}+ return err}- maps.Copy(defaults, hiddenDefaults)for name, service := range project.Services {- overrides, updaterMetadataLabelsErr := updaterMetadataLabelsInternal(service.Extensions[arcaneBlockKey])- if updaterMetadataLabelsErr != nil {- return fmt.Errorf("service %s x-arcane.updater: %w", name, updaterMetadataLabelsErr)- }- effective := maps.Clone(defaults)- hiddenOverrides, updaterMetadataLabelsErr := hiddenMetadataLabelInternal(service.Extensions[arcaneBlockKey])- if updaterMetadataLabelsErr != nil {- return fmt.Errorf("service %s x-arcane.hidden: %w", name, updaterMetadataLabelsErr)- }- maps.Copy(effective, overrides)- maps.Copy(effective, hiddenOverrides)- if len(effective) == 0 {- continue+ overrides, overridesErr := blockLabels(service.Extensions[arcaneBlockKey])+ if overridesErr != nil {+ return fmt.Errorf("service %s %w", name, overridesErr)}- service.Labels = maps.Clone(service.Labels)- if service.Labels == nil {- service.Labels = composetypes.Labels{}- }- for key, value := range effective {- if _, explicit := service.Labels[key]; !explicit {- service.Labels[key] = value- }+ if len(defaults)+len(overrides) == 0 {+ continue}+ labels := composetypes.Labels{}+ maps.Copy(labels, defaults)+ maps.Copy(labels, overrides)+ maps.Copy(labels, service.Labels)+ service.Labels = labelsproject.Services[name] = service}return nil}-func updaterMetadataLabelsInternal(block any) (map[string]string, error) {+func updaterMetadataLabels(block any) (map[string]string, error) {arcane, ok := kit.AsStringMap(block)if !ok {- return nil, nil+ return map[string]string{}, nil}raw, present := arcane["updater"]if !present {- return nil, nil+ return map[string]string{}, nil}config, ok := kit.AsStringMap(raw)if !ok {@@ -578,7 +586,7 @@ func updaterMetadataLabelsInternal(block any) (map[string]string, error) {result := make(map[string]string, len(config))for key, value := range config {if key == "enabled" {- enabled, err := metadataBoolInternal(value)+ enabled, err := metadataBool(value)if err != nil {return nil, err}@@ -609,23 +617,7 @@ func updaterMetadataLabelsInternal(block any) (map[string]string, error) {return result, nil}-func hiddenMetadataLabelInternal(block any) (map[string]string, error) {- arcane, ok := kit.AsStringMap(block)- if !ok {- return nil, nil- }- value, present := arcane["hidden"]- if !present {- return nil, nil- }- hidden, err := metadataBoolInternal(value)- if err != nil {- return nil, err- }- return map[string]string{libarcane.HiddenResourceLabel: strconv.FormatBool(hidden)}, nil-}--func metadataBoolInternal(value any) (bool, error) {+func metadataBool(value any) (bool, error) {if enabled, ok := value.(bool); ok {return enabled, nil}diff --git a/backend/pkg/projects/custom_labels_test.go b/backend/pkg/projects/custom_labels_test.goindex 12a277969..fd709c402 100644--- a/backend/pkg/projects/custom_labels_test.go+++ b/backend/pkg/projects/custom_labels_test.go@@ -10,6 +10,8 @@ import (projecttypes "github.com/getarcaneapp/arcane/types/v2/project""github.com/stretchr/testify/require"updaterlabels "go.getarcane.app/updater/labels"++ "github.com/getarcaneapp/arcane/backend/v2/pkg/utils/imageref")func TestParseArcaneComposeMetadata_InterpolationAndAnchor(t *testing.T) {@@ -278,6 +280,62 @@ func TestUpdaterMetadataValidationInternal(t *testing.T) {}}+func TestUpdateCheckMetadataLabels(t *testing.T) {+ const content = `x-arcane:+ update-check: false+services:+ inherited:+ image: alpine:3.20.0+ overridden:+ image: alpine:3.20.0+ x-arcane:+ update-check: true+ explicit:+ image: alpine:3.20.0+ labels:+ com.getarcaneapp.arcane.update-check: "true"+`+ dir := t.TempDir()+ path := filepath.Join(dir, "compose.yaml")+ require.NoError(t, os.WriteFile(path, []byte(content), 0o600))+ disk, err := LoadComposeProject(t.Context(), path, "metadata", dir, false, nil, nil, nil, false, nil, nil, nil)+ require.NoError(t, err)+ memory, err := LoadComposeProjectFromContent(+ t.Context(),+ projecttypes.ComposeContentOptions{+ ComposeContent: content,+ WorkingDir: dir,+ ProjectName: "metadata",+ },+ )+ require.NoError(t, err)+ for _, project := range []*composetypes.Project{disk, memory} {+ require.Equal(t, "false", project.Services["inherited"].Labels[imageref.UpdateCheckLabel])+ require.Equal(t, "true", project.Services["overridden"].Labels[imageref.UpdateCheckLabel])+ require.Equal(t, "true", project.Services["explicit"].Labels[imageref.UpdateCheckLabel])+ }+}++func TestUpdateCheckMetadataValidation(t *testing.T) {+ for _, content := range []string{+ "services:\n app:\n image: alpine:3.20.0\nx-arcane:\n update-check: maybe\n",+ "services:\n app:\n image: alpine:3.20.0\n x-arcane:\n update-check: maybe\n",+ } {+ t.Run(content, func(t *testing.T) {+ _, err := LoadComposeProjectFromContent(+ t.Context(),+ projecttypes.ComposeContentOptions{+ ComposeContent: content,+ WorkingDir: t.TempDir(),+ ProjectName: "metadata",+ },+ )+ require.Error(t, err)+ require.Contains(t, err.Error(), "update-check")+ })+ }+}+func TestUpdaterMetadataInterpolationAndIncludesInternal(t *testing.T) {dir := t.TempDir()require.NoError(t, os.WriteFile(filepath.Join(dir, ".env"), []byte("UPDATE_RANGE=3.20.x\nUPDATE_ENABLED=false\n"), 0o600))diff --git a/backend/pkg/projects/load.go b/backend/pkg/projects/load.goindex 786afc449..bb069dcd4 100644--- a/backend/pkg/projects/load.go+++ b/backend/pkg/projects/load.go@@ -488,7 +488,7 @@ func finishLoadedProjectInternal(ctx context.Context,prepare PrepareProjectFunc) (*composetypes.Project,error,) {- if err := applyServiceLabelMetadataInternal(project); err != nil {+ if err := applyServiceLabelMetadata(project); err != nil {return nil, err}project = project.WithoutUnnecessaryResources()diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex 9e92eda21..cd15ed0d0 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -2,6 +2,8 @@"hidden": "Hidden","editor_compose_hidden_detail": "Hide from container list","editor_compose_hidden_info": "Boolean. Hidden containers are excluded from dashboard counts and hidden from the container list by default. Enable \"Show hidden containers\" to reveal them in the list. The project-level value is the default for every service; service-level values override it.",+ "editor_compose_update_check_detail": "Enable update checks",+ "editor_compose_update_check_info": "Boolean. When false, Arcane skips update checks and update notifications for the service's image. Automatic installation is controlled separately by updater.enabled. The project-level value is the default for every service; service-level values override it.","$schema": "https://inlang.com/schema/inlang-message-format","layout_title": "Arcane","accent_color": "Accent Color",@@ -3799,7 +3801,7 @@"editor_compose_updater_detail": "Image update policy","editor_compose_updater_info": "Project defaults apply to all services. Service updater fields override project defaults. Explicit updater labels take precedence for each field.","editor_compose_updater_enabled_detail": "Enable image updates",- "editor_compose_updater_enabled_info": "Boolean. Set to false to disable image updates for the affected services.",+ "editor_compose_updater_enabled_info": "Boolean. Set to false to disable automatic update installation for the affected services. This does not stop update checks; use update-check: false for that.","editor_compose_updater_strategy_detail": "Update strategy","editor_compose_updater_strategy_info": "Defaults to digest: the configured tag is kept and only its image digest is followed. Set auto to let complete stable semantic version tags follow newer eligible tags, or tag to require version-based selection. A constraint or tag-pattern without a strategy also enables version-based selection.","editor_compose_updater_constraint_detail": "Version constraint",diff --git a/frontend/src/lib/components/code-editor/analysis/compose-schema.ts b/frontend/src/lib/components/code-editor/analysis/compose-schema.tsindex 4ac052379..9fb93346d 100644--- a/frontend/src/lib/components/code-editor/analysis/compose-schema.ts+++ b/frontend/src/lib/components/code-editor/analysis/compose-schema.ts@@ -72,6 +72,15 @@ const ARCANE_BLOCK_COMPLETIONS: ArcaneCompletionSpec[] = [label: 'tags',detail: 'Arcane project tags',info: 'A tag or list of tags used to group and filter projects. Compose-defined tags are read-only in Arcane.'+ },+ {+ label: 'update-check',+ get detail() {+ return m.editor_compose_update_check_detail();+ },+ get info() {+ return m.editor_compose_update_check_info();+ }}];@@ -107,6 +116,15 @@ const ARCANE_SERVICE_BLOCK_COMPLETIONS: ArcaneCompletionSpec[] = [label: 'icon-dark',detail: 'Arcane service icon for light theme',info: 'Dark service icon URL or catalog slug used in light theme.'+ },+ {+ label: 'update-check',+ get detail() {+ return m.editor_compose_update_check_detail();+ },+ get info() {+ return m.editor_compose_update_check_info();+ }}];@@ -380,6 +398,12 @@ const ARCANE_SCHEMA_DOCS: Record<string, SchemaDoc> = {return m.editor_compose_hidden_info();}},+ 'x-arcane.update-check': {+ title: 'x-arcane.update-check',+ get description() {+ return m.editor_compose_update_check_info();+ }+ },'x-arcane.urls': {title: 'x-arcane.urls',description: 'Additional project URLs (for example docs, homepage, or dashboards).'@@ -408,6 +432,8 @@ function getServiceArcaneSchemaDoc(path: Array<string | number>): SchemaDoc | nuif (path.length === 3) return ARCANE_SCHEMA_DOCS['services.<name>.x-arcane'] ?? null;if (path.length === 4 && path[3] === 'hidden')return { ...ARCANE_SCHEMA_DOCS['x-arcane.hidden'], title: 'services.<name>.x-arcane.hidden' };+ if (path.length === 4 && path[3] === 'update-check')+ return { ...ARCANE_SCHEMA_DOCS['x-arcane.update-check'], title: 'services.<name>.x-arcane.update-check' };if (path.length !== 4 || !['icon', 'icon-light', 'icon-dark'].includes(String(path[3]))) return null;return {title: `services.<name>.x-arcane.${String(path[3])}`,@@ -439,7 +465,10 @@ function getArcaneSchemaDocForPath(path: Array<string | number>): SchemaDoc | nuif (isServiceArcanePath(path.slice(0, 3))) return getServiceArcaneSchemaDoc(path);if (path[0] !== 'x-arcane') return null;if (path.length === 1) return ARCANE_SCHEMA_DOCS['x-arcane'] ?? null;- if (path.length === 2 && ['icon', 'icon-light', 'icon-dark', 'urls', 'tags', 'hidden'].includes(String(path[1])))+ if (+ path.length === 2 &&+ ['icon', 'icon-light', 'icon-dark', 'urls', 'tags', 'hidden', 'update-check'].includes(String(path[1]))+ )return ARCANE_SCHEMA_DOCS[`x-arcane.${path[1]}`] ?? null;if (path.length === 4 && path[1] === 'tags' && typeof path[2] === 'number') {return ARCANE_SCHEMA_DOCS[`x-arcane.tags[].${String(path[3])}`] ?? null;@@ -545,8 +574,8 @@ export function getCompletionOptionsForPath(export function getEnumValueCompletions(schema: SchemaObject | null, path: Array<string | number>): Completion[] {const values = new Set<string>();if (- (path.length === 2 && path[0] === 'x-arcane' && path[1] === 'hidden') ||- (path.length === 4 && isServiceArcanePath(path.slice(0, 3)) && path[3] === 'hidden')+ (path.length === 2 && path[0] === 'x-arcane' && ['hidden', 'update-check'].includes(String(path[1]))) ||+ (path.length === 4 && isServiceArcanePath(path.slice(0, 3)) && ['hidden', 'update-check'].includes(String(path[3])))) {values.add('true');values.add('false');