summaryrefslogtreecommitdiff
path: root/cmd/podman/pod_rm.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-02-20 15:02:18 -0600
committerbaude <bbaude@redhat.com>2019-02-21 08:40:42 -0600
commite91ec38a70f4755d06972a0b65edd1f2e5366581 (patch)
tree4f5792f6662ebe43bee3331354c13585351eb81e /cmd/podman/pod_rm.go
parent4934bf23272f185fa9f08d0ba890c5a0eb4ed14d (diff)
downloadpodman-e91ec38a70f4755d06972a0b65edd1f2e5366581.tar.gz
podman-e91ec38a70f4755d06972a0b65edd1f2e5366581.tar.bz2
podman-e91ec38a70f4755d06972a0b65edd1f2e5366581.zip
enable podman-remote pod rm
add the ability to delete a pod from the remote client. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/pod_rm.go')
-rw-r--r--cmd/podman/pod_rm.go38
1 files changed, 16 insertions, 22 deletions
diff --git a/cmd/podman/pod_rm.go b/cmd/podman/pod_rm.go
index 54cee2a50..b615f88c9 100644
--- a/cmd/podman/pod_rm.go
+++ b/cmd/podman/pod_rm.go
@@ -2,9 +2,9 @@ package main
import (
"fmt"
+ "github.com/containers/libpod/libpod/adapter"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -42,36 +42,30 @@ func init() {
}
-// saveCmd saves the image to either docker-archive or oci
+// podRmCmd deletes pods
func podRmCmd(c *cliconfig.PodRmValues) error {
if err := checkMutuallyExclusiveFlags(&c.PodmanCommand); err != nil {
return err
}
-
- runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand)
+ runtime, err := adapter.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
defer runtime.Shutdown(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]
- ctx := getContext()
- force := c.Force
-
- // getPodsFromContext returns an error when a requested pod
- // isn't found. The only fatal error scenerio is when there are no pods
- // in which case the following loop will be skipped.
- pods, lastError := getPodsFromContext(&c.PodmanCommand, runtime)
-
- for _, pod := range pods {
- err = runtime.RemovePod(ctx, pod, force, force)
- if err != nil {
- if lastError != nil {
- logrus.Errorf("%q", lastError)
- }
- lastError = errors.Wrapf(err, "failed to delete pod %v", pod.ID())
- } else {
- fmt.Println(pod.ID())
- }
+ for _, err := range podRmErrors {
+ logrus.Errorf("%q", err)
}
return lastError
}