anonymous func to run defer in a block

This commit is contained in:
Krzysztof Taraszka
2024-02-25 18:46:45 +01:00
parent 5af90b76a3
commit 54f74cccd0

View File

@@ -117,14 +117,18 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e
if !dockerTag(imageID, extraTagImage) { if !dockerTag(imageID, extraTagImage) {
return errors.New(fmt.Sprintf("Unable to tag image as %s", extraTag)) 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)) common.LogVerboseQuiet(fmt.Sprintf("Pushing %s", extraTagImage))
if !dockerPush(extraTagImage) { if !dockerPush(extraTagImage) {
return errors.New(fmt.Sprintf("Unable to push image with %s tag", extraTag)) 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))
}
} }
} }