summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-02-21 12:17:38 -0500
committerGitHub <noreply@github.com>2020-02-21 12:17:38 -0500
commita554e97adcd565bd378a7041589b3b4979489ead (patch)
treeff76414655670e0b8a755656a88f14c1938585cc /libpod
parent585649df4635a7341dd4636fb8be939f5de5825f (diff)
parentb6e0692466ef118bc1804729107fc6e0ddb2027a (diff)
downloadpodman-a554e97adcd565bd378a7041589b3b4979489ead.tar.gz
podman-a554e97adcd565bd378a7041589b3b4979489ead.tar.bz2
podman-a554e97adcd565bd378a7041589b3b4979489ead.zip
Merge pull request #5236 from marusak/filter_by_id
apiv2: Image filtering and fixup docs
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 7c7394930..c54ca6333 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])
}