From 32ef22aebe21f6396d29af9806d16079fbec5f62 Mon Sep 17 00:00:00 2001 From: Elio Marcolino Date: Thu, 11 Jul 2019 11:22:25 -0700 Subject: [PATCH] Fixed image handing on mutating webhook for images with all 3 components --- cmd/kubenab/main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/kubenab/main.go b/cmd/kubenab/main.go index 0ed542e..0646288 100644 --- a/cmd/kubenab/main.go +++ b/cmd/kubenab/main.go @@ -162,7 +162,14 @@ func handleContainer(container *v1.Container, dockerRegistryUrl string) bool { message := fmt.Sprintf("Image is not being pulled from Private Registry: %s", container.Image) log.Printf(message) - newImage := dockerRegistryUrl + "/" + container.Image + imageParts := strings.Split(container.Image, "/") + newImage := "" + if len(imageParts) < 3 { + newImage = dockerRegistryUrl + "/" + container.Image + } else { + imageParts[0] = dockerRegistryUrl + newImage = strings.Join(imageParts, "/") + } log.Printf("Changing image registry to: %s", newImage) container.Image = newImage