Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Merge pull request #110 from tobespc/0.3.1removeImages
Browse files Browse the repository at this point in the history
0.3.1remove images
  • Loading branch information
tobespc authored Sep 6, 2019
2 parents 9e6bdc2 + c8dbd2b commit c52f3e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
5 changes: 2 additions & 3 deletions actions/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@ import (
//RemoveCommand to remove all codewind and project images
func RemoveCommand(c *cli.Context) {
tag := c.String("tag")
imageArr := [5]string{}
imageArr := [4]string{}
imageArr[0] = "eclipse/codewind-pfe"
imageArr[1] = "eclipse/codewind-performance"
imageArr[2] = "eclipse/codewind-initialize"
imageArr[3] = "cw-"
imageArr[4] = "appsody"
networkName := "codewind"

if tag != "" {
for i := 0; i < len(imageArr); i++ {
if i == 3 || i == 4 {
if i == 3 {
break
}
imageArr[i] = imageArr[i] + "-amd64:" + tag
Expand Down
11 changes: 5 additions & 6 deletions actions/stop-all.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,22 @@ import (

//StopAllCommand to stop codewind and project containers
func StopAllCommand() {
containerArr := [2]string{}
containerArr := [4]string{}
containerArr[0] = "codewind-pfe"
containerArr[1] = "codewind-performance"
containerArr[0] = "cw-"
containerArr[1] = "appsody"
containerArr[2] = "cw-"
containerArr[3] = "appsody"

containers := utils.GetContainerList()

fmt.Println("Stopping Codewind and Project containers")
for _, container := range containers {
for _, key := range containerArr {
if strings.HasPrefix(container.Image, key) {
fmt.Println(container)
// stop appsody containers with "cw-" in their name, and all other cw containers
if key != "appsody" || strings.Contains(container.Names[0], "cw-") {
fmt.Println("Stopping container ", container.Names, "... ")
fmt.Println("Stopping container ", container.Names[0], "... ")
utils.StopContainer(container)
break
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions utils/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,13 @@ func StopContainer(container types.Container) {
errors.CheckErr(err, 108, "")
}

// Remove the container so it isnt lingering in the background
if err := cli.ContainerRemove(ctx, container.ID, types.ContainerRemoveOptions{}); err != nil {
errors.CheckErr(err, 108, "")
// Do not attempt to remove appsody images as that happens automatically
// when an appsody container stops
if !strings.HasPrefix(container.Image, "appsody") {
// Remove the container so it isnt lingering in the background
if err := cli.ContainerRemove(ctx, container.ID, types.ContainerRemoveOptions{}); err != nil {
errors.CheckErr(err, 108, "")
}
}
}

Expand Down

0 comments on commit c52f3e5

Please sign in to comment.