diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-02-14 22:52:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-14 22:52:03 +0100 |
commit | ae8cc41295c4ff6f6f82372221c66c250691e4f6 (patch) | |
tree | 197c210011a5c40a9beccafea8a22c52314f28de /cmd/podman/volume_prune.go | |
parent | 1a9128d1e4851df7c0316e0b861e70605fd262f6 (diff) | |
parent | 5be818e715d57f98e4a930632bc599e3fee3aaed (diff) | |
download | podman-ae8cc41295c4ff6f6f82372221c66c250691e4f6.tar.gz podman-ae8cc41295c4ff6f6f82372221c66c250691e4f6.tar.bz2 podman-ae8cc41295c4ff6f6f82372221c66c250691e4f6.zip |
Merge pull request #2332 from baude/remotevolumeprune
volume prune
Diffstat (limited to 'cmd/podman/volume_prune.go')
-rw-r--r-- | cmd/podman/volume_prune.go | 29 |
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()) } |