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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// +build ABISupport
package abi
import (
"context"
libpodImage "github.com/containers/libpod/libpod/image"
"github.com/containers/libpod/pkg/domain/entities"
)
func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) ([]*entities.ImageSummary, error) {
var (
images []*libpodImage.Image
err error
)
// TODO: Future work support for domain.Filters
// filters := utils.ToLibpodFilters(opts.Filters)
if len(opts.Filter) > 0 {
images, err = ir.Libpod.ImageRuntime().GetImagesWithFilters(opts.Filter)
} else {
images, err = ir.Libpod.ImageRuntime().GetImages()
}
if err != nil {
return nil, err
}
summaries := make([]*entities.ImageSummary, len(images))
for i, img := range images {
var repoTags []string
if opts.All {
pairs, err := libpodImage.ReposToMap(img.Names())
if err != nil {
return nil, err
}
for repo, tags := range pairs {
for _, tag := range tags {
repoTags = append(repoTags, repo+":"+tag)
}
}
} else {
repoTags, _ = img.RepoTags()
}
digests := make([]string, len(img.Digests()))
for j, d := range img.Digests() {
digests[j] = string(d)
}
e := entities.ImageSummary{
ID: img.ID(),
ConfigDigest: string(img.ConfigDigest),
Created: img.Created().Unix(),
Dangling: img.Dangling(),
Digest: string(img.Digest()),
Digests: digests,
History: img.NamesHistory(),
Names: img.Names(),
ParentId: img.Parent,
ReadOnly: img.IsReadOnly(),
SharedSize: 0,
VirtualSize: img.VirtualSize,
RepoTags: repoTags,
}
e.Labels, _ = img.Labels(context.TODO())
ctnrs, _ := img.Containers()
e.Containers = len(ctnrs)
sz, _ := img.Size(context.TODO())
e.Size = int64(*sz)
summaries[i] = &e
}
return summaries, nil
}
|