summaryrefslogtreecommitdiff
path: root/cmd/podman/cleanup.go
diff options
context:
space:
mode:
authorAdrian Reber <areber@redhat.com>2018-10-16 16:39:11 +0000
committerAdrian Reber <adrian@lisas.de>2018-10-23 17:01:30 +0200
commitc10ac01395066ddeb321a83ab64bc02b2e765f9a (patch)
tree1f488b0e9b5c4ea210fd1f6e1e14aef57daf4ef0 /cmd/podman/cleanup.go
parentfea37b387c746471177f90f15b04d7735a88e621 (diff)
downloadpodman-c10ac01395066ddeb321a83ab64bc02b2e765f9a.tar.gz
podman-c10ac01395066ddeb321a83ab64bc02b2e765f9a.tar.bz2
podman-c10ac01395066ddeb321a83ab64bc02b2e765f9a.zip
Use the newly added getAllOrLatestContainers() function
This removes duplicate code paths which has been previously factored out as getAllOrLatestContainers(). Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'cmd/podman/cleanup.go')
-rw-r--r--cmd/podman/cleanup.go27
1 files changed, 1 insertions, 26 deletions
diff --git a/cmd/podman/cleanup.go b/cmd/podman/cleanup.go
index 1d8b2fbec..bc4af9f50 100644
--- a/cmd/podman/cleanup.go
+++ b/cmd/podman/cleanup.go
@@ -5,7 +5,6 @@ import (
"os"
"github.com/containers/libpod/cmd/podman/libpodruntime"
- "github.com/containers/libpod/libpod"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
@@ -48,31 +47,7 @@ func cleanupCmd(c *cli.Context) error {
return err
}
- var lastError error
- var cleanupContainers []*libpod.Container
- if c.Bool("all") {
- cleanupContainers, err = runtime.GetContainers()
- if err != nil {
- return errors.Wrapf(err, "unable to get container list")
- }
- } else if c.Bool("latest") {
- lastCtr, err := runtime.GetLatestContainer()
- if err != nil {
- return errors.Wrapf(err, "unable to get latest container")
- }
- cleanupContainers = append(cleanupContainers, lastCtr)
- } else {
- args := c.Args()
- for _, i := range args {
- container, err := runtime.LookupContainer(i)
- if err != nil {
- fmt.Fprintln(os.Stderr, err)
- lastError = errors.Wrapf(err, "unable to find container %s", i)
- continue
- }
- cleanupContainers = append(cleanupContainers, container)
- }
- }
+ cleanupContainers, lastError := getAllOrLatestContainers(c, runtime, -1, "all")
ctx := getContext()