Skip to content

Commit 487feae

Browse files
committed
refactor: enhance tag destination determination logic
1 parent c8de273 commit 487feae

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

internal/sync/images_sync.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package sync
33
import (
44
"context"
55
"fmt"
6+
"path/filepath"
67
"slices"
78

89
"github.com/Altinity/docker-sync/internal/telemetry"
@@ -29,8 +30,15 @@ func syncTag(ctx context.Context, image *structs.Image, tag string, dstTags []st
2930

3031
var actualDsts []string
3132

33+
// Determine the actual destinations for the tag
3234
for _, dst := range image.Targets {
33-
if !slices.Contains(image.MutableTags, tag) && slices.Contains(dstTags, fmt.Sprintf("%s:%s", dst, tag)) && !slices.Contains(image.MutableTags, "*") {
35+
if !slices.Contains(image.MutableTags, tag) && // Explicitly mutable tags
36+
slices.Contains(dstTags, fmt.Sprintf("%s:%s", dst, tag)) && // Check if the tag already exists in the target
37+
!slices.ContainsFunc(image.MutableTags, func(t string) bool {
38+
match, _ := filepath.Match(t, tag)
39+
return match
40+
}) && // Check if the tag matches any mutable tag patterns
41+
!slices.Contains(image.MutableTags, "*") { // All tags are mutable if "*" is present
3442
continue
3543
}
3644

0 commit comments

Comments
 (0)