aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/volume_prune.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2019-02-05 10:41:55 -0800
committerDaniel J Walsh <dwalsh@redhat.com>2019-02-05 10:41:55 -0800
commit74d984e0560b2cb421287395b025687e3aabe118 (patch)
tree97de4a88cb4c201b3a69b15767aa79c55c3a9b6e /cmd/podman/volume_prune.go
parent650e242aa90fcb3f161da6e97921c606d3083215 (diff)
downloadpodman-74d984e0560b2cb421287395b025687e3aabe118.tar.gz
podman-74d984e0560b2cb421287395b025687e3aabe118.tar.bz2
podman-74d984e0560b2cb421287395b025687e3aabe118.zip
Add podman system prune and info commands
We are missing the equivalence of the docker system commands This patch set adds `podman system prune` and `podman system info` Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/volume_prune.go')
-rw-r--r--cmd/podman/volume_prune.go48
1 files changed, 26 insertions, 22 deletions
diff --git a/cmd/podman/volume_prune.go b/cmd/podman/volume_prune.go
index 652c50f42..41d95f9c7 100644
--- a/cmd/podman/volume_prune.go
+++ b/cmd/podman/volume_prune.go
@@ -2,12 +2,13 @@ package main
import (
"bufio"
+ "context"
"fmt"
"os"
"strings"
- "github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/adapter"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
@@ -37,21 +38,40 @@ var volumePruneCommand = cli.Command{
UseShortOptionHandling: true,
}
-func volumePruneCmd(c *cli.Context) error {
+func volumePrune(runtime *adapter.LocalRuntime, ctx context.Context) error {
var lastError error
+ volumes, err := runtime.GetAllVolumes()
+ if err != nil {
+ return err
+ }
+
+ for _, vol := range volumes {
+ err = runtime.RemoveVolume(ctx, vol, false, true)
+ if err == nil {
+ fmt.Println(vol.Name())
+ } else if err != libpod.ErrVolumeBeingUsed {
+ if lastError != nil {
+ logrus.Errorf("%q", lastError)
+ }
+ lastError = errors.Wrapf(err, "failed to remove volume %q", vol.Name())
+ }
+ }
+ return lastError
+}
+
+func volumePruneCmd(c *cli.Context) error {
+
if err := validateFlags(c, volumePruneFlags); err != nil {
return err
}
- runtime, err := libpodruntime.GetRuntime(c)
+ runtime, err := adapter.GetRuntime(c)
if err != nil {
return errors.Wrapf(err, "error creating libpod runtime")
}
defer runtime.Shutdown(false)
- ctx := getContext()
-
// Prompt for confirmation if --force is not set
if !c.Bool("force") {
reader := bufio.NewReader(os.Stdin)
@@ -66,21 +86,5 @@ func volumePruneCmd(c *cli.Context) error {
}
}
- volumes, err := runtime.GetAllVolumes()
- if err != nil {
- return err
- }
-
- for _, vol := range volumes {
- err = runtime.RemoveVolume(ctx, vol, false, true)
- if err == nil {
- fmt.Println(vol.Name())
- } else if err != libpod.ErrVolumeBeingUsed {
- if lastError != nil {
- logrus.Errorf("%q", lastError)
- }
- lastError = errors.Wrapf(err, "failed to remove volume %q", vol.Name())
- }
- }
- return lastError
+ return volumePrune(runtime, getContext())
}