From 881d16ea90d3b42b87bad19fcb991a662c9d7556 Mon Sep 17 00:00:00 2001 From: Krzysztof Taraszka Date: Sun, 25 Feb 2024 15:23:27 +0100 Subject: [PATCH] Untag extra image tag --- plugins/registry/functions.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/registry/functions.go b/plugins/registry/functions.go index c88639edf..c63e54362 100644 --- a/plugins/registry/functions.go +++ b/plugins/registry/functions.go @@ -120,7 +120,11 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e } common.LogVerboseQuiet(fmt.Sprintf("Pushing %s", extraTagImage)) if !dockerPush(extraTagImage) { - return errors.New(fmt.Sprintf("Unable to push image with %s tag", tag)) + 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)) } } } @@ -156,6 +160,17 @@ func dockerTag(imageID string, imageTag string) bool { return true } +func dockerRemoveTag(image string) bool { + cmd := sh.Command(common.DockerBin(), "image", "remove", image) + cmd.Stdout = nil + cmd.Stderr = nil + if err := cmd.Run(); err != nil { + return false + } + + return true +} + func dockerPush(imageTag string) bool { cmd := sh.Command(common.DockerBin(), "image", "push", imageTag) cmd.Stdout = os.Stdout