use common.RemoveImages
This commit is contained in:
1 parent
54f74cccd0
commit
00925b6c09
1 file changed
+3
-12
@@ -111,8 +111,10 @@ 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)
|
||||||
common.LogVerboseQuiet(fmt.Sprintf("Tagging %s as %s in registry format", imageRepo, extraTag))
|
common.LogVerboseQuiet(fmt.Sprintf("Tagging %s as %s in registry format", imageRepo, extraTag))
|
||||||
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))
|
||||||
@@ -120,7 +122,7 @@ func pushToRegistry(appName string, tag int, imageID string, imageRepo string) e
|
|||||||
func() {
|
func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
common.LogVerboseQuiet(fmt.Sprintf("Untagging extra tag %s", extraTag))
|
common.LogVerboseQuiet(fmt.Sprintf("Untagging extra tag %s", extraTag))
|
||||||
if !dockerRemoveTag(extraTagImage) {
|
if !common.RemoveImages(imagesToRemove) {
|
||||||
common.LogWarn(fmt.Sprintf("Unable to untag extra tag %s", extraTag))
|
common.LogWarn(fmt.Sprintf("Unable to untag extra tag %s", extraTag))
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@@ -163,17 +165,6 @@ func dockerTag(imageID string, imageTag string) bool {
|
|||||||
return true
|
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 {
|
func dockerPush(imageTag string) bool {
|
||||||
cmd := sh.Command(common.DockerBin(), "image", "push", imageTag)
|
cmd := sh.Command(common.DockerBin(), "image", "push", imageTag)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
|
|||||||
Reference in new issue
Block a user