diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-12-14 09:22:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-14 09:22:30 -0500 |
commit | e5741b984ed438e4c716eec67c83b3c927a97ebb (patch) | |
tree | b4805b1a2a01cdb00bbb1f237ac194196fe446ae /pkg/api/handlers/libpod | |
parent | bdbf47f606fbb592d563d33ddf3b7200c8607bf2 (diff) | |
parent | a0204ada0974343cbf6eefe988ef35cdfe28fb52 (diff) | |
download | podman-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/libpod')
-rw-r--r-- | pkg/api/handlers/libpod/volumes.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/pkg/api/handlers/libpod/volumes.go b/pkg/api/handlers/libpod/volumes.go index b0d40fd8b..b02a6a8ce 100644 --- a/pkg/api/handlers/libpod/volumes.go +++ b/pkg/api/handlers/libpod/volumes.go @@ -3,6 +3,7 @@ package libpod import ( "encoding/json" "net/http" + "net/url" "github.com/containers/podman/v2/libpod" "github.com/containers/podman/v2/libpod/define" @@ -180,8 +181,25 @@ func PruneVolumes(w http.ResponseWriter, r *http.Request) { func pruneVolumesHelper(r *http.Request) ([]*entities.VolumePruneReport, error) { var ( runtime = r.Context().Value("runtime").(*libpod.Runtime) + decoder = r.Context().Value("decoder").(*schema.Decoder) ) - pruned, err := runtime.PruneVolumes(r.Context()) + query := struct { + Filters map[string][]string `schema:"filters"` + }{ + // override any golang type defaults + } + + if err := decoder.Decode(&query, r.URL.Query()); err != nil { + return nil, err + } + + f := (url.Values)(query.Filters) + filterFuncs, err := filters.GenerateVolumeFilters(f) + if err != nil { + return nil, err + } + + pruned, err := runtime.PruneVolumes(r.Context(), filterFuncs) if err != nil { return nil, err } |