Skip to content

Commit

Permalink
Merge pull request #5075 from mheon/filter_forces_all
Browse files Browse the repository at this point in the history
Force --all when --filter is passed to podman ps
  • Loading branch information
openshift-merge-robot authored Feb 4, 2020
2 parents fac8318 + ee5b749 commit 348e58b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/podman/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ func checkFlagsPassed(c *cliconfig.PsValues) error {
if c.Last >= 0 && c.Latest {
return errors.Errorf("last and latest are mutually exclusive")
}
// Filter forces all
if len(c.Filter) > 0 {
c.All = true
}
// Quiet conflicts with size and namespace and is overridden by a Go
// template.
if c.Quiet {
Expand Down
1 change: 1 addition & 0 deletions docs/source/markdown/podman-ps.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Display namespace information
Filter what containers are shown in the output.
Multiple filters can be given with multiple uses of the --filter flag.
If multiple filters are given, only containers which match all of the given filters will be shown.
Results will be drawn from all containers, regardless of whether --all was given.

Valid filters are listed below:

Expand Down
16 changes: 16 additions & 0 deletions test/e2e/ps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,22 @@ var _ = Describe("Podman ps", func() {
Expect(output[0]).To(Equal(fullCid))
})

It("podman ps filter by exited does not need all", func() {
ctr := podmanTest.Podman([]string{"run", "-t", "-i", ALPINE, "ls", "/"})
ctr.WaitWithDefaultTimeout()
Expect(ctr.ExitCode()).To(Equal(0))

psAll := podmanTest.Podman([]string{"ps", "-aq", "--no-trunc"})
psAll.WaitWithDefaultTimeout()
Expect(psAll.ExitCode()).To(Equal(0))

psFilter := podmanTest.Podman([]string{"ps", "--no-trunc", "--quiet", "--filter", "status=exited"})
psFilter.WaitWithDefaultTimeout()
Expect(psFilter.ExitCode()).To(Equal(0))

Expect(psAll.OutputToString()).To(Equal(psFilter.OutputToString()))
})

It("podman ps mutually exclusive flags", func() {
session := podmanTest.Podman([]string{"ps", "-aqs"})
session.WaitWithDefaultTimeout()
Expand Down

0 comments on commit 348e58b

Please sign in to comment.