diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-10-23 09:22:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-23 09:22:03 -0700 |
commit | c019830a750d3c2cdb20d2568c9e0f9fdc35165e (patch) | |
tree | ffd123dcfa33f64a27d783eb70edf9332f2bc30f /cmd/podman/cleanup.go | |
parent | 41a8bbdbe01d76d39a7a670ac17df1d3da8b28d5 (diff) | |
parent | e8d69030b621874159176eb67292ce06632ea2fd (diff) | |
download | podman-c019830a750d3c2cdb20d2568c9e0f9fdc35165e.tar.gz podman-c019830a750d3c2cdb20d2568c9e0f9fdc35165e.tar.bz2 podman-c019830a750d3c2cdb20d2568c9e0f9fdc35165e.zip |
Merge pull request #1662 from adrianreber/all-and-latest
Add --all and --latest to checkpoint/restore
Diffstat (limited to 'cmd/podman/cleanup.go')
-rw-r--r-- | cmd/podman/cleanup.go | 40 |
1 files changed, 5 insertions, 35 deletions
diff --git a/cmd/podman/cleanup.go b/cmd/podman/cleanup.go index 3fd150783..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" ) @@ -44,43 +43,14 @@ func cleanupCmd(c *cli.Context) error { } defer runtime.Shutdown(false) - args := c.Args() + if err := checkAllAndLatest(c); err != nil { + return err + } + + cleanupContainers, lastError := getAllOrLatestContainers(c, runtime, -1, "all") ctx := getContext() - var lastError error - var cleanupContainers []*libpod.Container - if c.Bool("all") { - if c.Bool("lastest") { - return errors.New("--all and --latest cannot be used together") - } - if len(args) != 0 { - return errors.New("--all and explicit container IDs cannot be used together") - } - cleanupContainers, err = runtime.GetContainers() - if err != nil { - return errors.Wrapf(err, "unable to get container list") - } - } else if c.Bool("latest") { - if len(args) != 0 { - return errors.New("--latest and explicit container IDs cannot be used together") - } - lastCtr, err := runtime.GetLatestContainer() - if err != nil { - return errors.Wrapf(err, "unable to get latest container") - } - cleanupContainers = append(cleanupContainers, lastCtr) - } else { - 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) - } - } for _, ctr := range cleanupContainers { if err = ctr.Cleanup(ctx); err != nil { if lastError != nil { |