File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,18 @@ func isImageMatched(s, t string) bool {
143
143
// from the image string using either colon `:` or at `@` separators.
144
144
// Note that the returned tag keeps its separator.
145
145
func split (imageName string ) (name string , tag string ) {
146
- ic := strings .LastIndex (imageName , ":" )
146
+ // check if image name contains a domain
147
+ // if domain is present, ignore domain and check for `:`
148
+ ic := - 1
149
+ if slashIndex := strings .Index (imageName , "/" ); slashIndex < 0 {
150
+ ic = strings .LastIndex (imageName , ":" )
151
+ } else {
152
+ lastIc := strings .LastIndex (imageName [slashIndex :], ":" )
153
+ // set ic only if `:` is present
154
+ if lastIc > 0 {
155
+ ic = slashIndex + lastIc
156
+ }
157
+ }
147
158
ia := strings .LastIndex (imageName , "@" )
148
159
if ic < 0 && ia < 0 {
149
160
return imageName , ""
Original file line number Diff line number Diff line change @@ -118,6 +118,10 @@ func TestImageTransformer(t *testing.T) {
118
118
"name" : "myimage" ,
119
119
"image" : "myprivaterepohostname:1234/my/image:latest" ,
120
120
},
121
+ map [string ]interface {}{
122
+ "name" : "myimage2" ,
123
+ "image" : "myprivaterepohostname:1234/my/image" ,
124
+ },
121
125
map [string ]interface {}{
122
126
"name" : "my-app" ,
123
127
"image" : "my-app-image:v1" ,
@@ -218,6 +222,10 @@ func TestImageTransformer(t *testing.T) {
218
222
"name" : "myimage" ,
219
223
"image" : "myprivaterepohostname:1234/my/image:v1.0.1" ,
220
224
},
225
+ map [string ]interface {}{
226
+ "name" : "myimage2" ,
227
+ "image" : "myprivaterepohostname:1234/my/image:v1.0.1" ,
228
+ },
221
229
map [string ]interface {}{
222
230
"name" : "my-app" ,
223
231
"image" : "gcr.io/my-project/my-app-image:v1" ,
You can’t perform that action at this time.
0 commit comments