diff options
author | Korhonen Sami (Samlink) <k847259@ubuntu.saminet.fi> | 2020-07-07 11:31:32 +0300 |
---|---|---|
committer | Korhonen Sami (Samlink) <k847259@ubuntu.saminet.fi> | 2020-07-07 13:05:16 +0300 |
commit | 610118d9bf4ee28d50d3042d9578b3cef24fd86e (patch) | |
tree | aa186a20b09e7ca2662e123f942122dc4c9eabb6 /pkg/api | |
parent | 1a93857acc4ee1e5a9213e2c22f12802d84cd277 (diff) | |
download | podman-610118d9bf4ee28d50d3042d9578b3cef24fd86e.tar.gz podman-610118d9bf4ee28d50d3042d9578b3cef24fd86e.tar.bz2 podman-610118d9bf4ee28d50d3042d9578b3cef24fd86e.zip |
Add support for Filter query parameter to list images api
Docker api version 1.24 uses a query parameter named Filter
for filtering images by names. In more recent versions of
api name filter is in filters query parameter with other
filters
This patch adds a mapping that translates Filter query
parameter to Filters={"reference": [""]}
Signed-off-by: Sami Korhonen <skorhone@gmail.com>
Diffstat (limited to 'pkg/api')
-rw-r--r-- | pkg/api/handlers/utils/images.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/pkg/api/handlers/utils/images.go b/pkg/api/handlers/utils/images.go index 195e71b75..bf981b547 100644 --- a/pkg/api/handlers/utils/images.go +++ b/pkg/api/handlers/utils/images.go @@ -60,6 +60,7 @@ func GetImages(w http.ResponseWriter, r *http.Request) ([]*image.Image, error) { 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 } @@ -76,8 +77,16 @@ func GetImages(w http.ResponseWriter, r *http.Request) ([]*image.Image, error) { err error ) - if len(query.Filters) > 0 { - for k, v := range query.Filters { + queryFilters := query.Filters + if !IsLibpodRequest(r) && len(query.Filter) > 0 { // Docker 1.24 compatibility + if queryFilters == nil { + queryFilters = make(map[string][]string) + } + queryFilters["reference"] = append(queryFilters["reference"], query.Filter) + } + + if len(queryFilters) > 0 { + for k, v := range queryFilters { filters = append(filters, fmt.Sprintf("%s=%s", k, strings.Join(v, "="))) } images, err = runtime.ImageRuntime().GetImagesWithFilters(filters) |