summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/volumes/list.go4
-rw-r--r--docs/source/markdown/podman-volume-ls.1.md2
-rw-r--r--test/e2e/volume_ls_test.go22
3 files changed, 26 insertions, 2 deletions
diff --git a/cmd/podman/volumes/list.go b/cmd/podman/volumes/list.go
index 5548c9c1b..b0d999765 100644
--- a/cmd/podman/volumes/list.go
+++ b/cmd/podman/volumes/list.go
@@ -73,11 +73,11 @@ func list(cmd *cobra.Command, args []string) error {
lsOpts.Filter = make(map[string][]string)
}
for _, f := range cliOpts.Filter {
- filterSplit := strings.Split(f, "=")
+ filterSplit := strings.SplitN(f, "=", 2)
if len(filterSplit) < 2 {
return errors.Errorf("filter input must be in the form of filter=value: %s is invalid", f)
}
- lsOpts.Filter[filterSplit[0]] = append(lsOpts.Filter[filterSplit[0]], filterSplit[1:]...)
+ lsOpts.Filter[filterSplit[0]] = append(lsOpts.Filter[filterSplit[0]], filterSplit[1])
}
responses, err := registry.ContainerEngine().VolumeList(context.Background(), lsOpts)
if err != nil {
diff --git a/docs/source/markdown/podman-volume-ls.1.md b/docs/source/markdown/podman-volume-ls.1.md
index 98c3fae54..48853bdfd 100644
--- a/docs/source/markdown/podman-volume-ls.1.md
+++ b/docs/source/markdown/podman-volume-ls.1.md
@@ -40,6 +40,8 @@ $ podman volume ls --format json
$ podman volume ls --format "{{.Driver}} {{.Scope}}"
$ podman volume ls --filter name=foo,label=blue
+
+$ podman volume ls --filter label=key=value
```
## SEE ALSO
diff --git a/test/e2e/volume_ls_test.go b/test/e2e/volume_ls_test.go
index cda118bf1..5c466124d 100644
--- a/test/e2e/volume_ls_test.go
+++ b/test/e2e/volume_ls_test.go
@@ -83,6 +83,22 @@ var _ = Describe("Podman volume ls", func() {
Expect(session.ExitCode()).To(Equal(0))
Expect(len(session.OutputToStringArray())).To(Equal(2))
Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName))
+
+ session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo=foo"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(0))
+
+ session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo=bar"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(2))
+ Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName))
+
+ session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo=baz"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(0))
})
It("podman volume ls with --filter dangling", func() {
@@ -132,5 +148,11 @@ var _ = Describe("Podman volume ls", func() {
Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName))
Expect(session.OutputToStringArray()[2]).To(ContainSubstring(anotherVol))
+ session = podmanTest.Podman([]string{"volume", "ls", "--filter", "label=foo=bar", "--filter", "label=foo2=bar2"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ Expect(len(session.OutputToStringArray())).To(Equal(3))
+ Expect(session.OutputToStringArray()[1]).To(ContainSubstring(volName))
+ Expect(session.OutputToStringArray()[2]).To(ContainSubstring(anotherVol))
})
})