mirror of
https://github.com/containers/podman.git
synced 2025-06-24 19:42:56 +08:00
Merge pull request #6878 from skorhone/fix/docker_v1_24_image_list_compatibility
Add support for Filter query parameter to list images api
This commit is contained in:
@ -60,6 +60,7 @@ func GetImages(w http.ResponseWriter, r *http.Request) ([]*image.Image, error) {
|
|||||||
All bool
|
All bool
|
||||||
Filters map[string][]string `schema:"filters"`
|
Filters map[string][]string `schema:"filters"`
|
||||||
Digests bool
|
Digests bool
|
||||||
|
Filter string // Docker 1.24 compatibility
|
||||||
}{
|
}{
|
||||||
// This is where you can override the golang default value for one of fields
|
// 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
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(query.Filters) > 0 {
|
queryFilters := query.Filters
|
||||||
for k, v := range 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, "=")))
|
filters = append(filters, fmt.Sprintf("%s=%s", k, strings.Join(v, "=")))
|
||||||
}
|
}
|
||||||
images, err = runtime.ImageRuntime().GetImagesWithFilters(filters)
|
images, err = runtime.ImageRuntime().GetImagesWithFilters(filters)
|
||||||
|
@ -26,6 +26,14 @@ t GET libpod/images/${iid:0:12}/json 200 \
|
|||||||
.Id=$iid \
|
.Id=$iid \
|
||||||
.RepoTags[0]=$IMAGE
|
.RepoTags[0]=$IMAGE
|
||||||
|
|
||||||
|
# Docker API V1.24 filter parameter compatibility
|
||||||
|
t GET images/json?filter=$IMAGE 200 \
|
||||||
|
length=1 \
|
||||||
|
.[0].Names[0]=$IMAGE
|
||||||
|
|
||||||
|
# Negative test case
|
||||||
|
t GET images/json?filter=nonesuch 200 length=0
|
||||||
|
|
||||||
# FIXME: docker API incompatibility: libpod returns 'id', docker 'sha256:id'
|
# FIXME: docker API incompatibility: libpod returns 'id', docker 'sha256:id'
|
||||||
t GET images/$iid/json 200 \
|
t GET images/$iid/json 200 \
|
||||||
.Id=sha256:$iid \
|
.Id=sha256:$iid \
|
||||||
|
Reference in New Issue
Block a user