summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/source/markdown/podman-images.1.md8
-rw-r--r--libpod/image/filters.go2
-rw-r--r--test/system/010-images.bats36
3 files changed, 41 insertions, 5 deletions
diff --git a/docs/source/markdown/podman-images.1.md b/docs/source/markdown/podman-images.1.md
index d22fb940f..09778e3c2 100644
--- a/docs/source/markdown/podman-images.1.md
+++ b/docs/source/markdown/podman-images.1.md
@@ -29,11 +29,11 @@ Filter output based on conditions provided
Filters:
- **after==TIMESTRING**
- Filter on images created after the given time.Time.
+ **since=IMAGE**
+ Filter on images created after the given IMAGE (name or tag).
- **before==TIMESTRING**
- Filter on images created before the given time.Time.
+ **before=IMAGE**
+ Filter on images created before the given IMAGE (name or tag).
**dangling=true|false**
Show dangling images. Dangling images are a file system layer that was used in a previous build of an image and is no longer referenced by any active images. They are denoted with the <none> tag, consume disk space and serve no active purpose.
diff --git a/libpod/image/filters.go b/libpod/image/filters.go
index d545f1bfc..7c7394930 100644
--- a/libpod/image/filters.go
+++ b/libpod/image/filters.go
@@ -141,7 +141,7 @@ func (ir *Runtime) createFilterFuncs(filters []string, img *Image) ([]ResultFilt
return nil, errors.Wrapf(err, "unable to find image %s in local stores", splitFilter[1])
}
filterFuncs = append(filterFuncs, CreatedBeforeFilter(before.Created()))
- case "after":
+ case "since", "after":
after, err := ir.NewFromLocal(splitFilter[1])
if err != nil {
return nil, errors.Wrapf(err, "unable to find image %s in local stores", splitFilter[1])
diff --git a/test/system/010-images.bats b/test/system/010-images.bats
index 66ef53590..3224c9b42 100644
--- a/test/system/010-images.bats
+++ b/test/system/010-images.bats
@@ -74,4 +74,40 @@ size | [0-9]\\\+
run_podman rm my-container
}
+@test "podman images - filter" {
+ skip_if_remote "podman commit -q is broken in podman-remote"
+
+ run_podman inspect --format '{{.ID}}' $IMAGE
+ iid=$output
+
+ run_podman images --noheading --filter=after=$iid
+ is "$output" "" "baseline: empty results from filter (after)"
+
+ run_podman images --noheading --filter=before=$iid
+ is "$output" "" "baseline: empty results from filter (before)"
+
+ # Create a dummy container, then commit that as an image. We will
+ # now be able to use before/after/since queries
+ run_podman run --name mytinycontainer $IMAGE true
+ run_podman commit -q mytinycontainer mynewimage
+ new_iid=$output
+
+ # (refactor common options for legibility)
+ opts='--noheading --no-trunc --format={{.ID}}--{{.Repository}}:{{.Tag}}'
+
+ run_podman images ${opts} --filter=after=$iid
+ is "$output" "sha256:$new_iid--localhost/mynewimage:latest" "filter: after"
+
+ # Same thing, with 'since' instead of 'after'
+ run_podman images ${opts} --filter=since=$iid
+ is "$output" "sha256:$new_iid--localhost/mynewimage:latest" "filter: since"
+
+ run_podman images ${opts} --filter=before=mynewimage
+ is "$output" "sha256:$iid--$IMAGE" "filter: before"
+
+ # Clean up
+ run_podman rmi mynewimage
+ run_podman rm mytinycontainer
+}
+
# vim: filetype=sh