aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-06-26 05:11:50 -0400
committerGitHub <noreply@github.com>2020-06-26 05:11:50 -0400
commitbb11b428798094f33b3ec6102d2e52a3baf46324 (patch)
treebc08687ddf003e3c0b7612ba9e8cffb25f581f5f /pkg
parent4db296fab3ca5e201f76931f71ea3bcb58e43a87 (diff)
parentd78e83f47d487c1680ae0e2a1db42ef9d70caf30 (diff)
downloadpodman-bb11b428798094f33b3ec6102d2e52a3baf46324.tar.gz
podman-bb11b428798094f33b3ec6102d2e52a3baf46324.tar.bz2
podman-bb11b428798094f33b3ec6102d2e52a3baf46324.zip
Merge pull request #6756 from mheon/add_dangling_filter
Add support for dangling filter to volumes
Diffstat (limited to 'pkg')
-rw-r--r--pkg/domain/filters/volumes.go23
-rw-r--r--pkg/domain/infra/abi/system.go2
2 files changed, 24 insertions, 1 deletions
diff --git a/pkg/domain/filters/volumes.go b/pkg/domain/filters/volumes.go
index f97c3f570..b1b5e6319 100644
--- a/pkg/domain/filters/volumes.go
+++ b/pkg/domain/filters/volumes.go
@@ -61,6 +61,29 @@ func GenerateVolumeFilters(filters map[string][]string) ([]libpod.VolumeFilter,
}
return false
})
+ case "dangling":
+ danglingVal := val
+ invert := false
+ switch strings.ToLower(danglingVal) {
+ case "true", "1":
+ // Do nothing
+ case "false", "0":
+ // Dangling=false requires that we
+ // invert the result of IsDangling.
+ invert = true
+ default:
+ return nil, errors.Errorf("%q is not a valid value for the \"dangling\" filter - must be true or false", danglingVal)
+ }
+ vf = append(vf, func(v *libpod.Volume) bool {
+ dangling, err := v.IsDangling()
+ if err != nil {
+ return false
+ }
+ if invert {
+ return !dangling
+ }
+ return dangling
+ })
default:
return nil, errors.Errorf("%q is in an invalid volume filter", filter)
}
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index 90002326e..0511289ab 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -330,7 +330,7 @@ func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.System
if err != nil {
return nil, err
}
- inUse, err := v.VolumesInUse()
+ inUse, err := v.VolumeInUse()
if err != nil {
return nil, err
}