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
81
82
83
|
package tunnel
import (
"context"
"net/url"
images "github.com/containers/libpod/pkg/bindings/images"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/containers/libpod/pkg/domain/utils"
)
func (ir *ImageEngine) Exists(_ context.Context, nameOrId string) (*entities.BoolReport, error) {
found, err := images.Exists(ir.ClientCxt, nameOrId)
return &entities.BoolReport{Value: found}, err
}
func (ir *ImageEngine) Delete(ctx context.Context, nameOrId []string, opts entities.ImageDeleteOptions) (*entities.ImageDeleteReport, error) {
report := entities.ImageDeleteReport{}
for _, id := range nameOrId {
results, err := images.Remove(ir.ClientCxt, id, &opts.Force)
if err != nil {
return nil, err
}
for _, e := range results {
if a, ok := e["Deleted"]; ok {
report.Deleted = append(report.Deleted, a)
}
if a, ok := e["Untagged"]; ok {
report.Untagged = append(report.Untagged, a)
}
}
}
return &report, nil
}
func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) ([]*entities.ImageSummary, error) {
images, err := images.List(ir.ClientCxt, &opts.All, opts.Filters)
if err != nil {
return nil, err
}
is := make([]*entities.ImageSummary, len(images))
for i, img := range images {
hold := entities.ImageSummary{}
if err := utils.DeepCopy(&hold, img); err != nil {
return nil, err
}
is[i] = &hold
}
return is, nil
}
func (ir *ImageEngine) History(ctx context.Context, nameOrId string, opts entities.ImageHistoryOptions) (*entities.ImageHistoryReport, error) {
results, err := images.History(ir.ClientCxt, nameOrId)
if err != nil {
return nil, err
}
history := entities.ImageHistoryReport{
Layers: make([]entities.ImageHistoryLayer, len(results)),
}
for i, layer := range results {
hold := entities.ImageHistoryLayer{}
_ = utils.DeepCopy(&hold, layer)
history.Layers[i] = hold
}
return &history, nil
}
func (ir *ImageEngine) Prune(ctx context.Context, opts entities.ImagePruneOptions) (*entities.ImagePruneReport, error) {
results, err := images.Prune(ir.ClientCxt, url.Values{})
if err != nil {
return nil, err
}
report := entities.ImagePruneReport{}
copy(report.Report.Id, results)
return &report, nil
}
|