summaryrefslogtreecommitdiff
path: root/libpod
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 /libpod
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 'libpod')
-rw-r--r--libpod/volume.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/libpod/volume.go b/libpod/volume.go
index 82f389833..b29ac7ddf 100644
--- a/libpod/volume.go
+++ b/libpod/volume.go
@@ -137,7 +137,7 @@ func (v *Volume) Config() (*VolumeConfig, error) {
// VolumeInUse goes through the container dependencies of a volume
// and checks if the volume is being used by any container.
-func (v *Volume) VolumesInUse() ([]string, error) {
+func (v *Volume) VolumeInUse() ([]string, error) {
v.lock.Lock()
defer v.lock.Unlock()
@@ -146,3 +146,13 @@ func (v *Volume) VolumesInUse() ([]string, error) {
}
return v.runtime.state.VolumeInUse(v)
}
+
+// IsDangling returns whether this volume is dangling (unused by any
+// containers).
+func (v *Volume) IsDangling() (bool, error) {
+ ctrs, err := v.VolumeInUse()
+ if err != nil {
+ return false, err
+ }
+ return len(ctrs) == 0, nil
+}