diff options
Diffstat (limited to 'libpod/volume.go')
-rw-r--r-- | libpod/volume.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libpod/volume.go b/libpod/volume.go index ac5f61255..58d1f81a6 100644 --- a/libpod/volume.go +++ b/libpod/volume.go @@ -165,7 +165,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() @@ -174,3 +174,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 +} |