mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 08:20:59 +00:00
Merge pull request #837 from narayanan/image-with-port
Fix for #831 - Ignore domain when finding the image tag
This commit is contained in:
@@ -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, ""
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user