summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/compat/containers_prune.go
diff options
context:
space:
mode:
authorJakub Guzik <jakubmguzik@gmail.com>2021-03-20 22:56:01 +0100
committerJakub Guzik <jakubmguzik@gmail.com>2021-03-20 22:56:01 +0100
commit907b34c46fe474911d4321795f029583e8daeeec (patch)
treeb2f2628b6553dbaa0210e73686d9978ffc0afec5 /pkg/api/handlers/compat/containers_prune.go
parentebc9871c9358b41daefc37e5db8119f596770cb7 (diff)
downloadpodman-907b34c46fe474911d4321795f029583e8daeeec.tar.gz
podman-907b34c46fe474911d4321795f029583e8daeeec.tar.bz2
podman-907b34c46fe474911d4321795f029583e8daeeec.zip
Fix containers list/prune http api filter behaviour
The problem described in #9711 and followed by #9758 affects containers as well. When user provides wrong filter input, error message should occur, not fallback to full list/prune command. This change fixes the issue. Additionally, there are error message fixes for docker http api compat. Signed-off-by: Jakub Guzik <jakubmguzik@gmail.com>
Diffstat (limited to 'pkg/api/handlers/compat/containers_prune.go')
-rw-r--r--pkg/api/handlers/compat/containers_prune.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/pkg/api/handlers/compat/containers_prune.go b/pkg/api/handlers/compat/containers_prune.go
index dc4d53af6..e37929d27 100644
--- a/pkg/api/handlers/compat/containers_prune.go
+++ b/pkg/api/handlers/compat/containers_prune.go
@@ -9,23 +9,20 @@ import (
"github.com/containers/podman/v3/pkg/api/handlers/utils"
"github.com/containers/podman/v3/pkg/domain/entities/reports"
"github.com/containers/podman/v3/pkg/domain/filters"
- "github.com/gorilla/schema"
+ "github.com/containers/podman/v3/pkg/util"
"github.com/pkg/errors"
)
func PruneContainers(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value("runtime").(*libpod.Runtime)
- decoder := r.Context().Value("decoder").(*schema.Decoder)
-
- query := struct {
- Filters map[string][]string `schema:"filters"`
- }{}
- 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()))
+ filtersMap, 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
}
- filterFuncs := make([]libpod.ContainerFilter, 0, len(query.Filters))
- for k, v := range query.Filters {
+
+ filterFuncs := make([]libpod.ContainerFilter, 0, len(*filtersMap))
+ for k, v := range *filtersMap {
generatedFunc, err := filters.GenerateContainerFilterFuncs(k, v, runtime)
if err != nil {
utils.InternalServerError(w, err)