From bdf73cbed915cdb7c8db127f15eb71c34a38636e Mon Sep 17 00:00:00 2001 From: Aurel Canciu Date: Thu, 4 Nov 2021 21:32:05 +0100 Subject: [PATCH] Use strings.TrimRight to determine image name This is to prevent a slice bounds out of range error. Fixes #243 Signed-off-by: Aurel Canciu --- pkg/update/setters.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/update/setters.go b/pkg/update/setters.go index b70ef8eb..50b7e660 100644 --- a/pkg/update/setters.go +++ b/pkg/update/setters.go @@ -18,6 +18,7 @@ package update import ( "fmt" + "strings" "github.com/go-logr/logr" "github.com/google/go-containerregistry/pkg/name" @@ -159,7 +160,7 @@ func UpdateWithSetters(tracelog logr.Logger, inpath, outpath string, policies [] // annoyingly, neither the library imported above, nor an // alternative I found, will yield the original image name; // this is an easy way to get it - name := image[:len(image)-len(tag)-1] + name := strings.TrimRight(image, ":"+tag) imageSetter := fmt.Sprintf("%s:%s", policy.GetNamespace(), policy.GetName()) tracelog.Info("adding setter", "name", imageSetter)