fun() wrapper is not necessary; removed imagesToRemove array

This commit is contained in:
Krzysztof Taraszka
2024-02-25 20:34:34 +01:00
parent 00925b6c09
commit 58fd25ebf4

View File

@@ -111,7 +111,6 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e
extraTags := getRegistryPushExtraTagsForApp(appName) extraTags := getRegistryPushExtraTagsForApp(appName)
if extraTags != "" { if extraTags != "" {
extraTagsArray := strings.Split(extraTags, ",") extraTagsArray := strings.Split(extraTags, ",")
imagesToRemove := []string{}
for _, extraTag := range extraTagsArray { for _, extraTag := range extraTagsArray {
extraTagImage := fmt.Sprintf("%s%s:%s", registryServer, imageRepo, extraTag) extraTagImage := fmt.Sprintf("%s%s:%s", registryServer, imageRepo, extraTag)
imagesToRemove = append(imagesToRemove, extraTagImage) imagesToRemove = append(imagesToRemove, extraTagImage)
@@ -119,13 +118,11 @@ 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() {
defer func() { common.LogVerboseQuiet(fmt.Sprintf("Untagging extra tag %s", extraTag))
common.LogVerboseQuiet(fmt.Sprintf("Untagging extra tag %s", extraTag)) if err := common.RemoveImages(extraTagImage); err != nil {
if !common.RemoveImages(imagesToRemove) { common.LogWarn(fmt.Sprintf("Unable to untag extra tag %s", extraTag, err.Error()))
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) {