fun() wrapper is not necessary; removed imagesToRemove array

This commit is contained in:
Krzysztof Taraszka committed 2024-02-25 20:34:34 +01:00
1 parent 00925b6c09
commit 58fd25ebf4
1 file changed
+2 -5
+2 -5
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,14 +118,12 @@ 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 !common.RemoveImages(imagesToRemove) { if err := common.RemoveImages(extraTagImage); err != nil {
common.LogWarn(fmt.Sprintf("Unable to untag extra tag %s", extraTag)) common.LogWarn(fmt.Sprintf("Unable to untag extra tag %s", extraTag, err.Error()))
} }
}() }()
}()
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))