diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-04-07 18:55:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-07 18:55:23 -0400 |
commit | 9ba2e78cdcc28c15d72a76f6200a74e7ad6562b1 (patch) | |
tree | b75ec2d72a516d2469dec5de8634fa0e0c9ad442 /pkg/domain | |
parent | 8c0df1c44a496d30b6e122c4ebc1dae9b5059607 (diff) | |
parent | 84907324fa02b8ede502a47b522fc717e782a909 (diff) | |
download | podman-9ba2e78cdcc28c15d72a76f6200a74e7ad6562b1.tar.gz podman-9ba2e78cdcc28c15d72a76f6200a74e7ad6562b1.tar.bz2 podman-9ba2e78cdcc28c15d72a76f6200a74e7ad6562b1.zip |
Merge pull request #9958 from jmguzik/limit-prune-filters-for-volumes
Volumes prune endpoint should use only prune filters
Diffstat (limited to 'pkg/domain')
-rw-r--r-- | pkg/domain/filters/volumes.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/pkg/domain/filters/volumes.go b/pkg/domain/filters/volumes.go index 9b2fc5280..9a08adf82 100644 --- a/pkg/domain/filters/volumes.go +++ b/pkg/domain/filters/volumes.go @@ -75,7 +75,25 @@ func GenerateVolumeFilters(filters url.Values) ([]libpod.VolumeFilter, error) { return dangling }) default: - return nil, errors.Errorf("%q is in an invalid volume filter", filter) + return nil, errors.Errorf("%q is an invalid volume filter", filter) + } + } + } + return vf, nil +} + +func GeneratePruneVolumeFilters(filters url.Values) ([]libpod.VolumeFilter, error) { + var vf []libpod.VolumeFilter + for filter, v := range filters { + for _, val := range v { + switch filter { + case "label": + filter := val + vf = append(vf, func(v *libpod.Volume) bool { + return util.MatchLabelFilters([]string{filter}, v.Labels()) + }) + default: + return nil, errors.Errorf("%q is an invalid volume filter", filter) } } } |