Skip to content

Commit c8de273

Browse files
committed
feat: add support for wildcard tags
1 parent a380d85 commit c8de273

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

internal/sync/images_tags.go

Lines changed: 21 additions & 3 deletions
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
"strings"
89

@@ -16,19 +17,36 @@ func getSourceTags(ctx context.Context, image *structs.Image, srcCtx *types.Syst
1617
var srcTags []string
1718
var err error
1819

20+
var allTags []string
21+
1922
if len(image.Tags) > 0 {
2023
for _, tag := range image.Tags {
2124
if tag == "@semver" {
22-
allTags, err := docker.GetRepositoryTags(ctx, srcCtx, srcRef)
23-
if err != nil {
24-
return nil, err
25+
if allTags == nil {
26+
allTags, err = docker.GetRepositoryTags(ctx, srcCtx, srcRef)
27+
if err != nil {
28+
return nil, err
29+
}
2530
}
2631

2732
for _, t := range allTags {
2833
if isSemVerTag(t) {
2934
srcTags = append(srcTags, t)
3035
}
3136
}
37+
} else if strings.Contains(tag, "*") {
38+
if allTags == nil {
39+
allTags, err = docker.GetRepositoryTags(ctx, srcCtx, srcRef)
40+
if err != nil {
41+
return nil, err
42+
}
43+
}
44+
45+
for _, t := range allTags {
46+
if match, err := filepath.Match(tag, t); err == nil && match {
47+
srcTags = append(srcTags, t)
48+
}
49+
}
3250
} else {
3351
srcTags = append(srcTags, tag)
3452
}

0 commit comments

Comments
 (0)