aboutsummaryrefslogtreecommitdiff
path: root/pkg/domain
diff options
context:
space:
mode:
authorJakub Guzik <jakubmguzik@gmail.com>2021-04-07 00:02:12 +0200
committerJakub Guzik <jakubmguzik@gmail.com>2021-04-07 22:37:49 +0200
commit84907324fa02b8ede502a47b522fc717e782a909 (patch)
treede64d203f572634501f0417ff79d0a6c9b38d652 /pkg/domain
parentd83f49ef6b8a53535257bb56f5573ef3f65e3ba9 (diff)
downloadpodman-84907324fa02b8ede502a47b522fc717e782a909.tar.gz
podman-84907324fa02b8ede502a47b522fc717e782a909.tar.bz2
podman-84907324fa02b8ede502a47b522fc717e782a909.zip
Volumes prune endpoint should use only prune filters
Volumes endpoints for HTTP compat and libpod APIs allowed usage of list HTTP endpoint filter funcs. Documentation in case of compat API does not allow that. This commit aligns code with the documentation and also ligns libpod with compat API. Signed-off-by: Jakub Guzik <jakubmguzik@gmail.com>
Diffstat (limited to 'pkg/domain')
-rw-r--r--pkg/domain/filters/volumes.go20
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)
}
}
}