summaryrefslogtreecommitdiff
path: root/libpod/runtime_volume.go
diff options
context:
space:
mode:
authorAshley Cui <acui@redhat.com>2020-11-03 14:07:59 -0500
committerAshley Cui <acui@redhat.com>2020-11-03 14:35:01 -0500
commit532bce4ad434e302007c3d2adf9994b5a822cc19 (patch)
tree911b8a455999778ecf647fce6de50fd59530999b /libpod/runtime_volume.go
parent8dfbdb561be5e2313dfa9f665e1f184089c8e967 (diff)
downloadpodman-532bce4ad434e302007c3d2adf9994b5a822cc19.tar.gz
podman-532bce4ad434e302007c3d2adf9994b5a822cc19.tar.bz2
podman-532bce4ad434e302007c3d2adf9994b5a822cc19.zip
Make volume filters inclusive
When using multiple filters, return a volume that matches any one of the used filters, rather than matching both of the filters. This is for compatibility with docker's cli, and more importantly, the apiv2 compat endpoint Closes #6765 Signed-off-by: Ashley Cui <acui@redhat.com>
Diffstat (limited to 'libpod/runtime_volume.go')
-rw-r--r--libpod/runtime_volume.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/libpod/runtime_volume.go b/libpod/runtime_volume.go
index e4e6d87e6..055a243c0 100644
--- a/libpod/runtime_volume.go
+++ b/libpod/runtime_volume.go
@@ -86,8 +86,8 @@ 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. Multiple filters are handled by ANDing their output, so only volumes
-// matching all filters are returned
+// output. If multiple filters are used, a volume will be returned if
+// any of the filters are matched
func (r *Runtime) Volumes(filters ...VolumeFilter) ([]*Volume, error) {
r.lock.RLock()
defer r.lock.RUnlock()
@@ -101,11 +101,15 @@ func (r *Runtime) Volumes(filters ...VolumeFilter) ([]*Volume, error) {
return nil, err
}
+ if len(filters) == 0 {
+ return vols, nil
+ }
+
volsFiltered := make([]*Volume, 0, len(vols))
for _, vol := range vols {
- include := true
+ include := false
for _, filter := range filters {
- include = include && filter(vol)
+ include = include || filter(vol)
}
if include {