From 58fd25ebf47f7c5b083cb00bb4fc8e81e25b191b Mon Sep 17 00:00:00 2001 From: Krzysztof Taraszka Date: Sun, 25 Feb 2024 20:34:34 +0100 Subject: [PATCH] fun() wrapper is not necessary; removed imagesToRemove array --- plugins/registry/functions.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/plugins/registry/functions.go b/plugins/registry/functions.go index 253b8651b..95f704637 100644 --- a/plugins/registry/functions.go +++ b/plugins/registry/functions.go @@ -111,7 +111,6 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e extraTags := getRegistryPushExtraTagsForApp(appName) if extraTags != "" { extraTagsArray := strings.Split(extraTags, ",") - imagesToRemove := []string{} for _, extraTag := range extraTagsArray { extraTagImage := fmt.Sprintf("%s%s:%s", registryServer, imageRepo, extraTag) imagesToRemove = append(imagesToRemove, extraTagImage) @@ -119,13 +118,11 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e if !dockerTag(imageID, extraTagImage) { return errors.New(fmt.Sprintf("Unable to tag image as %s", extraTag)) } - func() { - defer func() { - common.LogVerboseQuiet(fmt.Sprintf("Untagging extra tag %s", extraTag)) - if !common.RemoveImages(imagesToRemove) { - common.LogWarn(fmt.Sprintf("Unable to untag extra tag %s", extraTag)) - } - }() + defer func() { + common.LogVerboseQuiet(fmt.Sprintf("Untagging extra tag %s", extraTag)) + if err := common.RemoveImages(extraTagImage); err != nil { + common.LogWarn(fmt.Sprintf("Unable to untag extra tag %s", extraTag, err.Error())) + } }() common.LogVerboseQuiet(fmt.Sprintf("Pushing %s", extraTagImage)) if !dockerPush(extraTagImage) {