diff options
author | Matthew Heon <matthew.heon@pm.me> | 2019-08-05 18:42:29 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-08-05 18:42:29 -0400 |
commit | 526c6c90daf1aad2bd2cd173d48b7f97a3d8278d (patch) | |
tree | a74c2825418a4386fa60fb6dc810aa7881a12669 /cmd | |
parent | 95b57cfb79f7654040649072bdc4b66813cfe6aa (diff) | |
download | podman-526c6c90daf1aad2bd2cd173d48b7f97a3d8278d.tar.gz podman-526c6c90daf1aad2bd2cd173d48b7f97a3d8278d.tar.bz2 podman-526c6c90daf1aad2bd2cd173d48b7f97a3d8278d.zip |
Backport rm --storage to Podman 1.0
This amounted to a near-complete rewrite in parts, but in the end
is a pretty simple change. The core functionality was already
review in #3330.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/rm.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/cmd/podman/rm.go b/cmd/podman/rm.go index 7c0569b78..d6978a460 100644 --- a/cmd/podman/rm.go +++ b/cmd/podman/rm.go @@ -21,6 +21,10 @@ var ( }, LatestFlag, cli.BoolFlag{ + Name: "storage", + Usage: "Remove container from storage library", + }, + cli.BoolFlag{ Name: "volumes, v", Usage: "Remove the volumes associated with the container (Not implemented yet)", }, @@ -62,6 +66,25 @@ func rmCmd(c *cli.Context) error { return err } + // Storage conflicts with --all/--latest/--volumes + if c.Bool("storage") { + if c.Bool("all") || c.Bool("latest") || c.Bool("volumes") { + return errors.Errorf("--storage conflicts with --volumes, --all, and --latest") + } + + var lastErr error + for _, ctr := range c.Args() { + if err := runtime.RemoveStorageContainer(ctr, c.Bool("force")); err != nil { + if lastErr != nil { + logrus.Errorf("Error removing container %s from storage: %v", ctr, lastErr) + } + lastErr = err + } + fmt.Printf("%s\n", ctr) + } + return lastErr + } + delContainers, err := getAllOrLatestContainers(c, runtime, -1, "all") if err != nil { if len(delContainers) == 0 { |