diff options
author | Jakub Guzik <jakubmguzik@gmail.com> | 2021-03-25 01:32:00 +0100 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2021-03-29 11:58:26 -0400 |
commit | 573ed9220b9b295eacdd017dc87bbb592043cff4 (patch) | |
tree | 0b96c575bd05acdd29671c3d04fe8f78c065ff55 /pkg/api/handlers/utils/images.go | |
parent | 1b349d79adc322b9df4a9c2cac49a4e42b301ef4 (diff) | |
download | podman-573ed9220b9b295eacdd017dc87bbb592043cff4.tar.gz podman-573ed9220b9b295eacdd017dc87bbb592043cff4.tar.bz2 podman-573ed9220b9b295eacdd017dc87bbb592043cff4.zip |
Fix filters in image http compat/libpod api endpoints
Signed-off-by: Jakub Guzik <jakubmguzik@gmail.com>
Diffstat (limited to 'pkg/api/handlers/utils/images.go')
-rw-r--r-- | pkg/api/handlers/utils/images.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/pkg/api/handlers/utils/images.go b/pkg/api/handlers/utils/images.go index 743629db8..da3c9e985 100644 --- a/pkg/api/handlers/utils/images.go +++ b/pkg/api/handlers/utils/images.go @@ -11,6 +11,7 @@ import ( "github.com/containers/image/v5/types" "github.com/containers/podman/v3/libpod" "github.com/containers/podman/v3/libpod/image" + "github.com/containers/podman/v3/pkg/util" "github.com/gorilla/schema" "github.com/pkg/errors" ) @@ -58,13 +59,17 @@ func GetImages(w http.ResponseWriter, r *http.Request) ([]*image.Image, error) { runtime := r.Context().Value("runtime").(*libpod.Runtime) query := struct { All bool - Filters map[string][]string `schema:"filters"` Digests bool Filter string // Docker 1.24 compatibility }{ // This is where you can override the golang default value for one of fields } + filterMap, err := util.PrepareFilters(r) + if err != nil { + return nil, err + } + if err := decoder.Decode(&query, r.URL.Query()); err != nil { return nil, err } @@ -72,12 +77,9 @@ func GetImages(w http.ResponseWriter, r *http.Request) ([]*image.Image, error) { if _, found := r.URL.Query()["digests"]; found && query.Digests { UnSupportedParameter("digests") } - var ( - images []*image.Image - err error - ) + var images []*image.Image - queryFilters := query.Filters + queryFilters := *filterMap if !IsLibpodRequest(r) && len(query.Filter) > 0 { // Docker 1.24 compatibility if queryFilters == nil { queryFilters = make(map[string][]string) |