summaryrefslogtreecommitdiff
path: root/cmd/podman/volume_prune.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-02-11 15:36:24 -0600
committerbaude <bbaude@redhat.com>2019-02-14 10:55:05 -0600
commit5be818e715d57f98e4a930632bc599e3fee3aaed (patch)
treecde8eb83111a17d6c081c4f25cae4d751b6313a5 /cmd/podman/volume_prune.go
parent0cd22435964573231ab32e545d5f319821b35b14 (diff)
downloadpodman-5be818e715d57f98e4a930632bc599e3fee3aaed.tar.gz
podman-5be818e715d57f98e4a930632bc599e3fee3aaed.tar.bz2
podman-5be818e715d57f98e4a930632bc599e3fee3aaed.zip
enable podman-remote volume prune
allow users to remotely prune volumes. this is the last volume command for remote enablement. as such, the volume commands are being folded back into main because they are supported for both local and remote clients. also, enable all volume tests that do not use containers as containers are not enabled for the remote client yet. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/volume_prune.go')
-rw-r--r--cmd/podman/volume_prune.go29
1 files changed, 12 insertions, 17 deletions
diff --git a/cmd/podman/volume_prune.go b/cmd/podman/volume_prune.go
index 74228fa5b..a2205140f 100644
--- a/cmd/podman/volume_prune.go
+++ b/cmd/podman/volume_prune.go
@@ -8,7 +8,6 @@ import (
"strings"
"github.com/containers/libpod/cmd/podman/cliconfig"
- "github.com/containers/libpod/libpod"
"github.com/containers/libpod/libpod/adapter"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -44,23 +43,20 @@ func init() {
}
func volumePrune(runtime *adapter.LocalRuntime, ctx context.Context) error {
- var lastError error
-
- volumes, err := runtime.GetAllVolumes()
- if err != nil {
- return err
+ prunedNames, prunedErrors := runtime.PruneVolumes(ctx)
+ for _, name := range prunedNames {
+ fmt.Println(name)
+ }
+ if len(prunedErrors) == 0 {
+ return nil
}
+ // Grab the last error
+ lastError := prunedErrors[len(prunedErrors)-1]
+ // Remove the last error from the error slice
+ prunedErrors = prunedErrors[:len(prunedErrors)-1]
- 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())
- }
+ for _, err := range prunedErrors {
+ logrus.Errorf("%q", err)
}
return lastError
}
@@ -85,6 +81,5 @@ func volumePruneCmd(c *cliconfig.VolumePruneValues) error {
return nil
}
}
-
return volumePrune(runtime, getContext())
}