From 54f74cccd0c48992a335a82e962ecb6dd5feaee0 Mon Sep 17 00:00:00 2001 From: Krzysztof Taraszka Date: Sun, 25 Feb 2024 18:46:45 +0100 Subject: [PATCH] anonymous func to run defer in a block --- plugins/registry/functions.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/registry/functions.go b/plugins/registry/functions.go index 708b71894..95cab0bb0 100644 --- a/plugins/registry/functions.go +++ b/plugins/registry/functions.go @@ -117,14 +117,18 @@ 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 !dockerRemoveTag(extraTagImage) { + common.LogWarn(fmt.Sprintf("Unable to untag extra tag %s", extraTag)) + } + }() + }() common.LogVerboseQuiet(fmt.Sprintf("Pushing %s", extraTagImage)) if !dockerPush(extraTagImage) { return errors.New(fmt.Sprintf("Unable to push image with %s tag", extraTag)) } - common.LogVerboseQuiet(fmt.Sprintf("Untagging extra tag %s", extraTag)) - if !dockerRemoveTag(extraTagImage) { - return errors.New(fmt.Sprintf("Unable to untag extra tag %s", extraTag)) - } } }