@@ -4,10 +4,10 @@ import (
4
4
"strings"
5
5
"time"
6
6
7
+ "github.com/distribution/distribution/v3/reference"
8
+
7
9
"github.com/argoproj-labs/argocd-image-updater/pkg/log"
8
10
"github.com/argoproj-labs/argocd-image-updater/pkg/tag"
9
-
10
- "github.com/distribution/distribution/v3/reference"
11
11
)
12
12
13
13
type ContainerImage struct {
@@ -95,12 +95,13 @@ func (img *ContainerImage) GetFullNameWithTag() string {
95
95
}
96
96
str += img .ImageName
97
97
if img .ImageTag != nil {
98
+ if img .ImageTag .TagName != "" {
99
+ str += ":"
100
+ str += img .ImageTag .TagName
101
+ }
98
102
if img .ImageTag .TagDigest != "" {
99
103
str += "@"
100
104
str += img .ImageTag .TagDigest
101
- } else if img .ImageTag .TagName != "" {
102
- str += ":"
103
- str += img .ImageTag .TagName
104
105
}
105
106
}
106
107
return str
@@ -223,10 +224,22 @@ func getImageTagFromIdentifier(identifier string) (string, string, *tag.ImageTag
223
224
imageString = strings .Join (comp [1 :], "/" )
224
225
}
225
226
226
- // We can either have a tag name or a digest reference
227
+ // We can either have a tag name or a digest reference, or both
228
+ // jannfis/test-image:0.1
229
+ // gcr.io/jannfis/test-image:0.1
230
+ // gcr.io/jannfis/test-image@sha256:abcde
231
+ // gcr.io/jannfis/test-image:test-tag@sha256:abcde
227
232
if strings .Contains (imageString , "@" ) {
228
233
comp = strings .SplitN (imageString , "@" , 2 )
229
- return sourceName , comp [0 ], tag .NewImageTag ("" , time .Unix (0 , 0 ), comp [1 ])
234
+ colonPos := strings .LastIndex (comp [0 ], ":" )
235
+ slashPos := strings .LastIndex (comp [0 ], "/" )
236
+ if colonPos > slashPos {
237
+ // first half (before @) contains image and tag name
238
+ return sourceName , comp [0 ][:colonPos ], tag .NewImageTag (comp [0 ][colonPos + 1 :], time .Unix (0 , 0 ), comp [1 ])
239
+ } else {
240
+ // first half contains image name without tag name
241
+ return sourceName , comp [0 ], tag .NewImageTag ("" , time .Unix (0 , 0 ), comp [1 ])
242
+ }
230
243
} else {
231
244
comp = strings .SplitN (imageString , ":" , 2 )
232
245
if len (comp ) != 2 {
0 commit comments