Skip to content

Commit

Permalink
Minor fix filtering images by label
Browse files Browse the repository at this point in the history
Added test to avoid future regressions

Fix containers#3163

Signed-off-by: Divyansh Kamboj <kambojdivyansh2000@gmail.com>
  • Loading branch information
weirdwiz committed May 20, 2019
1 parent 18a9539 commit c6f7066
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/podman/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func CreateFilterFuncs(ctx context.Context, r *adapter.LocalRuntime, filters []s
var filterFuncs []imagefilters.ResultFilter
for _, filter := range filters {
splitFilter := strings.Split(filter, "=")
if len(splitFilter) != 2 {
if len(splitFilter) < 2 {
return nil, errors.Errorf("invalid filter syntax %s", filter)
}
switch splitFilter[0] {
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,17 @@ ENV foo=bar
Expect(session2.ExitCode()).To(Equal(0))
Expect(len(session2.OutputToStringArray())).To(Equal(6))
})

It("podman images filter by label", func() {
SkipIfRemote()
dockerfile := `FROM docker.io/library/alpine:latest
LABEL version="1.0"
LABEL "com.example.vendor"="Example Vendor"
`
podmanTest.BuildImage(dockerfile, "test", "true")
session := podmanTest.Podman([]string{"images", "-f", "label=version=1.0"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
Expect(len(session.OutputToStringArray())).To(Equal(2))
})
})

0 comments on commit c6f7066

Please sign in to comment.