mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-11 17:12:51 +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.
|
// from the image string using either colon `:` or at `@` separators.
|
||||||
// Note that the returned tag keeps its separator.
|
// Note that the returned tag keeps its separator.
|
||||||
func split(imageName string) (name string, tag string) {
|
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, "@")
|
ia := strings.LastIndex(imageName, "@")
|
||||||
if ic < 0 && ia < 0 {
|
if ic < 0 && ia < 0 {
|
||||||
return imageName, ""
|
return imageName, ""
|
||||||
|
|||||||
@@ -118,6 +118,10 @@ func TestImageTransformer(t *testing.T) {
|
|||||||
"name": "myimage",
|
"name": "myimage",
|
||||||
"image": "myprivaterepohostname:1234/my/image:latest",
|
"image": "myprivaterepohostname:1234/my/image:latest",
|
||||||
},
|
},
|
||||||
|
map[string]interface{}{
|
||||||
|
"name": "myimage2",
|
||||||
|
"image": "myprivaterepohostname:1234/my/image",
|
||||||
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"name": "my-app",
|
"name": "my-app",
|
||||||
"image": "my-app-image:v1",
|
"image": "my-app-image:v1",
|
||||||
@@ -218,6 +222,10 @@ func TestImageTransformer(t *testing.T) {
|
|||||||
"name": "myimage",
|
"name": "myimage",
|
||||||
"image": "myprivaterepohostname:1234/my/image:v1.0.1",
|
"image": "myprivaterepohostname:1234/my/image:v1.0.1",
|
||||||
},
|
},
|
||||||
|
map[string]interface{}{
|
||||||
|
"name": "myimage2",
|
||||||
|
"image": "myprivaterepohostname:1234/my/image:v1.0.1",
|
||||||
|
},
|
||||||
map[string]interface{}{
|
map[string]interface{}{
|
||||||
"name": "my-app",
|
"name": "my-app",
|
||||||
"image": "gcr.io/my-project/my-app-image:v1",
|
"image": "gcr.io/my-project/my-app-image:v1",
|
||||||
|
|||||||
Reference in New Issue
Block a user