From 526c6c90daf1aad2bd2cd173d48b7f97a3d8278d Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Mon, 5 Aug 2019 18:42:29 -0400 Subject: 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 --- cmd/podman/rm.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'cmd') 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 @@ -20,6 +20,10 @@ var ( Usage: "Force removal of a running container. The default is false", }, 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 { -- cgit v1.2.3-54-g00ecf