File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -482,12 +482,18 @@ func GetPrefixFromEnv() string {
482482
483483// GetImage returns the image name with the prefix and override.
484484func GetImage (name string ) string {
485+ var image_namespace string
485486 prefix := GetPrefixFromEnv ()
486487 override := os .Getenv ("IMAGE_NAMESPACE_OVERRIDE" )
487- imagearray := strings .Split (name , "/" )
488- image_namespace := strings .Join (imagearray [0 :len (imagearray )- 1 ], "/" )
488+ imageArray := strings .Split (name , "/" )
489+ if len (imageArray ) == 1 {
490+ image_namespace = ""
491+ } else {
492+ image_namespace = strings .Join (imageArray [0 :len (imageArray )- 1 ], "/" ) + "/"
493+ }
489494 if len (override ) > 0 {
490- image_namespace = override
495+ image_namespace = override + "/"
491496 }
492- return prefix + image_namespace + "/" + imagearray [len (imagearray )- 1 ]
497+
498+ return prefix + image_namespace + imageArray [len (imageArray )- 1 ]
493499}
Original file line number Diff line number Diff line change @@ -752,4 +752,13 @@ func TestGetImage(t *testing.T) {
752752 result := GetImage (testCase )
753753 assert .Equal (t , want , result )
754754 }
755+ {
756+ // No image namespace
757+ t .Setenv ("IMAGE_PREFIX" , "" )
758+ t .Setenv ("IMAGE_NAMESPACE_OVERRIDE" , "" )
759+ testCase := "busybox:1.32"
760+ want := "busybox:1.32"
761+ result := GetImage (testCase )
762+ assert .Equal (t , want , result )
763+ }
755764}
You can’t perform that action at this time.
0 commit comments