Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/source/markdown/options/filter.volume-ls.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#### **--filter**, **-f**=*filter*

Filter what volumes are shown in the output.
Multiple filters can be given with multiple uses of the --filter flag.

The *filters* argument format is of `key=value`. If there is more than one *filter*, then pass multiple OPTIONS: **--filter** *foo=bar* **--filter** *bif=baz*.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"If there is more than one filter, the --filter option should be passed multiple times: --filter name=test --filter driver=local`*"


Filters with the same key work inclusive, with the only exception being `label`
which is exclusive. Filters with different keys always work exclusive.

Expand Down
3 changes: 3 additions & 0 deletions docs/source/markdown/podman-volume-prune.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Provide filter values.

The *filters* argument format is of `key=value`. If there is more than one *filter*, then pass multiple OPTIONS: **--filter** *foo=bar* **--filter** *bif=baz*.

Filters with the same key work inclusive, with the only exception being `label`
which is exclusive. Filters with different keys always work exclusive.

Supported filters:

| Filter | Description |
Expand Down
6 changes: 3 additions & 3 deletions libpod/runtime_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (r *Runtime) HasVolume(name string) (bool, error) {
// Volumes retrieves all volumes
// Filters can be provided which will determine which volumes are included in the
// output. If multiple filters are used, a volume will be returned if
// any of the filters are matched
// all of the filters are matched
func (r *Runtime) Volumes(filters ...VolumeFilter) ([]*Volume, error) {
if !r.valid {
return nil, define.ErrRuntimeStopped
Expand All @@ -88,9 +88,9 @@ func (r *Runtime) Volumes(filters ...VolumeFilter) ([]*Volume, error) {

volsFiltered := make([]*Volume, 0, len(vols))
for _, vol := range vols {
include := false
include := true
for _, filter := range filters {
include = include || filter(vol)
include = include && filter(vol)
}

if include {
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/volume_ls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ var _ = Describe("Podman volume ls", func() {
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(HaveLen(1))
Expect(session.OutputToStringArray()[0]).To(Equal(vol3Name))

// Filters with different keys
session = podmanTest.Podman([]string{"volume", "ls", "-q", "--filter", "label=b=c", "--filter", "name=vol1"})
session.WaitWithDefaultTimeout()
Expect(session).Should(ExitCleanly())
Expect(session.OutputToStringArray()).To(HaveLen(1))
Expect(session.OutputToStringArray()[0]).To(Equal(vol1Name))
})

It("podman ls volume with --filter since/after", func() {
Expand Down