summaryrefslogtreecommitdiff
path: root/libpod/image/prune.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-12-06 08:31:20 -0800
committerGitHub <noreply@github.com>2018-12-06 08:31:20 -0800
commit3e60de629d5feaff1ac15173b4ff1e5325dfa5dc (patch)
tree06f3cee26ea99d6027130b6a908b8734c8f68afe /libpod/image/prune.go
parent99bbbeb746820716610317fedd8d3918951a9d7d (diff)
parente037427035dc57e536478362fc19e30a400bc327 (diff)
downloadpodman-3e60de629d5feaff1ac15173b4ff1e5325dfa5dc.tar.gz
podman-3e60de629d5feaff1ac15173b4ff1e5325dfa5dc.tar.bz2
podman-3e60de629d5feaff1ac15173b4ff1e5325dfa5dc.zip
Merge pull request #1912 from baude/prune
Add ability to prune containers and images
Diffstat (limited to 'libpod/image/prune.go')
-rw-r--r--libpod/image/prune.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/libpod/image/prune.go b/libpod/image/prune.go
new file mode 100644
index 000000000..6a1f160d5
--- /dev/null
+++ b/libpod/image/prune.go
@@ -0,0 +1,26 @@
+package image
+
+// GetPruneImages returns a slice of images that have no names/unused
+func (ir *Runtime) GetPruneImages() ([]*Image, error) {
+ var (
+ unamedImages []*Image
+ )
+ allImages, err := ir.GetImages()
+ if err != nil {
+ return nil, err
+ }
+ for _, i := range allImages {
+ if len(i.Names()) == 0 {
+ unamedImages = append(unamedImages, i)
+ continue
+ }
+ containers, err := i.Containers()
+ if err != nil {
+ return nil, err
+ }
+ if len(containers) < 1 {
+ unamedImages = append(unamedImages, i)
+ }
+ }
+ return unamedImages, nil
+}