aboutsummaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-02-24 17:09:24 +0100
committerGitHub <noreply@github.com>2020-02-24 17:09:24 +0100
commit2602083f6282b13407569ce8df593fd7703442e0 (patch)
tree25348acfba805f9aa2220267eacbc2d680f2c364 /pkg/api
parent18dcb84d641f4e8ae7fa31fa446d9461e0c915ab (diff)
parentd92b9b88595b030245d5d74b096ce605b5ae2db7 (diff)
downloadpodman-2602083f6282b13407569ce8df593fd7703442e0.tar.gz
podman-2602083f6282b13407569ce8df593fd7703442e0.tar.bz2
podman-2602083f6282b13407569ce8df593fd7703442e0.zip
Merge pull request #5301 from baude/apiv2imagetests3
more image binding tests
Diffstat (limited to 'pkg/api')
-rw-r--r--pkg/api/handlers/images.go33
1 files changed, 30 insertions, 3 deletions
diff --git a/pkg/api/handlers/images.go b/pkg/api/handlers/images.go
index 96bcbdc96..2086ce748 100644
--- a/pkg/api/handlers/images.go
+++ b/pkg/api/handlers/images.go
@@ -7,6 +7,7 @@ import (
"os"
"strconv"
+ "github.com/containers/image/v5/types"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/libpod/image"
"github.com/containers/libpod/pkg/api/handlers/utils"
@@ -147,10 +148,36 @@ func SearchImages(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse parameters for %s", r.URL.String()))
return
}
- // TODO filters are a bit undefined here in terms of what exactly the input looks
- // like. We need to understand that a bit more.
+
+ filter := image.SearchFilter{}
+ if len(query.Filters) > 0 {
+ if len(query.Filters["stars"]) > 0 {
+ stars, err := strconv.Atoi(query.Filters["stars"][0])
+ if err != nil {
+ utils.InternalServerError(w, err)
+ return
+ }
+ filter.Stars = stars
+ }
+ if len(query.Filters["is-official"]) > 0 {
+ isOfficial, err := strconv.ParseBool(query.Filters["is-official"][0])
+ if err != nil {
+ utils.InternalServerError(w, err)
+ return
+ }
+ filter.IsOfficial = types.NewOptionalBool(isOfficial)
+ }
+ if len(query.Filters["is-automated"]) > 0 {
+ isAutomated, err := strconv.ParseBool(query.Filters["is-automated"][0])
+ if err != nil {
+ utils.InternalServerError(w, err)
+ return
+ }
+ filter.IsAutomated = types.NewOptionalBool(isAutomated)
+ }
+ }
options := image.SearchOptions{
- Filter: image.SearchFilter{},
+ Filter: filter,
Limit: query.Limit,
}
results, err := image.SearchImages(query.Term, options)