mirror of
https://github.com/containers/podman.git
synced 2025-09-23 13:13:42 +08:00
Merge pull request #18345 from vrothberg/fix-18092
api: fix parsing filters
This commit is contained in:
@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/containers/podman/v4/pkg/auth"
|
"github.com/containers/podman/v4/pkg/auth"
|
||||||
"github.com/containers/podman/v4/pkg/domain/entities"
|
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||||
"github.com/containers/podman/v4/pkg/domain/infra/abi"
|
"github.com/containers/podman/v4/pkg/domain/infra/abi"
|
||||||
|
"github.com/containers/podman/v4/pkg/util"
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
"github.com/docker/docker/pkg/jsonmessage"
|
"github.com/docker/docker/pkg/jsonmessage"
|
||||||
"github.com/gorilla/schema"
|
"github.com/gorilla/schema"
|
||||||
@ -431,12 +432,22 @@ func GetImages(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
filterList, err := filters.FiltersFromRequest(r)
|
var filterList []string
|
||||||
|
var err error
|
||||||
|
if utils.IsLibpodRequest(r) {
|
||||||
|
// Podman clients split the filter map as `"{"label":["version","1.0"]}`
|
||||||
|
filterList, err = filters.FiltersFromRequest(r)
|
||||||
|
if err != nil {
|
||||||
|
utils.Error(w, http.StatusInternalServerError, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Docker clients split the filter map as `"{"label":["version=1.0"]}`
|
||||||
|
filterList, err = util.FiltersFromRequest(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Error(w, http.StatusInternalServerError, err)
|
utils.Error(w, http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !utils.IsLibpodRequest(r) {
|
|
||||||
if len(query.Filter) > 0 { // Docker 1.24 compatibility
|
if len(query.Filter) > 0 { // Docker 1.24 compatibility
|
||||||
filterList = append(filterList, "reference="+query.Filter)
|
filterList = append(filterList, "reference="+query.Filter)
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ from alpine
|
|||||||
RUN >file1
|
RUN >file1
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
podman image build -t test:test --label xyz -<<EOF
|
podman image build -t test:test --label xyz --label abc -<<EOF
|
||||||
from alpine
|
from alpine
|
||||||
RUN >file2
|
RUN >file2
|
||||||
EOF
|
EOF
|
||||||
@ -143,7 +143,7 @@ t POST images/prune?filters='{"dangling":["true"]}' 200
|
|||||||
t GET images/json?filters='{"dangling":["true"]}' 200 length=0
|
t GET images/json?filters='{"dangling":["true"]}' 200 length=0
|
||||||
|
|
||||||
#label filter check in libpod and compat
|
#label filter check in libpod and compat
|
||||||
t GET images/json?filters='{"label":["xyz"]}' 200 length=1
|
t GET images/json?filters='{"label":["xyz","abc"]}' 200 length=1
|
||||||
t GET libpod/images/json?filters='{"label":["xyz"]}' 200 length=1
|
t GET libpod/images/json?filters='{"label":["xyz"]}' 200 length=1
|
||||||
|
|
||||||
t DELETE libpod/images/test:test 200
|
t DELETE libpod/images/test:test 200
|
||||||
|
Reference in New Issue
Block a user