summaryrefslogtreecommitdiff
path: root/cmd/podman/pod_rm.go
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-04-16 12:25:26 -0500
committerBrent Baude <bbaude@redhat.com>2020-04-16 15:53:58 -0500
commit241326a9a8c20ad7f2bcf651416b836e7778e090 (patch)
tree4001e8e47a022bb1b9bfbf2332c42e1aeb802f9e /cmd/podman/pod_rm.go
parent88c6fd06cd54fb9a8826306dfdf1a77e400de5de (diff)
downloadpodman-241326a9a8c20ad7f2bcf651416b836e7778e090.tar.gz
podman-241326a9a8c20ad7f2bcf651416b836e7778e090.tar.bz2
podman-241326a9a8c20ad7f2bcf651416b836e7778e090.zip
Podman V2 birth
remote podman v1 and replace with podman v2. Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/pod_rm.go')
-rw-r--r--cmd/podman/pod_rm.go74
1 files changed, 0 insertions, 74 deletions
diff --git a/cmd/podman/pod_rm.go b/cmd/podman/pod_rm.go
deleted file mode 100644
index 02daf8764..000000000
--- a/cmd/podman/pod_rm.go
+++ /dev/null
@@ -1,74 +0,0 @@
-package main
-
-import (
- "fmt"
-
- "github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/pkg/adapter"
- "github.com/pkg/errors"
- "github.com/sirupsen/logrus"
- "github.com/spf13/cobra"
-)
-
-var (
- podRmCommand cliconfig.PodRmValues
- podRmDescription = fmt.Sprintf(`podman rm will remove one or more stopped pods and their containers from the host.
-
- The pod name or ID can be used. A pod with containers will not be removed without --force. If --force is specified, all containers will be stopped, then removed.`)
- _podRmCommand = &cobra.Command{
- Use: "rm [flags] POD [POD...]",
- Short: "Remove one or more pods",
- Long: podRmDescription,
- RunE: func(cmd *cobra.Command, args []string) error {
- podRmCommand.InputArgs = args
- podRmCommand.GlobalFlags = MainGlobalOpts
- podRmCommand.Remote = remoteclient
- return podRmCmd(&podRmCommand)
- },
- Args: func(cmd *cobra.Command, args []string) error {
- return checkAllLatestAndCIDFile(cmd, args, false, false)
- },
- Example: `podman pod rm mywebserverpod
- podman pod rm -f 860a4b23
- podman pod rm -f -a`,
- }
-)
-
-func init() {
- podRmCommand.Command = _podRmCommand
- podRmCommand.SetHelpTemplate(HelpTemplate())
- podRmCommand.SetUsageTemplate(UsageTemplate())
- flags := podRmCommand.Flags()
- flags.BoolVarP(&podRmCommand.All, "all", "a", false, "Remove all running pods")
- flags.BoolVarP(&podRmCommand.Force, "force", "f", false, "Force removal of a running pod by first stopping all containers, then removing all containers in the pod. The default is false")
- flags.BoolVarP(&podRmCommand.Ignore, "ignore", "i", false, "Ignore errors when a specified pod is missing")
- flags.BoolVarP(&podRmCommand.Latest, "latest", "l", false, "Remove the latest pod podman is aware of")
- markFlagHiddenForRemoteClient("ignore", flags)
- markFlagHiddenForRemoteClient("latest", flags)
-}
-
-// podRmCmd deletes pods
-func podRmCmd(c *cliconfig.PodRmValues) error {
- runtime, err := adapter.GetRuntime(getContext(), &c.PodmanCommand)
- if err != nil {
- return errors.Wrapf(err, "could not get runtime")
- }
- defer runtime.DeferredShutdown(false)
-
- podRmIds, podRmErrors := runtime.RemovePods(getContext(), c)
- for _, p := range podRmIds {
- fmt.Println(p)
- }
- if len(podRmErrors) == 0 {
- return nil
- }
- // Grab the last error
- lastError := podRmErrors[len(podRmErrors)-1]
- // Remove the last error from the error slice
- podRmErrors = podRmErrors[:len(podRmErrors)-1]
-
- for _, err := range podRmErrors {
- logrus.Errorf("%q", err)
- }
- return lastError
-}