diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-02-21 16:51:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-21 16:51:23 +0100 |
commit | 28d6eeb57a46b8df8960cff6bf6748c4611b61ef (patch) | |
tree | afbedcfd6da81a0d4d924c8360a220241775e0db /cmd/podman/pod_rm.go | |
parent | fc1b1ff6919b257739371079097803b0cb1b3ed2 (diff) | |
parent | e91ec38a70f4755d06972a0b65edd1f2e5366581 (diff) | |
download | podman-28d6eeb57a46b8df8960cff6bf6748c4611b61ef.tar.gz podman-28d6eeb57a46b8df8960cff6bf6748c4611b61ef.tar.bz2 podman-28d6eeb57a46b8df8960cff6bf6748c4611b61ef.zip |
Merge pull request #2387 from baude/remotepodrm
enable podman-remote pod rm
Diffstat (limited to 'cmd/podman/pod_rm.go')
-rw-r--r-- | cmd/podman/pod_rm.go | 38 |
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 } |