Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
refactor: consolidate digest and image updater logic (#2623)
Kyle Mendellb382a601a5ae
diff --git a/backend/cli/upgrade/upgrade.go b/backend/cli/upgrade/upgrade.goindex 2b5412597..da99b1bf0 100644--- a/backend/cli/upgrade/upgrade.go+++ b/backend/cli/upgrade/upgrade.go@@ -9,7 +9,7 @@ import (docker "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate""github.com/moby/moby/api/types/container""github.com/moby/moby/api/types/network""github.com/moby/moby/client"diff --git a/backend/internal/services/container_registry_service.go b/backend/internal/services/container_registry_service.goindex fa982c15d..2cc0afc7d 100644--- a/backend/internal/services/container_registry_service.go+++ b/backend/internal/services/container_registry_service.go@@ -17,24 +17,25 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto"+ imageupdatecore "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate"+ utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/libarcane/registryauth""github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/backend/pkg/utils""github.com/getarcaneapp/arcane/backend/pkg/utils/cache"- utilsdistribution "github.com/getarcaneapp/arcane/backend/pkg/utils/distribution"- "github.com/getarcaneapp/arcane/backend/pkg/utils/imagedigest""github.com/getarcaneapp/arcane/backend/pkg/utils/mapper"- utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry""github.com/getarcaneapp/arcane/types/containerregistry"dockerregistry "github.com/moby/moby/api/types/registry""github.com/moby/moby/client")const (- registryCacheTTL = 30 * time.Minute- registryTypeGeneric string = "generic"- registryTypeECR string = "ecr"- registryPullCountKeyPrefix = "container_registry:pulls:"- registryRateLimitKeyPrefix = "container_registry:rate_limits:"+ registryCacheTTL = 30 * time.Minute+ registryTypeGeneric string = "generic"+ registryTypeECR string = "ecr"+ registryPullCountKeyPrefix = "container_registry:pulls:"+ registryRateLimitKeyPrefix = "container_registry:rate_limits:"+ dockerHubRateLimitRepository = "ratelimitpreview/test"+ dockerHubRateLimitTag = "latest")type RegistryDaemonClient interface {@@ -59,8 +60,8 @@ type resolvedRegistryCredential struct {}type registryRateLimitCacheEntryInternal struct {- RateLimit utilsdistribution.RateLimitInfo `json:"rateLimit"`- CheckedAt time.Time `json:"checkedAt"`+ RateLimit imageupdatecore.RateLimitInfo `json:"rateLimit"`+ CheckedAt time.Time `json:"checkedAt"`}type ContainerRegistryService struct {@@ -79,7 +80,7 @@ func NewContainerRegistryService(db *database.DB, dockerClient registryDaemonGetreturn &ContainerRegistryService{db: db,dockerClient: dockerClient,- distributionHTTPClient: utilsdistribution.NewRegistryHTTPClient(),+ distributionHTTPClient: imageupdatecore.NewRegistryHTTPClient(),cache: make(map[string]*cache.Cache[string]),kvService: kvService,}@@ -516,7 +517,7 @@ func (s *ContainerRegistryService) getObservedPullsInternal(ctx context.Context,return value}-func (s *ContainerRegistryService) dockerHubCredentialForRegistryInternal(reg models.ContainerRegistry) (*utilsdistribution.Credentials, string, string, error) {+func (s *ContainerRegistryService) dockerHubCredentialForRegistryInternal(reg models.ContainerRegistry) (*imageupdatecore.Credentials, string, string, error) {if reg.RegistryType != registryTypeGeneric {return nil, "anonymous", "", nil}@@ -536,21 +537,17 @@ func (s *ContainerRegistryService) dockerHubCredentialForRegistryInternal(reg moreturn nil, "anonymous", "", nil}- return &utilsdistribution.Credentials{+ return &imageupdatecore.Credentials{Username: username,Token: token,}, "credential", username, nil}-func (s *ContainerRegistryService) fetchDockerHubRateLimitInternal(ctx context.Context, credential *utilsdistribution.Credentials) (*utilsdistribution.RateLimitInfo, error) {- if s.distributionHTTPClient == nil {- return utilsdistribution.FetchDockerHubRateLimit(ctx, credential)- }-- return utilsdistribution.FetchDockerHubRateLimitWithHTTPClient(ctx, credential, s.distributionHTTPClient)+func (s *ContainerRegistryService) fetchDockerHubRateLimitInternal(ctx context.Context, credential *imageupdatecore.Credentials) (*imageupdatecore.RateLimitInfo, error) {+ return imageupdatecore.FetchRegistryRateLimit(ctx, "docker.io", dockerHubRateLimitRepository, dockerHubRateLimitTag, credential, s.distributionHTTPClient)}-func (s *ContainerRegistryService) getCachedRateLimitInternal(ctx context.Context, registryID string) (*utilsdistribution.RateLimitInfo, time.Time, bool) {+func (s *ContainerRegistryService) getCachedRateLimitInternal(ctx context.Context, registryID string) (*imageupdatecore.RateLimitInfo, time.Time, bool) {if s.kvService == nil || registryID == "" {return nil, time.Time{}, false}@@ -576,7 +573,7 @@ func (s *ContainerRegistryService) getCachedRateLimitInternal(ctx context.Contexreturn &entry.RateLimit, entry.CheckedAt, true}-func (s *ContainerRegistryService) setCachedRateLimitInternal(ctx context.Context, registryID string, rateLimit *utilsdistribution.RateLimitInfo, checkedAt time.Time) {+func (s *ContainerRegistryService) setCachedRateLimitInternal(ctx context.Context, registryID string, rateLimit *imageupdatecore.RateLimitInfo, checkedAt time.Time) {if s.kvService == nil || registryID == "" || rateLimit == nil {return}@@ -731,7 +728,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 := normalizeDistributionReferenceInternal(imageRef)+ parts, err := imageupdatecore.NormalizeReference(imageRef)if err != nil {return nil, err}@@ -775,7 +772,7 @@ func (s *ContainerRegistryService) inspectImageDigestViaDaemonInternal(ctx conteinspectResult, err := dockerClient.DistributionInspect(ctx, normalizedRef, client.DistributionInspectOptions{})if err == nil {- digest, normalizeErr := imagedigest.Normalize(inspectResult.Descriptor.Digest.String())+ digest, normalizeErr := imageupdatecore.NormalizeDigest(inspectResult.Descriptor.Digest.String())if normalizeErr != nil {return nil, fmt.Errorf("distribution inspect returned invalid digest for %s: %w", normalizedRef, normalizeErr)}@@ -813,7 +810,7 @@ func (s *ContainerRegistryService) inspectImageDigestWithCredentialsInternal(ctxEncodedRegistryAuth: authHeader,})if err == nil {- digest, normalizeErr := imagedigest.Normalize(inspectResult.Descriptor.Digest.String())+ digest, normalizeErr := imageupdatecore.NormalizeDigest(inspectResult.Descriptor.Digest.String())if normalizeErr != nil {return nil, fmt.Errorf("distribution inspect returned invalid digest for %s: %w", normalizedRef, normalizeErr)}@@ -1181,12 +1178,8 @@ func (s *ContainerRegistryService) deleteUnsyncedInternal(ctx context.Context, ereturn nil}-func normalizeDistributionReferenceInternal(imageRef string) (*utilsdistribution.Reference, error) {- return utilsdistribution.NormalizeReference(imageRef)-}-func normalizeImageReferenceForDistributionInternal(imageRef string) (string, string, error) {- parts, err := normalizeDistributionReferenceInternal(imageRef)+ parts, err := imageupdatecore.NormalizeReference(imageRef)if err != nil {return "", "", err}@@ -1253,29 +1246,19 @@ func isDistributionFallbackEligibleInternal(err error) bool {return false}- return utilsdistribution.IsFallbackEligibleDaemonError(err)+ return imageupdatecore.IsFallbackEligibleDaemonError(err)}func (s *ContainerRegistryService) fetchDigestFromRegistryInternal(ctx context.Context, registryHost, repository, tag string, credential *resolvedRegistryCredential) (string, error) {- var distributionCredential *utilsdistribution.Credentials+ var distributionCredential *imageupdatecore.Credentialsif credential != nil {- distributionCredential = &utilsdistribution.Credentials{+ distributionCredential = &imageupdatecore.Credentials{Username: strings.TrimSpace(credential.Username),Token: strings.TrimSpace(credential.Token),}}- if s.distributionHTTPClient == nil {- return utilsdistribution.FetchDigest(- ctx,- registryHost,- repository,- tag,- distributionCredential,- )- }-- return utilsdistribution.FetchDigestWithHTTPClient(+ return imageupdatecore.FetchDigest(ctx,registryHost,repository,diff --git a/backend/internal/services/container_service.go b/backend/internal/services/container_service.goindex 1c7d12be9..deeabf8b4 100644--- a/backend/internal/services/container_service.go+++ b/backend/internal/services/container_service.go@@ -19,8 +19,8 @@ import (dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane""github.com/getarcaneapp/arcane/backend/pkg/libarcane/containerstats"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate""github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater""github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/backend/pkg/projects""github.com/getarcaneapp/arcane/backend/pkg/utils/cache"diff --git a/backend/internal/services/dashboard_service.go b/backend/internal/services/dashboard_service.goindex 138f7ff90..f4bc08de5 100644--- a/backend/internal/services/dashboard_service.go+++ b/backend/internal/services/dashboard_service.go@@ -13,7 +13,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/models"dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate""github.com/getarcaneapp/arcane/types/base"containertypes "github.com/getarcaneapp/arcane/types/container"dashboardtypes "github.com/getarcaneapp/arcane/types/dashboard"diff --git a/backend/internal/services/image_service.go b/backend/internal/services/image_service.goindex 42f984e97..6734c1cb0 100644--- a/backend/internal/services/image_service.go+++ b/backend/internal/services/image_service.go@@ -14,8 +14,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil"+ utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/libarcane/registryauth""github.com/getarcaneapp/arcane/backend/pkg/pagination"- utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry""github.com/getarcaneapp/arcane/types/containerregistry"imagetypes "github.com/getarcaneapp/arcane/types/image"systemtypes "github.com/getarcaneapp/arcane/types/system"diff --git a/backend/internal/services/image_update_service.go b/backend/internal/services/image_update_service.goindex 984d6c7c1..5400af235 100644--- a/backend/internal/services/image_update_service.go+++ b/backend/internal/services/image_update_service.go@@ -12,8 +12,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/pkg/libarcane/crypto"- "github.com/getarcaneapp/arcane/backend/pkg/utils/imagedigest"- registry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry"+ imageupdatecore "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate"+ registry "github.com/getarcaneapp/arcane/backend/pkg/libarcane/registryauth""github.com/getarcaneapp/arcane/types/containerregistry""github.com/getarcaneapp/arcane/types/imageupdate""github.com/moby/moby/api/types/image"@@ -212,7 +212,7 @@ func (s *ImageUpdateService) parseImageReference(imageRef string) *ImageParts {// Fallback parser for cases where the official parser failsfunc (s *ImageUpdateService) parseImageReferenceFallback(imageRef string) *ImageParts {var registryHost, repository, tag string- if _, ok := imagedigest.FromReferenceSuffix(imageRef); ok {+ if _, ok := imageupdatecore.DigestFromReferenceSuffix(imageRef); ok {digestParts := strings.Split(imageRef, "@")if len(digestParts) != 2 {return nil@@ -378,7 +378,7 @@ func (s *ImageUpdateService) inspectLocalImageSnapshotInternal(ctx context.Conte// Extract all digests from RepoDigestsif len(inspectResponse.RepoDigests) > 0 {for _, repoDigest := range inspectResponse.RepoDigests {- digest, ok := imagedigest.FromReferenceSuffix(repoDigest)+ digest, ok := imageupdatecore.DigestFromReferenceSuffix(repoDigest)if !ok {continue}diff --git a/backend/internal/services/project_service.go b/backend/internal/services/project_service.goindex 165f85d5c..bc1578c53 100644--- a/backend/internal/services/project_service.go+++ b/backend/internal/services/project_service.go@@ -24,9 +24,9 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models"dockerutil "github.com/getarcaneapp/arcane/backend/pkg/dockerutil"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate"libbuild "github.com/getarcaneapp/arcane/backend/pkg/libarcane/libbuild""github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater""github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/backend/pkg/projects""github.com/getarcaneapp/arcane/backend/pkg/utils"diff --git a/backend/internal/services/project_service_test.go b/backend/internal/services/project_service_test.goindex 584f4db26..63a6cc79f 100644--- a/backend/internal/services/project_service_test.go+++ b/backend/internal/services/project_service_test.go@@ -20,7 +20,7 @@ import (composeapi "github.com/docker/compose/v5/pkg/api""github.com/getarcaneapp/arcane/backend/internal/common""github.com/getarcaneapp/arcane/backend/internal/config"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate""github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/backend/pkg/projects"buildtypes "github.com/getarcaneapp/arcane/types/builds"diff --git a/backend/internal/services/system_service.go b/backend/internal/services/system_service.goindex f99bd5ab8..9ab5e957e 100644--- a/backend/internal/services/system_service.go+++ b/backend/internal/services/system_service.go@@ -11,7 +11,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/pkg/libarcane/dockerrun"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate"containertypes "github.com/getarcaneapp/arcane/types/container""github.com/getarcaneapp/arcane/types/system""github.com/goccy/go-yaml"diff --git a/backend/internal/services/system_upgrade_service.go b/backend/internal/services/system_upgrade_service.goindex df4c3423d..6193a5687 100644--- a/backend/internal/services/system_upgrade_service.go+++ b/backend/internal/services/system_upgrade_service.go@@ -13,8 +13,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/models"dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate""github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"containertypes "github.com/moby/moby/api/types/container"mounttypes "github.com/moby/moby/api/types/mount""github.com/moby/moby/client"diff --git a/backend/internal/services/system_upgrade_service_test.go b/backend/internal/services/system_upgrade_service_test.goindex 92d97fd11..7de4424fc 100644--- a/backend/internal/services/system_upgrade_service_test.go+++ b/backend/internal/services/system_upgrade_service_test.go@@ -3,7 +3,7 @@ package servicesimport ("testing"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate""github.com/stretchr/testify/require")diff --git a/backend/internal/services/updater_service.go b/backend/internal/services/updater_service.goindex 72b3d8cc6..45e210c94 100644--- a/backend/internal/services/updater_service.go+++ b/backend/internal/services/updater_service.go@@ -22,9 +22,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/database""github.com/getarcaneapp/arcane/backend/internal/models""github.com/getarcaneapp/arcane/backend/pkg/libarcane"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate"projectspkg "github.com/getarcaneapp/arcane/backend/pkg/projects"- arcRegistry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry""github.com/getarcaneapp/arcane/types/updater")@@ -129,7 +128,11 @@ func (s *UpdaterService) ApplyPending(ctx context.Context, dryRun bool) (*updatecontinue}oldRef := fmt.Sprintf("%s:%s", r.Repository, r.Tag)- oldNorm := s.normalizeRef(oldRef)+ oldNorm := normalizeImageUpdateRefInternal(oldRef)+ if oldNorm == "" {+ slog.DebugContext(ctx, "ApplyPending: skipping invalid pending image reference", "imageRef", oldRef)+ continue+ }if _, ok := usedImages[oldNorm]; !ok {continue@@ -199,7 +202,7 @@ func (s *UpdaterService) ApplyPending(ctx context.Context, dryRun bool) (*update// Digest pre-check: if registry supports it and digests match, avoid pulling entirely.// This also prevents unnecessary restarts when the update record is stale.- normNew := s.normalizeRef(p.newRef)+ normNew := normalizeImageUpdateRefInternal(p.newRef)check := digestChecker.CheckImageNeedsUpdate(ctx, normNew)skipPull := false@@ -492,7 +495,7 @@ func (s *UpdaterService) UpdateSingleContainer(ctx context.Context, containerIDreturn out, nil}- normalizedRef := s.normalizeRef(imageRef)+ normalizedRef := normalizeImageUpdateRefInternal(imageRef)repo, tag := s.parseRepoAndTag(normalizedRef)if repo == "" || tag == "" {@@ -923,34 +926,29 @@ func buildUpdaterRecreateNetworkingConfigInternal(networkMode container.NetworkMreturn &network.NetworkingConfig{EndpointsConfig: sanitizedEndpointsConfig}}-// normalizeRef returns a canonical "registry/repository:tag" without digest.-// Examples:-// - "redis:latest" -> "docker.io/library/redis:latest"-// - "nginx@sha256:..." -> "docker.io/library/nginx:latest" (if no tag was present, defaults to latest)-func (s *UpdaterService) normalizeRef(ref string) string {- ref = s.stripDigest(ref)-- // Split tag- tag := "latest"- if i := strings.LastIndex(ref, ":"); i != -1 && strings.LastIndex(ref, "/") < i {- tag = ref[i+1:]- ref = ref[:i]+func normalizeImageUpdateRefInternal(imageRef string) string {+ parts, err := libupdater.NormalizeReference(imageRef)+ if err != nil {+ return ""}+ return parts.NormalizedRef+}- parts := strings.Split(ref, "/")- domain := ""- switch {- case len(parts) > 0 && (strings.Contains(parts[0], ".") || strings.Contains(parts[0], ":") || parts[0] == "localhost"):- domain = arcRegistry.NormalizeRegistryForComparison(parts[0])- parts = parts[1:]- default:- domain = "docker.io"+func addNormalizedImageUpdateRefInternal(ctx context.Context, out map[string]struct{}, imageRef, logMessage string, attrs ...any) bool {+ normalizedRef := normalizeImageUpdateRefInternal(imageRef)+ if normalizedRef != "" {+ out[normalizedRef] = struct{}{}+ return true}- repo := strings.Join(parts, "/")- if domain == "docker.io" && !strings.Contains(repo, "/") {- repo = "library/" + repo++ args := slices.Clone(attrs)+ args = append(args, "imageRef", imageRef)+ if ctx != nil {+ slog.DebugContext(ctx, logMessage, args...)+ } else {+ slog.Debug(logMessage, args...)}- return strings.ToLower(domain + "/" + repo + ":" + tag)+ return false}func (s *UpdaterService) stripDigest(ref string) string {@@ -996,7 +994,7 @@ func (s *UpdaterService) collectUsedImagesFromContainersInternal(ctx context.ConimageRef := strings.TrimSpace(c.Image)if imageRef != "" && !isImageIDLikeReferenceInternal(imageRef) {- out[s.normalizeRef(imageRef)] = struct{}{}+ addNormalizedImageUpdateRefInternal(ctx, out, imageRef, "collectUsedImagesFromContainersInternal: skipping invalid image reference", "containerId", c.ID)continue}@@ -1099,7 +1097,7 @@ func (s *UpdaterService) collectUsedImagesFromProjects(ctx context.Context, outreturn err}- s.collectUsedImagesFromComposeContainersInternal(composeContainers, activeProjectNames, out)+ s.collectUsedImagesFromComposeContainersInternal(ctx, composeContainers, activeProjectNames, out)return nil}@@ -1128,7 +1126,7 @@ func activeComposeProjectNameSetInternal(projects []models.Project) map[string]sreturn active}-func (s *UpdaterService) collectUsedImagesFromComposeContainersInternal(composeContainers []container.Summary, activeProjectNames map[string]struct{}, out map[string]struct{}) {+func (s *UpdaterService) collectUsedImagesFromComposeContainersInternal(ctx context.Context, composeContainers []container.Summary, activeProjectNames map[string]struct{}, out map[string]struct{}) {for _, c := range composeContainers {projectName := strings.TrimSpace(c.Labels["com.docker.compose.project"])if projectName == "" {@@ -1145,7 +1143,7 @@ func (s *UpdaterService) collectUsedImagesFromComposeContainersInternal(composeCif imageRef == "" || isImageIDLikeReferenceInternal(imageRef) {continue}- out[s.normalizeRef(imageRef)] = struct{}{}+ addNormalizedImageUpdateRefInternal(ctx, out, imageRef, "collectUsedImagesFromComposeContainersInternal: skipping invalid image reference", "containerId", c.ID)}}@@ -1160,7 +1158,7 @@ func (s *UpdaterService) getNormalizedTagsForContainer(ctx context.Context, dcliif tag == "<none>:<none>" || tag == "" {continue}- seen[s.normalizeRef(tag)] = struct{}{}+ addNormalizedImageUpdateRefInternal(ctx, seen, tag, "getNormalizedTagsForContainer: skipping invalid repo tag", "imageId", inspect.Image)}} else {slog.DebugContext(ctx, "getNormalizedTagsForContainer: image inspect failed", "imageId", inspect.Image, "err", err)@@ -1168,7 +1166,7 @@ func (s *UpdaterService) getNormalizedTagsForContainer(ctx context.Context, dcli}if inspect.Config != nil && inspect.Config.Image != "" {- seen[s.normalizeRef(inspect.Config.Image)] = struct{}{}+ addNormalizedImageUpdateRefInternal(ctx, seen, inspect.Config.Image, "getNormalizedTagsForContainer: skipping invalid config image reference", "imageId", inspect.Image)}out := make([]string, 0, len(seen))@@ -1280,7 +1278,11 @@ func (s *UpdaterService) restartContainersUsingOldIDs(ctx context.Context, oldIDupdatedNorm := map[string]string{}for oldRef, nr := range oldRefToNewRef {- updatedNorm[s.normalizeRef(oldRef)] = nr+ if normalizedRef := normalizeImageUpdateRefInternal(oldRef); normalizedRef != "" {+ updatedNorm[normalizedRef] = nr+ } else {+ slog.DebugContext(ctx, "restartContainersUsingOldIDs: skipping invalid old image reference", "imageRef", oldRef)+ }}plansByName := map[string]*restartPlan{}@@ -1497,7 +1499,7 @@ func (s *UpdaterService) restartContainersUsingOldIDs(ctx context.Context, oldIDResourceType: "container",Status: "checked",OldImages: map[string]string{"main": p.match},- NewImages: map[string]string{"main": s.normalizeRef(p.newRef)},+ NewImages: map[string]string{"main": normalizeImageUpdateRefInternal(p.newRef)},}if p.newRef == "" {@@ -1549,7 +1551,7 @@ func (s *UpdaterService) restartContainersUsingOldIDs(ctx context.Context, oldIDres.UpdateApplied = true// Send notificationif s.notificationService != nil {- if notifErr := s.notificationService.SendContainerUpdateNotification(ctx, name, p.newRef, p.match, s.normalizeRef(p.newRef)); notifErr != nil {+ if notifErr := s.notificationService.SendContainerUpdateNotification(ctx, name, p.newRef, p.match, normalizeImageUpdateRefInternal(p.newRef)); notifErr != nil {slog.WarnContext(ctx, "Failed to send container update notification", "containerId", p.cnt.ID, "containerName", name, "imageRef", p.newRef, "error", notifErr.Error())}}@@ -1578,7 +1580,7 @@ func (s *UpdaterService) restartContainersUsingOldIDs(ctx context.Context, oldID// Send notification after successful container updateif s.notificationService != nil {- if notifErr := s.notificationService.SendContainerUpdateNotification(ctx, name, p.newRef, p.match, s.normalizeRef(p.newRef)); notifErr != nil {+ if notifErr := s.notificationService.SendContainerUpdateNotification(ctx, name, p.newRef, p.match, normalizeImageUpdateRefInternal(p.newRef)); notifErr != nil {slog.WarnContext(ctx, "Failed to send container update notification", "containerId", p.cnt.ID, "containerName", name, "imageRef", p.newRef, "error", notifErr.Error())}}@@ -1787,7 +1789,10 @@ func (s *UpdaterService) resolveContainerImageMatchInternal(c container.Summary,return "", ""}- norm := s.normalizeRef(imageRef)+ norm := normalizeImageUpdateRefInternal(imageRef)+ if norm == "" {+ return "", ""+ }if nr, ok := updatedNorm[norm]; ok {return nr, norm}diff --git a/backend/internal/services/updater_service_test.go b/backend/internal/services/updater_service_test.goindex 976c1776a..a2669a5c9 100644--- a/backend/internal/services/updater_service_test.go+++ b/backend/internal/services/updater_service_test.go@@ -24,7 +24,7 @@ import ("gorm.io/gorm""github.com/getarcaneapp/arcane/backend/internal/models"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate")// mockSystemUpgradeService is a simple mock implementation for testing@@ -401,7 +401,6 @@ func TestIsImageIDLikeReference(t *testing.T) {}func TestCollectUsedImagesFromContainers_FastPathSkipsInspectLikeRefs(t *testing.T) {- svc := &UpdaterService{}out := map[string]struct{}{}// Simulate fast-path behavior expectations without Docker client dependency.@@ -409,17 +408,19 @@ func TestCollectUsedImagesFromContainers_FastPathSkipsInspectLikeRefs(t *testing{Image: "nginx:latest"},{Image: "sha256:abcdef"},{Image: "redis:7"},+ {Image: "Bad/Image:latest"},}for _, c := range containers {if c.Image != "" && !isImageIDLikeReferenceInternal(c.Image) {- out[svc.normalizeRef(c.Image)] = struct{}{}+ addNormalizedImageUpdateRefInternal(context.Background(), out, c.Image, "test skip invalid image reference")}}- assert.Contains(t, out, svc.normalizeRef("nginx:latest"))- assert.Contains(t, out, svc.normalizeRef("redis:7"))- assert.NotContains(t, out, svc.normalizeRef("sha256:abcdef"))+ assert.Contains(t, out, normalizeImageUpdateRefInternal("nginx:latest"))+ assert.Contains(t, out, normalizeImageUpdateRefInternal("redis:7"))+ assert.NotContains(t, out, normalizeImageUpdateRefInternal("sha256:abcdef"))+ assert.NotContains(t, out, "")}func mustHardwareAddr(t *testing.T, value string) network.HardwareAddr {@@ -703,20 +704,27 @@ func TestCollectUsedImagesFromComposeContainersInternal(t *testing.T) {"com.docker.compose.project": "myapp",},},+ {+ Image: "Bad/Image:latest",+ Labels: map[string]string{+ "com.docker.compose.project": "myapp",+ },+ },}- svc.collectUsedImagesFromComposeContainersInternal(composeContainers, activeProjects, out)+ svc.collectUsedImagesFromComposeContainersInternal(context.Background(), composeContainers, activeProjects, out)- assert.Contains(t, out, svc.normalizeRef("nginx:latest"))- assert.NotContains(t, out, svc.normalizeRef("redis:7"))- assert.NotContains(t, out, svc.normalizeRef("postgres:16"))- assert.NotContains(t, out, svc.normalizeRef("sha256:abcdef"))+ assert.Contains(t, out, normalizeImageUpdateRefInternal("nginx:latest"))+ assert.NotContains(t, out, normalizeImageUpdateRefInternal("redis:7"))+ assert.NotContains(t, out, normalizeImageUpdateRefInternal("postgres:16"))+ assert.NotContains(t, out, normalizeImageUpdateRefInternal("sha256:abcdef"))+ assert.NotContains(t, out, "")}func TestResolveContainerImageMatchInternal(t *testing.T) {svc := &UpdaterService{}updatedNorm := map[string]string{- svc.normalizeRef("nginx:latest"): "nginx:latest",+ normalizeImageUpdateRefInternal("nginx:latest"): "nginx:latest",}oldIDToNewRef := map[string]string{"sha256:img1": "redis:7",@@ -725,6 +733,7 @@ func TestResolveContainerImageMatchInternal(t *testing.T) {tests := []struct {name stringcontainer container.Summary+ updatedNorm map[string]stringwantRef stringwantMatchID string}{@@ -744,7 +753,7 @@ func TestResolveContainerImageMatchInternal(t *testing.T) {Image: "docker.io/library/nginx:latest",},wantRef: "nginx:latest",- wantMatchID: svc.normalizeRef("nginx:latest"),+ wantMatchID: normalizeImageUpdateRefInternal("nginx:latest"),},{name: "image id-like summary value cannot be tag matched",@@ -755,11 +764,25 @@ func TestResolveContainerImageMatchInternal(t *testing.T) {wantRef: "",wantMatchID: "",},+ {+ name: "invalid image reference does not match empty normalized key",+ container: container.Summary{+ ImageID: "sha256:unknown",+ Image: "Bad/Image:latest",+ },+ updatedNorm: map[string]string{"": "wrong:latest"},+ wantRef: "",+ wantMatchID: "",+ },}for _, tt := range tests {t.Run(tt.name, func(t *testing.T) {- gotRef, gotMatch := svc.resolveContainerImageMatchInternal(tt.container, oldIDToNewRef, updatedNorm)+ localUpdatedNorm := updatedNorm+ if tt.updatedNorm != nil {+ localUpdatedNorm = tt.updatedNorm+ }+ gotRef, gotMatch := svc.resolveContainerImageMatchInternal(tt.container, oldIDToNewRef, localUpdatedNorm)assert.Equal(t, tt.wantRef, gotRef)assert.Equal(t, tt.wantMatchID, gotMatch)})@@ -945,6 +968,6 @@ func TestUpdaterService_CollectUsedImages_SkipsExcludedContainers(t *testing.T)require.NoError(t, svc.collectUsedImagesFromContainersInternal(ctx, dcli, out))- assert.NotContains(t, out, svc.normalizeRef("nginx:latest"), "excluded container image must not be collected")- assert.Contains(t, out, svc.normalizeRef("redis:7"), "non-excluded container image must be collected")+ assert.NotContains(t, out, normalizeImageUpdateRefInternal("nginx:latest"), "excluded container image must not be collected")+ assert.Contains(t, out, normalizeImageUpdateRefInternal("redis:7"), "non-excluded container image must be collected")}diff --git a/backend/internal/services/version_service.go b/backend/internal/services/version_service.goindex b6158e834..b508597f9 100644--- a/backend/internal/services/version_service.go+++ b/backend/internal/services/version_service.go@@ -14,7 +14,7 @@ import ("github.com/getarcaneapp/arcane/backend/internal/config"docker "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate""github.com/getarcaneapp/arcane/backend/pkg/utils/cache""github.com/getarcaneapp/arcane/types/version"containertypes "github.com/moby/moby/api/types/container"diff --git a/backend/internal/services/vulnerability_service.go b/backend/internal/services/vulnerability_service.goindex 9c62ce1c6..d5f3e4563 100644--- a/backend/internal/services/vulnerability_service.go+++ b/backend/internal/services/vulnerability_service.go@@ -26,8 +26,8 @@ import ("github.com/getarcaneapp/arcane/backend/internal/models"dockerutils "github.com/getarcaneapp/arcane/backend/pkg/dockerutil""github.com/getarcaneapp/arcane/backend/pkg/libarcane"+ libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/imageupdate""github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"- libupdater "github.com/getarcaneapp/arcane/backend/pkg/libarcane/updater""github.com/getarcaneapp/arcane/backend/pkg/pagination""github.com/getarcaneapp/arcane/types/vulnerability""github.com/moby/moby/api/pkg/stdcopy"diff --git a/backend/pkg/libarcane/updater/digest.go b/backend/pkg/libarcane/imageupdate/digest.gosimilarity index 65%rename from backend/pkg/libarcane/updater/digest.gorename to backend/pkg/libarcane/imageupdate/digest.goindex d60da4f02..e37974fa7 100644--- a/backend/pkg/libarcane/updater/digest.go+++ b/backend/pkg/libarcane/imageupdate/digest.go@@ -1,4 +1,4 @@-package updater+package imageupdateimport ("context"@@ -6,11 +6,8 @@ import ("log/slog""strings"- "github.com/getarcaneapp/arcane/backend/pkg/utils/imagedigest""github.com/moby/moby/client"- ref "go.podman.io/image/v5/docker/reference"-- "github.com/getarcaneapp/arcane/backend/pkg/utils/registry"+ digest "github.com/opencontainers/go-digest")type remoteDigestResolver interface {@@ -40,6 +37,29 @@ type CheckResult struct {CheckedViaAPI bool // True if we checked via registry API, false if we had to pull}+func NormalizeDigest(value string) (string, error) {+ parsed, err := digest.Parse(strings.TrimSpace(value))+ if err != nil {+ return "", fmt.Errorf("invalid OCI digest %q: %w", value, err)+ }++ return parsed.String(), nil+}++func DigestFromReferenceSuffix(ref string) (string, bool) {+ _, digestValue, ok := strings.Cut(strings.TrimSpace(ref), "@")+ if !ok {+ return "", false+ }++ normalized, err := NormalizeDigest(digestValue)+ if err != nil {+ return "", false+ }++ return normalized, true+}+// CheckImageNeedsUpdate checks if an image has a newer version available without pulling// Returns true if the remote digest differs from the local digestfunc (c *DigestChecker) CheckImageNeedsUpdate(ctx context.Context, imageRef string) CheckResult {@@ -47,10 +67,10 @@ func (c *DigestChecker) CheckImageNeedsUpdate(ctx context.Context, imageRef strislog.DebugContext(ctx, "CheckImageNeedsUpdate: checking image","imageRef", imageRef,- "normalizedRef", normalizeRef(imageRef))+ "normalizedRef", normalizedReferenceStringInternal(imageRef))// Get local digest- localDigest, err := c.getLocalDigest(ctx, imageRef)+ localDigest, err := c.getLocalDigestInternal(ctx, imageRef)if err != nil {slog.DebugContext(ctx, "CheckImageNeedsUpdate: failed to get local digest","imageRef", imageRef,@@ -91,8 +111,8 @@ func (c *DigestChecker) CheckImageNeedsUpdate(ctx context.Context, imageRef strireturn result}-// getLocalDigest retrieves the digest of a locally stored image-func (c *DigestChecker) getLocalDigest(ctx context.Context, imageRef string) (string, error) {+// getLocalDigestInternal retrieves the digest of a locally stored image+func (c *DigestChecker) getLocalDigestInternal(ctx context.Context, imageRef string) (string, error) {inspect, err := c.dcli.ImageInspect(ctx, imageRef)if err != nil {return "", fmt.Errorf("image not found locally: %w", err)@@ -100,7 +120,7 @@ func (c *DigestChecker) getLocalDigest(ctx context.Context, imageRef string) (st// Try to get digest from RepoDigestsfor _, rd := range inspect.RepoDigests {- if normalized, ok := imagedigest.FromReferenceSuffix(rd); ok {+ if normalized, ok := DigestFromReferenceSuffix(rd); ok {return normalized, nil}}@@ -141,11 +161,11 @@ func (c *DigestChecker) GetImageIDsForRef(ctx context.Context, ref string) ([]st}images := imageList.Items- normalizedRef := normalizeRef(ref)+ normalizedRef := normalizedReferenceStringInternal(ref)var ids []stringfor _, img := range images {for _, tag := range img.RepoTags {- if normalizeRef(tag) == normalizedRef {+ if normalizedReferenceStringInternal(tag) == normalizedRef {ids = append(ids, img.ID)break}@@ -155,53 +175,10 @@ func (c *DigestChecker) GetImageIDsForRef(ctx context.Context, ref string) ([]streturn ids, nil}-// parseImageRef splits an image reference into registry, repository, and tag-func parseImageRef(imageRef string) (registryHost, repository, tag string) {- named, err := ref.ParseNormalizedNamed(imageRef)- if err == nil {- registryHost = registry.NormalizeRegistryForComparison(ref.Domain(named))- repository = ref.Path(named)- tag = "latest"- if tagged, ok := named.(ref.NamedTagged); ok {- tag = tagged.Tag()- }- return registryHost, repository, tag- }-- // Fallback for unexpected parser failures.- registryHost = registry.ExtractRegistryHost(imageRef)- if i := strings.Index(imageRef, "@"); i != -1 {- imageRef = imageRef[:i]- }-- tag = "latest"- if i := strings.LastIndex(imageRef, ":"); i != -1 && strings.LastIndex(imageRef, "/") < i {- tag = imageRef[i+1:]- imageRef = imageRef[:i]- }-- parts := strings.Split(imageRef, "/")- if len(parts) > 0 && (strings.Contains(parts[0], ".") || strings.Contains(parts[0], ":") || parts[0] == "localhost") {- repository = strings.Join(parts[1:], "/")- } else {- repository = imageRef- if registryHost == "docker.io" && !strings.Contains(repository, "/") {- repository = "library/" + repository- }- }-- return registry.NormalizeRegistryForComparison(registryHost), repository, tag-}--// normalizeRef normalizes an image reference for comparison-func normalizeRef(ref string) string {- // Strip digest- if i := strings.Index(ref, "@"); i != -1 {- ref = ref[:i]+func normalizedReferenceStringInternal(imageRef string) string {+ parts, err := NormalizeReference(imageRef)+ if err != nil {+ return ""}-- // Parse and reconstruct- reg, repo, tag := parseImageRef(ref)-- return strings.ToLower(reg + "/" + repo + ":" + tag)+ return parts.NormalizedRef}diff --git a/backend/pkg/libarcane/imageupdate/digest_test.go b/backend/pkg/libarcane/imageupdate/digest_test.gonew file mode 100644index 000000000..0339f7f29--- /dev/null+++ b/backend/pkg/libarcane/imageupdate/digest_test.go@@ -0,0 +1,100 @@+package imageupdate++import (+ "testing"++ digest "github.com/opencontainers/go-digest"+ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/require"+)++func TestNormalizeDigest(t *testing.T) {+ want := digest.FromString("arcane").String()++ got, err := NormalizeDigest(" " + want + " ")+ require.NoError(t, err)+ assert.Equal(t, want, got)+}++func TestNormalizeDigest_InvalidDigest(t *testing.T) {+ _, err := NormalizeDigest("sha256:not-a-valid-digest")+ require.Error(t, err)+}++func TestDigestFromReferenceSuffix(t *testing.T) {+ want := digest.FromString("arcane-reference").String()++ got, ok := DigestFromReferenceSuffix("docker.io/library/nginx@" + want)+ require.True(t, ok)+ assert.Equal(t, want, got)+}++func TestDigestFromReferenceSuffix_InvalidDigest(t *testing.T) {+ _, ok := DigestFromReferenceSuffix("docker.io/library/nginx@sha256:bad")+ assert.False(t, ok)+}++func TestParseImageRef(t *testing.T) {+ redisDigest := digest.FromString("redis").String()++ tests := []struct {+ name string+ imageRef string+ wantHost string+ wantRepo string+ wantTag string+ }{+ {+ name: "docker hub official image",+ imageRef: "nginx:latest",+ wantHost: "docker.io",+ wantRepo: "library/nginx",+ wantTag: "latest",+ },+ {+ name: "custom registry image",+ imageRef: "ghcr.io/getarcaneapp/arcane:v1.2.3",+ wantHost: "ghcr.io",+ wantRepo: "getarcaneapp/arcane",+ wantTag: "v1.2.3",+ },+ {+ name: "digest reference defaults to latest tag",+ imageRef: "docker.io/library/redis@" + redisDigest,+ wantHost: "docker.io",+ wantRepo: "library/redis",+ wantTag: "latest",+ },+ {+ name: "docker registry variant is normalized",+ imageRef: "registry-1.docker.io/library/busybox:1.36",+ wantHost: "docker.io",+ wantRepo: "library/busybox",+ wantTag: "1.36",+ },+ }++ for _, tt := range tests {+ t.Run(tt.name, func(t *testing.T) {+ parts, err := NormalizeReference(tt.imageRef)+ assert.NoError(t, err)+ assert.Equal(t, tt.wantHost, parts.RegistryHost)+ assert.Equal(t, tt.wantRepo, parts.Repository)+ assert.Equal(t, tt.wantTag, parts.Tag)+ })+ }+}++func TestNormalizeRef(t *testing.T) {+ parts, err := NormalizeReference("nginx")+ assert.NoError(t, err)+ assert.Equal(t, "docker.io/library/nginx:latest", parts.NormalizedRef)++ parts, err = NormalizeReference("index.docker.io/library/nginx:latest")+ assert.NoError(t, err)+ assert.Equal(t, "docker.io/library/nginx:latest", parts.NormalizedRef)++ parts, err = NormalizeReference("ghcr.io/getarcaneapp/arcane:v1")+ assert.NoError(t, err)+ assert.Equal(t, "ghcr.io/getarcaneapp/arcane:v1", parts.NormalizedRef)+}diff --git a/backend/pkg/libarcane/updater/labels.go b/backend/pkg/libarcane/imageupdate/labels.gosimilarity index 99%rename from backend/pkg/libarcane/updater/labels.gorename to backend/pkg/libarcane/imageupdate/labels.goindex e7453cde8..fe0d28794 100644--- a/backend/pkg/libarcane/updater/labels.go+++ b/backend/pkg/libarcane/imageupdate/labels.go@@ -1,4 +1,4 @@-package updater+package imageupdateimport "strings"diff --git a/backend/pkg/libarcane/updater/labels_test.go b/backend/pkg/libarcane/imageupdate/labels_test.gosimilarity index 99%rename from backend/pkg/libarcane/updater/labels_test.gorename to backend/pkg/libarcane/imageupdate/labels_test.goindex 68a9f74e7..d51aeae3c 100644--- a/backend/pkg/libarcane/updater/labels_test.go+++ b/backend/pkg/libarcane/imageupdate/labels_test.go@@ -1,4 +1,4 @@-package updater+package imageupdateimport ("errors"diff --git a/backend/pkg/libarcane/updater/logfile.go b/backend/pkg/libarcane/imageupdate/logfile.gosimilarity index 91%rename from backend/pkg/libarcane/updater/logfile.gorename to backend/pkg/libarcane/imageupdate/logfile.goindex edb1f7049..8984d5233 100644--- a/backend/pkg/libarcane/updater/logfile.go+++ b/backend/pkg/libarcane/imageupdate/logfile.go@@ -1,4 +1,4 @@-package updater+package imageupdateimport ("context"@@ -21,7 +21,7 @@ type messageOnlyHandler struct {groups []string}-func newMessageOnlyHandler(w io.Writer, minLevel slog.Level) *messageOnlyHandler {+func newMessageOnlyHandlerInternal(w io.Writer, minLevel slog.Level) *messageOnlyHandler {return &messageOnlyHandler{mu: &sync.Mutex{}, w: w, minLevel: minLevel}}@@ -44,7 +44,7 @@ func (h *messageOnlyHandler) Handle(_ context.Context, r slog.Record) error {if len(h.groups) > 0 {key = strings.Join(h.groups, ".") + "." + key}- line += " " + key + "=" + formatSlogValue(a.Value)+ line += " " + key + "=" + formatSlogValueInternal(a.Value)}for _, a := range h.attrs {@@ -96,7 +96,7 @@ func (h *messageOnlyHandler) WithGroup(name string) slog.Handler {}}-func formatSlogValue(v slog.Value) string {+func formatSlogValueInternal(v slog.Value) string {switch v.Kind() {case slog.KindAny:return strconv.Quote(fmt.Sprint(v.Any()))@@ -121,7 +121,7 @@ func formatSlogValue(v slog.Value) string {// Groups are typically flattened earlier in Handle(), but handle defensively.return strconv.Quote(fmt.Sprint(v.Group()))case slog.KindLogValuer:- return formatSlogValue(v.Resolve())+ return formatSlogValueInternal(v.Resolve())default:return strconv.Quote(fmt.Sprint(v.Any()))}@@ -156,7 +156,7 @@ func SetupMessageOnlyLogFile(dataDir string, filePrefix string, minLevel slog.LeLevel: minLevel,AddSource: true,})- fileHandler := newMessageOnlyHandler(logFile, minLevel)+ fileHandler := newMessageOnlyHandlerInternal(logFile, minLevel)slog.SetDefault(slog.New(slog.NewMultiHandler(stdoutHandler, fileHandler)))diff --git a/backend/pkg/libarcane/updater/logfile_test.go b/backend/pkg/libarcane/imageupdate/logfile_test.gosimilarity index 84%rename from backend/pkg/libarcane/updater/logfile_test.gorename to backend/pkg/libarcane/imageupdate/logfile_test.goindex 8b70ebcaf..dc60f472b 100644--- a/backend/pkg/libarcane/updater/logfile_test.go+++ b/backend/pkg/libarcane/imageupdate/logfile_test.go@@ -1,4 +1,4 @@-package updater+package imageupdateimport ("bytes"@@ -57,7 +57,7 @@ func TestMessageOnlyHandler_Handle(t *testing.T) {for _, tt := range tests {t.Run(tt.name, func(t *testing.T) {var buf bytes.Buffer- handler := newMessageOnlyHandler(&buf, slog.LevelDebug)+ handler := newMessageOnlyHandlerInternal(&buf, slog.LevelDebug)record := slog.NewRecord(time.Now(), tt.level, tt.message, 0)for _, attr := range tt.attrs {@@ -113,7 +113,7 @@ func TestMessageOnlyHandler_Enabled(t *testing.T) {for _, tt := range tests {t.Run(tt.name, func(t *testing.T) {var buf bytes.Buffer- handler := newMessageOnlyHandler(&buf, tt.minLevel)+ handler := newMessageOnlyHandlerInternal(&buf, tt.minLevel)if got := handler.Enabled(context.Background(), tt.level); got != tt.want {t.Errorf("Enabled() = %v, want %v", got, tt.want)@@ -124,7 +124,7 @@ func TestMessageOnlyHandler_Enabled(t *testing.T) {func TestMessageOnlyHandler_WithAttrs(t *testing.T) {var buf bytes.Buffer- handler := newMessageOnlyHandler(&buf, slog.LevelInfo)+ handler := newMessageOnlyHandlerInternal(&buf, slog.LevelInfo)attrs := []slog.Attr{slog.String("key1", "value1"),@@ -155,7 +155,7 @@ func TestMessageOnlyHandler_WithAttrs(t *testing.T) {func TestMessageOnlyHandler_WithGroup(t *testing.T) {var buf bytes.Buffer- handler := newMessageOnlyHandler(&buf, slog.LevelInfo)+ handler := newMessageOnlyHandlerInternal(&buf, slog.LevelInfo)newHandler := handler.WithGroup("testgroup")if newHandler == nil {@@ -220,9 +220,9 @@ func TestFormatSlogValue(t *testing.T) {for _, tt := range tests {t.Run(tt.name, func(t *testing.T) {- got := formatSlogValue(tt.value)+ got := formatSlogValueInternal(tt.value)if got != tt.want {- t.Errorf("formatSlogValue() = %v, want %v", got, tt.want)+ t.Errorf("formatSlogValueInternal() = %v, want %v", got, tt.want)}})}@@ -232,34 +232,34 @@ func TestFormatSlogValue_Time(t *testing.T) {now := time.Date(2024, 1, 1, 12, 0, 0, 0, time.UTC)value := slog.TimeValue(now)- got := formatSlogValue(value)+ got := formatSlogValueInternal(value)// Should be quoted and contain the dateif !strings.HasPrefix(got, "\"") || !strings.HasSuffix(got, "\"") {- t.Errorf("formatSlogValue(time) should be quoted, got %q", got)+ t.Errorf("formatSlogValueInternal(time) should be quoted, got %q", got)}if !strings.Contains(got, "2024") {- t.Errorf("formatSlogValue(time) should contain year, got %q", got)+ t.Errorf("formatSlogValueInternal(time) should contain year, got %q", got)}}func TestFormatSlogValue_Duration(t *testing.T) {value := slog.DurationValue(5 * time.Second)- got := formatSlogValue(value)+ got := formatSlogValueInternal(value)// Should be quoted and contain duration stringif !strings.HasPrefix(got, "\"") || !strings.HasSuffix(got, "\"") {- t.Errorf("formatSlogValue(duration) should be quoted, got %q", got)+ t.Errorf("formatSlogValueInternal(duration) should be quoted, got %q", got)}if !strings.Contains(got, "5s") {- t.Errorf("formatSlogValue(duration) should contain duration, got %q", got)+ t.Errorf("formatSlogValueInternal(duration) should contain duration, got %q", got)}}func TestMultiHandler_Enabled(t *testing.T) {var buf1, buf2 bytes.Buffer- handler1 := newMessageOnlyHandler(&buf1, slog.LevelInfo)- handler2 := newMessageOnlyHandler(&buf2, slog.LevelWarn)+ handler1 := newMessageOnlyHandlerInternal(&buf1, slog.LevelInfo)+ handler2 := newMessageOnlyHandlerInternal(&buf2, slog.LevelWarn)multi := slog.NewMultiHandler(handler1, handler2)@@ -301,8 +301,8 @@ func TestMultiHandler_Enabled(t *testing.T) {func TestMultiHandler_Handle(t *testing.T) {var buf1, buf2 bytes.Buffer- handler1 := newMessageOnlyHandler(&buf1, slog.LevelInfo)- handler2 := newMessageOnlyHandler(&buf2, slog.LevelInfo)+ handler1 := newMessageOnlyHandlerInternal(&buf1, slog.LevelInfo)+ handler2 := newMessageOnlyHandlerInternal(&buf2, slog.LevelInfo)multi := slog.NewMultiHandler(handler1, handler2)@@ -322,8 +322,8 @@ func TestMultiHandler_Handle(t *testing.T) {func TestMultiHandler_WithAttrs(t *testing.T) {var buf1, buf2 bytes.Buffer- handler1 := newMessageOnlyHandler(&buf1, slog.LevelInfo)- handler2 := newMessageOnlyHandler(&buf2, slog.LevelInfo)+ handler1 := newMessageOnlyHandlerInternal(&buf1, slog.LevelInfo)+ handler2 := newMessageOnlyHandlerInternal(&buf2, slog.LevelInfo)multi := slog.NewMultiHandler(handler1, handler2)@@ -344,8 +344,8 @@ func TestMultiHandler_WithAttrs(t *testing.T) {func TestMultiHandler_WithGroup(t *testing.T) {var buf1, buf2 bytes.Buffer- handler1 := newMessageOnlyHandler(&buf1, slog.LevelInfo)- handler2 := newMessageOnlyHandler(&buf2, slog.LevelInfo)+ handler1 := newMessageOnlyHandlerInternal(&buf1, slog.LevelInfo)+ handler2 := newMessageOnlyHandlerInternal(&buf2, slog.LevelInfo)multi := slog.NewMultiHandler(handler1, handler2)@@ -366,20 +366,20 @@ func TestMultiHandler_WithGroup(t *testing.T) {func TestNewMessageOnlyHandler(t *testing.T) {var buf bytes.Buffer- handler := newMessageOnlyHandler(&buf, slog.LevelInfo)+ handler := newMessageOnlyHandlerInternal(&buf, slog.LevelInfo)if handler.minLevel != slog.LevelInfo {- t.Errorf("newMessageOnlyHandler() minLevel = %v, want %v", handler.minLevel, slog.LevelInfo)+ t.Errorf("newMessageOnlyHandlerInternal() minLevel = %v, want %v", handler.minLevel, slog.LevelInfo)}if handler.mu == nil {- t.Error("newMessageOnlyHandler() did not initialize mutex")+ t.Error("newMessageOnlyHandlerInternal() did not initialize mutex")}}func TestMessageOnlyHandler_MultipleMessages(t *testing.T) {var buf bytes.Buffer- handler := newMessageOnlyHandler(&buf, slog.LevelInfo)+ handler := newMessageOnlyHandlerInternal(&buf, slog.LevelInfo)messages := []string{"First message",diff --git a/backend/pkg/utils/distribution/distribution.go b/backend/pkg/libarcane/imageupdate/registry_http.gosimilarity index 89%rename from backend/pkg/utils/distribution/distribution.gorename to backend/pkg/libarcane/imageupdate/registry_http.goindex d96d7a4da..79be592c9 100644--- a/backend/pkg/utils/distribution/distribution.go+++ b/backend/pkg/libarcane/imageupdate/registry_http.go@@ -1,4 +1,4 @@-package distribution+package imageupdateimport ("context"@@ -12,12 +12,11 @@ import ("strings""time"- "github.com/getarcaneapp/arcane/backend/pkg/utils/imagedigest"+ "github.com/getarcaneapp/arcane/backend/pkg/libarcane/registryauth"ref "go.podman.io/image/v5/docker/reference")const defaultRegistryHost = "registry-1.docker.io"-const dockerHubRateLimitRepository = "ratelimitpreview/test"// trustedAuthDelegations maps registry hosts to their trusted external auth realm hosts.// Some registries serve images under their own domain but delegate token auth to a@@ -50,13 +49,14 @@ type Reference struct {}func NormalizeReference(imageRef string) (*Reference, error) {- named, err := ref.ParseNormalizedNamed(strings.TrimSpace(imageRef))- if err != nil {- return nil, fmt.Errorf("invalid image reference %q: %w", imageRef, err)+ trimmed := strings.TrimSpace(imageRef)+ if before, _, ok := strings.Cut(trimmed, "@"); ok {+ trimmed = before}- if _, ok := named.(ref.Digested); ok {- return nil, fmt.Errorf("digest-pinned references are not supported for distribution inspect: %q", imageRef)+ named, err := ref.ParseNormalizedNamed(trimmed)+ if err != nil {+ return nil, fmt.Errorf("invalid image reference %q: %w", imageRef, err)}registryHost := normalizeRegistryForComparisonInternal(ref.Domain(named))@@ -128,24 +128,9 @@ func IsFallbackEligibleDaemonError(err error) bool {return false}-func FetchDigest(ctx context.Context, registryHost, repository, tag string, credential *Credentials) (string, error) {- return FetchDigestWithHTTPClient(ctx, registryHost, repository, tag, credential, nil)-}--// FetchDockerHubRateLimit fetches Docker Hub pull rate limit information.-func FetchDockerHubRateLimit(ctx context.Context, credential *Credentials) (*RateLimitInfo, error) {- return FetchDockerHubRateLimitWithHTTPClient(ctx, credential, nil)-}--// FetchDockerHubRateLimitWithHTTPClient fetches Docker Hub pull rate limit-// information using the provided HTTP client.-func FetchDockerHubRateLimitWithHTTPClient(ctx context.Context, credential *Credentials, httpClient *http.Client) (*RateLimitInfo, error) {- return FetchRegistryRateLimitWithHTTPClient(ctx, "docker.io", dockerHubRateLimitRepository, "latest", credential, httpClient)-}--// FetchRegistryRateLimitWithHTTPClient fetches pull rate limit information from-// an OCI registry manifest response.-func FetchRegistryRateLimitWithHTTPClient(ctx context.Context, registryHost, repository, tag string, credential *Credentials, httpClient *http.Client) (*RateLimitInfo, error) {+// FetchRegistryRateLimit fetches pull rate limit information from an OCI+// registry manifest response.+func FetchRegistryRateLimit(ctx context.Context, registryHost, repository, tag string, credential *Credentials, httpClient *http.Client) (*RateLimitInfo, error) {if httpClient == nil {httpClient = NewRegistryHTTPClient()}@@ -179,7 +164,7 @@ func FetchRegistryRateLimitWithHTTPClient(ctx context.Context, registryHost, repreturn extractRateLimitFromHeadersInternal(resp.Header)}-func FetchDigestWithHTTPClient(ctx context.Context, registryHost, repository, tag string, credential *Credentials, httpClient *http.Client) (string, error) {+func FetchDigest(ctx context.Context, registryHost, repository, tag string, credential *Credentials, httpClient *http.Client) (string, error) {if httpClient == nil {httpClient = NewRegistryHTTPClient()}@@ -426,12 +411,12 @@ func basicAuthHeaderInternal(username, token string) string {}func extractDigestFromHeadersInternal(headers http.Header) string {- if normalized, err := imagedigest.Normalize(headers.Get("Docker-Content-Digest")); err == nil {+ if normalized, err := NormalizeDigest(headers.Get("Docker-Content-Digest")); err == nil {return normalized}etag := strings.Trim(headers.Get("ETag"), `"`)- if normalized, err := imagedigest.Normalize(etag); err == nil {+ if normalized, err := NormalizeDigest(etag); err == nil {return normalized}@@ -634,19 +619,5 @@ func normalizeAuthRealmHostInternal(raw string) string {}func normalizeRegistryForComparisonInternal(raw string) string {- value := strings.TrimSpace(strings.ToLower(raw))- value = strings.TrimPrefix(value, "https://")- value = strings.TrimPrefix(value, "http://")- value = strings.TrimSuffix(value, "/")-- if slash := strings.Index(value, "/"); slash != -1 {- value = value[:slash]- }-- switch value {- case "docker.io", "registry-1.docker.io", "index.docker.io":- return "docker.io"- default:- return value- }+ return registryauth.NormalizeRegistryForComparison(raw)}diff --git a/backend/pkg/utils/distribution/distribution_test.go b/backend/pkg/libarcane/imageupdate/registry_http_test.gosimilarity index 88%rename from backend/pkg/utils/distribution/distribution_test.gorename to backend/pkg/libarcane/imageupdate/registry_http_test.goindex 5d201c381..35218ef3f 100644--- a/backend/pkg/utils/distribution/distribution_test.go+++ b/backend/pkg/libarcane/imageupdate/registry_http_test.go@@ -1,4 +1,4 @@-package distribution+package imageupdateimport ("context"@@ -58,7 +58,7 @@ func TestIsFallbackEligibleDaemonError(t *testing.T) {assert.False(t, IsFallbackEligibleDaemonError(nil))}-func TestFetchDigestWithHTTPClient_FallsBackToGetOnMethodNotAllowed(t *testing.T) {+func TestFetchDigest_FallsBackToGetOnMethodNotAllowed(t *testing.T) {var headCalls intvar getCalls intwantDigest := digest.FromString("method-not-allowed").String()@@ -78,7 +78,7 @@ func TestFetchDigestWithHTTPClient_FallsBackToGetOnMethodNotAllowed(t *testing.T}))defer server.Close()- digest, err := FetchDigestWithHTTPClient(+ digest, err := FetchDigest(context.Background(),server.URL,"team/app",@@ -92,7 +92,7 @@ func TestFetchDigestWithHTTPClient_FallsBackToGetOnMethodNotAllowed(t *testing.Tassert.Equal(t, 1, getCalls)}-func TestFetchDigestWithHTTPClient_DoesNotFallbackToGetOnResourceErrors(t *testing.T) {+func TestFetchDigest_DoesNotFallbackToGetOnResourceErrors(t *testing.T) {testCases := []struct {name stringstatus int@@ -121,7 +121,7 @@ func TestFetchDigestWithHTTPClient_DoesNotFallbackToGetOnResourceErrors(t *testi}))defer server.Close()- digest, err := FetchDigestWithHTTPClient(+ digest, err := FetchDigest(context.Background(),server.URL,"team/app",@@ -138,7 +138,7 @@ func TestFetchDigestWithHTTPClient_DoesNotFallbackToGetOnResourceErrors(t *testi}}-func TestFetchRegistryRateLimitWithHTTPClient_AnonymousTokenFlow(t *testing.T) {+func TestFetchRegistryRateLimit_AnonymousTokenFlow(t *testing.T) {var tokenCalls intvar manifestCalls int@@ -167,7 +167,7 @@ func TestFetchRegistryRateLimitWithHTTPClient_AnonymousTokenFlow(t *testing.T) {}))defer server.Close()- info, err := FetchRegistryRateLimitWithHTTPClient(+ info, err := FetchRegistryRateLimit(context.Background(),server.URL,"team/app",@@ -190,7 +190,7 @@ func TestFetchRegistryRateLimitWithHTTPClient_AnonymousTokenFlow(t *testing.T) {assert.Equal(t, 2, manifestCalls)}-func TestFetchRegistryRateLimitWithHTTPClient_CredentialBackedTokenFlow(t *testing.T) {+func TestFetchRegistryRateLimit_CredentialBackedTokenFlow(t *testing.T) {var tokenAuth stringvar initialManifestAuth string@@ -215,7 +215,7 @@ func TestFetchRegistryRateLimitWithHTTPClient_CredentialBackedTokenFlow(t *testi}))defer server.Close()- info, err := FetchRegistryRateLimitWithHTTPClient(+ info, err := FetchRegistryRateLimit(context.Background(),server.URL,"team/app",@@ -233,40 +233,40 @@ func TestFetchRegistryRateLimitWithHTTPClient_CredentialBackedTokenFlow(t *testiassert.Contains(t, tokenAuth, "Basic ")}-func TestFetchRegistryRateLimitWithHTTPClient_MissingHeaders(t *testing.T) {+func TestFetchRegistryRateLimit_MissingHeaders(t *testing.T) {server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {w.WriteHeader(http.StatusOK)}))defer server.Close()- info, err := FetchRegistryRateLimitWithHTTPClient(context.Background(), server.URL, "team/app", "latest", nil, server.Client())+ info, err := FetchRegistryRateLimit(context.Background(), server.URL, "team/app", "latest", nil, server.Client())require.Error(t, err)assert.Nil(t, info)assert.Contains(t, err.Error(), "rate limit headers not returned")}-func TestFetchRegistryRateLimitWithHTTPClient_MalformedHeader(t *testing.T) {+func TestFetchRegistryRateLimit_MalformedHeader(t *testing.T) {server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {w.Header().Set("RateLimit-Limit", "bad;w=21600")w.WriteHeader(http.StatusOK)}))defer server.Close()- info, err := FetchRegistryRateLimitWithHTTPClient(context.Background(), server.URL, "team/app", "latest", nil, server.Client())+ info, err := FetchRegistryRateLimit(context.Background(), server.URL, "team/app", "latest", nil, server.Client())require.Error(t, err)assert.Nil(t, info)assert.Contains(t, err.Error(), "parse RateLimit-Limit")}-func TestFetchRegistryRateLimitWithHTTPClient_NonOKResponse(t *testing.T) {+func TestFetchRegistryRateLimit_NonOKResponse(t *testing.T) {server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {w.WriteHeader(http.StatusTooManyRequests)}))defer server.Close()- info, err := FetchRegistryRateLimitWithHTTPClient(context.Background(), server.URL, "team/app", "latest", nil, server.Client())+ info, err := FetchRegistryRateLimit(context.Background(), server.URL, "team/app", "latest", nil, server.Client())require.Error(t, err)assert.Nil(t, info)@@ -279,14 +279,14 @@ func TestParseWWWAuthInternal_AllowsCommasInsideQuotedRealm(t *testing.T) {assert.Equal(t, "registry.example.com", service)}-func TestFetchDigestWithHTTPClient_RejectsUntrustedTokenRealm(t *testing.T) {+func TestFetchDigest_RejectsUntrustedTokenRealm(t *testing.T) {registry := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {w.Header().Set("WWW-Authenticate", `Bearer realm="https://169.254.169.254/token",service="registry.example.com"`)w.WriteHeader(http.StatusUnauthorized)}))defer registry.Close()- digest, err := FetchDigestWithHTTPClient(+ digest, err := FetchDigest(context.Background(),registry.URL,"team/app",diff --git a/backend/pkg/libarcane/updater/sorter.go b/backend/pkg/libarcane/imageupdate/sorter.gosimilarity index 94%rename from backend/pkg/libarcane/updater/sorter.gorename to backend/pkg/libarcane/imageupdate/sorter.goindex 3faa16776..b8020b9a1 100644--- a/backend/pkg/libarcane/updater/sorter.go+++ b/backend/pkg/libarcane/imageupdate/sorter.go@@ -1,4 +1,4 @@-package updater+package imageupdateimport ("context"@@ -50,7 +50,7 @@ func NewContainerSorter(containers []ContainerWithDeps) *ContainerSorter {func (s *ContainerSorter) Sort() ([]ContainerWithDeps, error) {for _, c := range s.containers {if !s.visited[c.Name] {- if err := s.visit(c); err != nil {+ if err := s.visitInternal(c); err != nil {return nil, err}}@@ -70,7 +70,7 @@ func (s *ContainerSorter) SortReverse() ([]ContainerWithDeps, error) {return sorted, nil}-func (s *ContainerSorter) visit(c ContainerWithDeps) error {+func (s *ContainerSorter) visitInternal(c ContainerWithDeps) error {if s.marked[c.Name] {return fmt.Errorf("circular dependency detected: %s", c.Name)}@@ -82,10 +82,10 @@ func (s *ContainerSorter) visit(c ContainerWithDeps) error {defer delete(s.marked, c.Name)// Visit all dependencies first- allDeps := s.getAllDependencies(c)+ allDeps := s.getAllDependenciesInternal(c)for _, depName := range allDeps {if idx, ok := s.nameToIndex[depName]; ok {- if err := s.visit(s.containers[idx]); err != nil {+ if err := s.visitInternal(s.containers[idx]); err != nil {return err}}@@ -96,7 +96,7 @@ func (s *ContainerSorter) visit(c ContainerWithDeps) error {return nil}-func (s *ContainerSorter) getAllDependencies(c ContainerWithDeps) []string {+func (s *ContainerSorter) getAllDependenciesInternal(c ContainerWithDeps) []string {seen := make(map[string]struct{})var deps []stringdiff --git a/backend/pkg/libarcane/updater/sorter_test.go b/backend/pkg/libarcane/imageupdate/sorter_test.gosimilarity index 99%rename from backend/pkg/libarcane/updater/sorter_test.gorename to backend/pkg/libarcane/imageupdate/sorter_test.goindex f98609345..deaf83db9 100644--- a/backend/pkg/libarcane/updater/sorter_test.go+++ b/backend/pkg/libarcane/imageupdate/sorter_test.go@@ -1,4 +1,4 @@-package updater+package imageupdateimport ("testing"diff --git a/backend/pkg/libarcane/libbuild/builder_core.go b/backend/pkg/libarcane/libbuild/builder_core.goindex aa0df1d4a..ab8eb6960 100644--- a/backend/pkg/libarcane/libbuild/builder_core.go+++ b/backend/pkg/libarcane/libbuild/builder_core.go@@ -11,8 +11,8 @@ import ("github.com/docker/cli/cli/config"configtypes "github.com/docker/cli/cli/config/types"+ utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/libarcane/registryauth""github.com/getarcaneapp/arcane/backend/pkg/libarcane/timeouts"- utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry"buildtypes "github.com/getarcaneapp/arcane/types/builds"imagetypes "github.com/getarcaneapp/arcane/types/image"buildkit "github.com/moby/buildkit/client"diff --git a/backend/pkg/libarcane/libbuild/builder_core_test.go b/backend/pkg/libarcane/libbuild/builder_core_test.goindex 285ac027f..2d640bda7 100644--- a/backend/pkg/libarcane/libbuild/builder_core_test.go+++ b/backend/pkg/libarcane/libbuild/builder_core_test.go@@ -6,7 +6,7 @@ import ("testing"configtypes "github.com/docker/cli/cli/config/types"- utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/utils/registry"+ utilsregistry "github.com/getarcaneapp/arcane/backend/pkg/libarcane/registryauth""github.com/moby/buildkit/session/auth/authprovider"dockerregistry "github.com/moby/moby/api/types/registry""github.com/stretchr/testify/assert"diff --git a/backend/pkg/utils/registry/constants.go b/backend/pkg/libarcane/registryauth/constants.gosimilarity index 91%rename from backend/pkg/utils/registry/constants.gorename to backend/pkg/libarcane/registryauth/constants.goindex 3c3d9c5c9..77895551a 100644--- a/backend/pkg/utils/registry/constants.go+++ b/backend/pkg/libarcane/registryauth/constants.go@@ -1,4 +1,4 @@-package registry+package registryauthconst (DefaultRegistry = "registry-1.docker.io"diff --git a/backend/pkg/utils/registry/helpers.go b/backend/pkg/libarcane/registryauth/helpers.gosimilarity index 99%rename from backend/pkg/utils/registry/helpers.gorename to backend/pkg/libarcane/registryauth/helpers.goindex 3043955b2..8bf6258f1 100644--- a/backend/pkg/utils/registry/helpers.go+++ b/backend/pkg/libarcane/registryauth/helpers.go@@ -1,4 +1,4 @@-package registry+package registryauthimport ("fmt"diff --git a/backend/pkg/utils/registry/helpers_test.go b/backend/pkg/libarcane/registryauth/helpers_test.gosimilarity index 99%rename from backend/pkg/utils/registry/helpers_test.gorename to backend/pkg/libarcane/registryauth/helpers_test.goindex c68cd7a9b..eb5364175 100644--- a/backend/pkg/utils/registry/helpers_test.go+++ b/backend/pkg/libarcane/registryauth/helpers_test.go@@ -1,4 +1,4 @@-package registry+package registryauthimport ("testing"diff --git a/backend/pkg/libarcane/updater/digest_test.go b/backend/pkg/libarcane/updater/digest_test.godeleted file mode 100644index 64c67be6a..000000000--- a/backend/pkg/libarcane/updater/digest_test.go+++ /dev/null@@ -1,64 +0,0 @@-package updater--import (- "testing"-- digest "github.com/opencontainers/go-digest"- "github.com/stretchr/testify/assert"-)--func TestParseImageRef(t *testing.T) {- redisDigest := digest.FromString("redis").String()-- tests := []struct {- name string- imageRef string- wantHost string- wantRepo string- wantTag string- }{- {- name: "docker hub official image",- imageRef: "nginx:latest",- wantHost: "docker.io",- wantRepo: "library/nginx",- wantTag: "latest",- },- {- name: "custom registry image",- imageRef: "ghcr.io/getarcaneapp/arcane:v1.2.3",- wantHost: "ghcr.io",- wantRepo: "getarcaneapp/arcane",- wantTag: "v1.2.3",- },- {- name: "digest reference defaults to latest tag",- imageRef: "docker.io/library/redis@" + redisDigest,- wantHost: "docker.io",- wantRepo: "library/redis",- wantTag: "latest",- },- {- name: "docker registry variant is normalized",- imageRef: "registry-1.docker.io/library/busybox:1.36",- wantHost: "docker.io",- wantRepo: "library/busybox",- wantTag: "1.36",- },- }-- for _, tt := range tests {- t.Run(tt.name, func(t *testing.T) {- host, repo, tag := parseImageRef(tt.imageRef)- assert.Equal(t, tt.wantHost, host)- assert.Equal(t, tt.wantRepo, repo)- assert.Equal(t, tt.wantTag, tag)- })- }-}--func TestNormalizeRef(t *testing.T) {- assert.Equal(t, "docker.io/library/nginx:latest", normalizeRef("nginx"))- assert.Equal(t, "docker.io/library/nginx:latest", normalizeRef("index.docker.io/library/nginx:latest"))- assert.Equal(t, "ghcr.io/getarcaneapp/arcane:v1", normalizeRef("ghcr.io/getarcaneapp/arcane:v1"))-}diff --git a/backend/pkg/utils/imagedigest/digest.go b/backend/pkg/utils/imagedigest/digest.godeleted file mode 100644index d6e698791..000000000--- a/backend/pkg/utils/imagedigest/digest.go+++ /dev/null@@ -1,31 +0,0 @@-package imagedigest--import (- "fmt"- "strings"-- digest "github.com/opencontainers/go-digest"-)--func Normalize(value string) (string, error) {- parsed, err := digest.Parse(strings.TrimSpace(value))- if err != nil {- return "", fmt.Errorf("invalid OCI digest %q: %w", value, err)- }-- return parsed.String(), nil-}--func FromReferenceSuffix(ref string) (string, bool) {- _, digestValue, ok := strings.Cut(strings.TrimSpace(ref), "@")- if !ok {- return "", false- }-- normalized, err := Normalize(digestValue)- if err != nil {- return "", false- }-- return normalized, true-}diff --git a/backend/pkg/utils/imagedigest/digest_test.go b/backend/pkg/utils/imagedigest/digest_test.godeleted file mode 100644index 6015b9b3e..000000000--- a/backend/pkg/utils/imagedigest/digest_test.go+++ /dev/null@@ -1,35 +0,0 @@-package imagedigest--import (- "testing"-- digest "github.com/opencontainers/go-digest"- "github.com/stretchr/testify/assert"- "github.com/stretchr/testify/require"-)--func TestNormalize(t *testing.T) {- want := digest.FromString("arcane").String()-- got, err := Normalize(" " + want + " ")- require.NoError(t, err)- assert.Equal(t, want, got)-}--func TestNormalize_InvalidDigest(t *testing.T) {- _, err := Normalize("sha256:not-a-valid-digest")- require.Error(t, err)-}--func TestFromReferenceSuffix(t *testing.T) {- want := digest.FromString("arcane-reference").String()-- got, ok := FromReferenceSuffix("docker.io/library/nginx@" + want)- require.True(t, ok)- assert.Equal(t, want, got)-}--func TestFromReferenceSuffix_InvalidDigest(t *testing.T) {- _, ok := FromReferenceSuffix("docker.io/library/nginx@sha256:bad")- assert.False(t, ok)-}