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/checkpoint.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/checkpoint.go')
-rw-r--r-- | cmd/podman/checkpoint.go | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/cmd/podman/checkpoint.go b/cmd/podman/checkpoint.go index 8582ce138..bf280920d 100644 --- a/cmd/podman/checkpoint.go +++ b/cmd/podman/checkpoint.go @@ -6,6 +6,7 @@ import ( "os" "github.com/containers/libpod/cmd/podman/libpodruntime" + "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/rootless" "github.com/pkg/errors" "github.com/urfave/cli" @@ -22,6 +23,11 @@ var ( Name: "keep, k", Usage: "keep all temporary checkpoint files", }, + cli.BoolFlag{ + Name: "all, a", + Usage: "checkpoint all running containers", + }, + LatestFlag, } checkpointCommand = cli.Command{ Name: "checkpoint", @@ -45,21 +51,14 @@ func checkpointCmd(c *cli.Context) error { defer runtime.Shutdown(false) keep := c.Bool("keep") - args := c.Args() - if len(args) < 1 { - return errors.Errorf("you must provide at least one container name or id") + + if err := checkAllAndLatest(c); err != nil { + return err } - var lastError error - for _, arg := range args { - ctr, err := runtime.LookupContainer(arg) - if err != nil { - if lastError != nil { - fmt.Fprintln(os.Stderr, lastError) - } - lastError = errors.Wrapf(err, "error looking up container %q", arg) - continue - } + containers, lastError := getAllOrLatestContainers(c, runtime, libpod.ContainerStateRunning, "running") + + for _, ctr := range containers { if err = ctr.Checkpoint(context.TODO(), keep); err != nil { if lastError != nil { fmt.Fprintln(os.Stderr, lastError) |