summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatej Marusak <mmarusak@redhat.com>2020-02-17 18:43:37 +0100
committerMatej Marusak <mmarusak@redhat.com>2020-02-17 18:44:46 +0100
commitd08e0c728f8c2bf2185265b35d8e7b6acfd221f0 (patch)
tree9a2192427c7a43e43a5e97a1a6ae0afe5f6ef298 /libpod
parentff0f8388138f7b66c4312db0e984f0bedcac2558 (diff)
downloadpodman-d08e0c728f8c2bf2185265b35d8e7b6acfd221f0.tar.gz
podman-d08e0c728f8c2bf2185265b35d8e7b6acfd221f0.tar.bz2
podman-d08e0c728f8c2bf2185265b35d8e7b6acfd221f0.zip
apiv2: Enable filtering images by ID
It is more practical for API usage and also it is more in sync how filtering of containers works. Signed-off-by: Matej Marusak <mmarusak@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/image/filters.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/libpod/image/filters.go b/libpod/image/filters.go
index d545f1bfc..de10f9443 100644
--- a/libpod/image/filters.go
+++ b/libpod/image/filters.go
@@ -102,6 +102,13 @@ func ReferenceFilter(ctx context.Context, referenceFilter string) ResultFilter {
}
}
+// IdFilter allows you to filter by image Id
+func IdFilter(idFilter string) ResultFilter {
+ return func(i *Image) bool {
+ return i.ID() == idFilter
+ }
+}
+
// OutputImageFilter allows you to filter by an a specific image name
func OutputImageFilter(userImage *Image) ResultFilter {
return func(i *Image) bool {
@@ -165,6 +172,8 @@ func (ir *Runtime) createFilterFuncs(filters []string, img *Image) ([]ResultFilt
case "reference":
referenceFilter := strings.Join(splitFilter[1:], "=")
filterFuncs = append(filterFuncs, ReferenceFilter(ctx, referenceFilter))
+ case "id":
+ filterFuncs = append(filterFuncs, IdFilter(splitFilter[1]))
default:
return nil, errors.Errorf("invalid filter %s ", splitFilter[0])
}