summaryrefslogtreecommitdiff
path: root/pkg/domain
diff options
context:
space:
mode:
authorJakub Guzik <jakubmguzik@gmail.com>2021-06-22 22:51:46 +0200
committerJakub Guzik <jakubmguzik@gmail.com>2021-06-22 22:51:53 +0200
commita0b24de32fa3459ab01d3f667384c51b0d7e43d0 (patch)
tree7910de33535e6f866bdd3ac8cef308305abbb5d9 /pkg/domain
parent1b27234d13d651e91b79f91397f7b4885f716872 (diff)
downloadpodman-a0b24de32fa3459ab01d3f667384c51b0d7e43d0.tar.gz
podman-a0b24de32fa3459ab01d3f667384c51b0d7e43d0.tar.bz2
podman-a0b24de32fa3459ab01d3f667384c51b0d7e43d0.zip
Add support for volume prune until filter to http api
As stated in #10579 docker silently implements until filter for volume prune. This commit adds initial support to the HTTP API, both libpod and compat. It enables further work on that issue, such as adding cli support in the future. Signed-off-by: Jakub Guzik <jakubmguzik@gmail.com>
Diffstat (limited to 'pkg/domain')
-rw-r--r--pkg/domain/filters/volumes.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/pkg/domain/filters/volumes.go b/pkg/domain/filters/volumes.go
index 9a08adf82..df23c31c0 100644
--- a/pkg/domain/filters/volumes.go
+++ b/pkg/domain/filters/volumes.go
@@ -86,11 +86,22 @@ func GeneratePruneVolumeFilters(filters url.Values) ([]libpod.VolumeFilter, erro
var vf []libpod.VolumeFilter
for filter, v := range filters {
for _, val := range v {
+ filterVal := val
switch filter {
case "label":
- filter := val
vf = append(vf, func(v *libpod.Volume) bool {
- return util.MatchLabelFilters([]string{filter}, v.Labels())
+ return util.MatchLabelFilters([]string{filterVal}, v.Labels())
+ })
+ case "until":
+ until, err := util.ComputeUntilTimestamp([]string{filterVal})
+ if err != nil {
+ return nil, err
+ }
+ vf = append(vf, func(v *libpod.Volume) bool {
+ if !until.IsZero() && v.CreatedTime().Before(until) {
+ return true
+ }
+ return false
})
default:
return nil, errors.Errorf("%q is an invalid volume filter", filter)