Merge pull request #837 from narayanan/image-with-port

Fix for #831 - Ignore domain when finding the image tag
This commit is contained in:
Kubernetes Prow Robot
2019-03-04 11:21:14 -08:00
committed by GitHub
2 changed files with 20 additions and 1 deletions

View File

@@ -143,7 +143,18 @@ func isImageMatched(s, t string) bool {
// from the image string using either colon `:` or at `@` separators.
// Note that the returned tag keeps its separator.
func split(imageName string) (name string, tag string) {
ic := strings.LastIndex(imageName, ":")
// check if image name contains a domain
// if domain is present, ignore domain and check for `:`
ic := -1
if slashIndex := strings.Index(imageName, "/"); slashIndex < 0 {
ic = strings.LastIndex(imageName, ":")
} else {
lastIc := strings.LastIndex(imageName[slashIndex:], ":")
// set ic only if `:` is present
if lastIc > 0 {
ic = slashIndex + lastIc
}
}
ia := strings.LastIndex(imageName, "@")
if ic < 0 && ia < 0 {
return imageName, ""

View File

@@ -118,6 +118,10 @@ func TestImageTransformer(t *testing.T) {
"name": "myimage",
"image": "myprivaterepohostname:1234/my/image:latest",
},
map[string]interface{}{
"name": "myimage2",
"image": "myprivaterepohostname:1234/my/image",
},
map[string]interface{}{
"name": "my-app",
"image": "my-app-image:v1",
@@ -218,6 +222,10 @@ func TestImageTransformer(t *testing.T) {
"name": "myimage",
"image": "myprivaterepohostname:1234/my/image:v1.0.1",
},
map[string]interface{}{
"name": "myimage2",
"image": "myprivaterepohostname:1234/my/image:v1.0.1",
},
map[string]interface{}{
"name": "my-app",
"image": "gcr.io/my-project/my-app-image:v1",