diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2019-02-19 16:29:14 +0100 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2019-02-20 10:25:25 +0100 |
commit | 6ae4401bd1c7988b84c6e1f715ca85ad74ee4048 (patch) | |
tree | f31b1150514ca1a1bfa64fc1ba1effb857d0c537 /pkg | |
parent | 8a49b59ed403b25340f315b3cb9ea90482ad6cd9 (diff) | |
download | podman-6ae4401bd1c7988b84c6e1f715ca85ad74ee4048.tar.gz podman-6ae4401bd1c7988b84c6e1f715ca85ad74ee4048.tar.bz2 podman-6ae4401bd1c7988b84c6e1f715ca85ad74ee4048.zip |
iopodman.SearchImages: add ImageSearchFilter to Varlink API
Also add some argument checks to the Varlink function to avoid
referencing nil pointers, and complement the API.md descriptions.
The varlink endpoint can be tested via varlink CLI:
$ varlink call -m unix:/run/podman/io.podman/io.podman.SearchImages \
'{"query": "ruby", "limit": 0, "tlsVerify": false, "filter": {}}'
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/varlinkapi/images.go | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go index 032160b1b..d12ab97ab 100644 --- a/pkg/varlinkapi/images.go +++ b/pkg/varlinkapi/images.go @@ -434,16 +434,36 @@ func (i *LibpodAPI) RemoveImage(call iopodman.VarlinkCall, name string, force bo // SearchImages searches all registries configured in /etc/containers/registries.conf for an image // Requires an image name and a search limit as int -func (i *LibpodAPI) SearchImages(call iopodman.VarlinkCall, query string, limit *int64, tlsVerify *bool, filter []string) error { - sFilter, err := image.ParseSearchFilter(filter) - if err != nil { - return call.ReplyErrorOccurred(err.Error()) +func (i *LibpodAPI) SearchImages(call iopodman.VarlinkCall, query string, limit *int64, tlsVerify *bool, filter iopodman.ImageSearchFilter) error { + // Transform all arguments to proper types first + argLimit := 0 + argTLSVerify := types.OptionalBoolUndefined + argIsOfficial := types.OptionalBoolUndefined + argIsAutomated := types.OptionalBoolUndefined + if limit != nil { + argLimit = int(*limit) + } + if tlsVerify != nil { + argTLSVerify = types.NewOptionalBool(!*tlsVerify) + } + if filter.Is_official != nil { + argIsOfficial = types.NewOptionalBool(*filter.Is_official) + } + if filter.Is_automated != nil { + argIsAutomated = types.NewOptionalBool(*filter.Is_automated) + } + + // Transform a SearchFilter the backend can deal with + sFilter := image.SearchFilter{ + IsOfficial: argIsOfficial, + IsAutomated: argIsAutomated, + Stars: int(filter.Star_count), } searchOptions := image.SearchOptions{ - Limit: 1000, - Filter: *sFilter, - InsecureSkipTLSVerify: types.NewOptionalBool(!*tlsVerify), + Limit: argLimit, + Filter: sFilter, + InsecureSkipTLSVerify: argTLSVerify, } results, err := image.SearchImages(query, searchOptions) if err != nil { |