summaryrefslogtreecommitdiff
path: root/cmd/podman/cleanup.go
diff options
context:
space:
mode:
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()