summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/volumes.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-12-14 09:22:30 -0500
committerGitHub <noreply@github.com>2020-12-14 09:22:30 -0500
commite5741b984ed438e4c716eec67c83b3c927a97ebb (patch)
treeb4805b1a2a01cdb00bbb1f237ac194196fe446ae /pkg/api/handlers/compat/volumes.go
parentbdbf47f606fbb592d563d33ddf3b7200c8607bf2 (diff)
parenta0204ada0974343cbf6eefe988ef35cdfe28fb52 (diff)
downloadpodman-e5741b984ed438e4c716eec67c83b3c927a97ebb.tar.gz
podman-e5741b984ed438e4c716eec67c83b3c927a97ebb.tar.bz2
podman-e5741b984ed438e4c716eec67c83b3c927a97ebb.zip
Merge pull request #8689 from bblenard/issue-8672-volume-prune
Add volume prune --filter support
Diffstat (limited to 'pkg/api/handlers/compat/volumes.go')
-rw-r--r--pkg/api/handlers/compat/volumes.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/pkg/api/handlers/compat/volumes.go b/pkg/api/handlers/compat/volumes.go
index 71b848932..f76e18ee3 100644
--- a/pkg/api/handlers/compat/volumes.go
+++ b/pkg/api/handlers/compat/volumes.go
@@ -3,6 +3,7 @@ package compat
import (
"encoding/json"
"net/http"
+ "net/url"
"time"
"github.com/containers/podman/v2/libpod"
@@ -254,14 +255,15 @@ func PruneVolumes(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
- // TODO: We have no ability to pass pruning filters to `PruneVolumes()` so
- // we'll explicitly reject the request if we see any
- if len(query.Filters) > 0 {
- utils.InternalServerError(w, errors.New("filters for pruning volumes is not implemented"))
+
+ f := (url.Values)(query.Filters)
+ filterFuncs, err := filters.GenerateVolumeFilters(f)
+ if err != nil {
+ utils.Error(w, "Something when wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse filters for %s", f.Encode()))
return
}
- pruned, err := runtime.PruneVolumes(r.Context())
+ pruned, err := runtime.PruneVolumes(r.Context(), filterFuncs)
if err != nil {
utils.InternalServerError(w, err)
return