summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/images_prune.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-03-25 14:40:21 -0700
committerGitHub <noreply@github.com>2021-03-25 14:40:21 -0700
commit9e23e0b3e3b219cbdc42fac4f843d6d2ec97421b (patch)
tree6986b66d1aa4e37999ffd091900b9a487e87d202 /pkg/api/handlers/compat/images_prune.go
parent8eb36320ca321ba514b5388cfdb11595e61a7d49 (diff)
parent429a655866ba6298935a2fb53cd6e1e8653bab4d (diff)
downloadpodman-9e23e0b3e3b219cbdc42fac4f843d6d2ec97421b.tar.gz
podman-9e23e0b3e3b219cbdc42fac4f843d6d2ec97421b.tar.bz2
podman-9e23e0b3e3b219cbdc42fac4f843d6d2ec97421b.zip
Merge pull request #9810 from jmguzik/fix-impages-filter-http-api
Fix filters list/prune in image http compat/libpod api endpoints
Diffstat (limited to 'pkg/api/handlers/compat/images_prune.go')
-rw-r--r--pkg/api/handlers/compat/images_prune.go19
1 files changed, 6 insertions, 13 deletions
diff --git a/pkg/api/handlers/compat/images_prune.go b/pkg/api/handlers/compat/images_prune.go
index 63daaa780..ddf559ec6 100644
--- a/pkg/api/handlers/compat/images_prune.go
+++ b/pkg/api/handlers/compat/images_prune.go
@@ -8,8 +8,8 @@ import (
"github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/pkg/api/handlers"
"github.com/containers/podman/v3/pkg/api/handlers/utils"
+ "github.com/containers/podman/v3/pkg/util"
"github.com/docker/docker/api/types"
- "github.com/gorilla/schema"
"github.com/pkg/errors"
)
@@ -17,27 +17,20 @@ func PruneImages(w http.ResponseWriter, r *http.Request) {
var (
filters []string
)
- decoder := r.Context().Value("decoder").(*schema.Decoder)
runtime := r.Context().Value("runtime").(*libpod.Runtime)
- query := struct {
- All bool
- Filters map[string][]string `schema:"filters"`
- }{
- // This is where you can override the golang default value for one of fields
- }
-
- if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
+ filterMap, err := util.PrepareFilters(r)
+ if err != nil {
+ utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
return
}
- for k, v := range query.Filters {
+ for k, v := range *filterMap {
for _, val := range v {
filters = append(filters, fmt.Sprintf("%s=%s", k, val))
}
}
- imagePruneReports, err := runtime.ImageRuntime().PruneImages(r.Context(), query.All, filters)
+ imagePruneReports, err := runtime.ImageRuntime().PruneImages(r.Context(), false, filters)
if err != nil {
utils.InternalServerError(w, err)
return