blob: 6a1f160d524459c4b262683308ca1bac2b1822e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
}
|