diff options
author | Matthew Heon <mheon@redhat.com> | 2020-02-03 22:39:50 -0500 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2020-02-04 09:52:25 -0500 |
commit | ee5b749e653f4c78298d1e290d5a1ae03edc3c05 (patch) | |
tree | 997b4c37b9fbe5d9cac564f62c241750c9950d40 | |
parent | c4f6d5615a34ea67b1335a2a446bd09789d98015 (diff) | |
download | podman-ee5b749e653f4c78298d1e290d5a1ae03edc3c05.tar.gz podman-ee5b749e653f4c78298d1e290d5a1ae03edc3c05.tar.bz2 podman-ee5b749e653f4c78298d1e290d5a1ae03edc3c05.zip |
Force --all when --filter is passed to podman ps
When we filter, it should be out of all containers, not just
running ones, by default - this is necessary to ensure Docker
compatability.
Fixes #5050
Signed-off-by: Matthew Heon <mheon@redhat.com>
-rw-r--r-- | cmd/podman/ps.go | 4 | ||||
-rw-r--r-- | docs/source/markdown/podman-ps.1.md | 1 | ||||
-rw-r--r-- | test/e2e/ps_test.go | 16 |
3 files changed, 21 insertions, 0 deletions
diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index d2c5e19e2..d93ccc24c 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -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 { diff --git a/docs/source/markdown/podman-ps.1.md b/docs/source/markdown/podman-ps.1.md index 024b85ea5..23bf9f45d 100644 --- a/docs/source/markdown/podman-ps.1.md +++ b/docs/source/markdown/podman-ps.1.md @@ -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: diff --git a/test/e2e/ps_test.go b/test/e2e/ps_test.go index 12bfdfe41..fccc5c93b 100644 --- a/test/e2e/ps_test.go +++ b/test/e2e/ps_test.go @@ -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() |