mirror of
https://github.com/containers/podman.git
synced 2025-06-03 03:07:56 +08:00
more image binding tests
add two additional bindings tests for image usage. add ability to use search filter on the endpoint. Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user