| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package API::Docker::API::Images; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Docker Engine Images API |
|
3
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
|
4
|
7
|
|
|
7
|
|
46
|
use Moo; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
44
|
|
|
5
|
7
|
|
|
7
|
|
6592
|
use API::Docker::Image; |
|
|
7
|
|
|
|
|
42
|
|
|
|
7
|
|
|
|
|
330
|
|
|
6
|
7
|
|
|
7
|
|
50
|
use Carp qw( croak ); |
|
|
7
|
|
|
|
|
12
|
|
|
|
7
|
|
|
|
|
491
|
|
|
7
|
7
|
|
|
7
|
|
80
|
use namespace::clean; |
|
|
7
|
|
|
|
|
12
|
|
|
|
7
|
|
|
|
|
34
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has client => ( |
|
11
|
|
|
|
|
|
|
is => 'ro', |
|
12
|
|
|
|
|
|
|
required => 1, |
|
13
|
|
|
|
|
|
|
weak_ref => 1, |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _wrap { |
|
18
|
3
|
|
|
3
|
|
7
|
my ($self, $data) = @_; |
|
19
|
3
|
|
|
|
|
47
|
return API::Docker::Image->new( |
|
20
|
|
|
|
|
|
|
client => $self->client, |
|
21
|
|
|
|
|
|
|
%$data, |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _wrap_list { |
|
26
|
1
|
|
|
1
|
|
2
|
my ($self, $list) = @_; |
|
27
|
1
|
|
|
|
|
3
|
return [ map { $self->_wrap($_) } @$list ]; |
|
|
2
|
|
|
|
|
1790
|
|
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub list { |
|
31
|
1
|
|
|
1
|
1
|
1067
|
my ($self, %opts) = @_; |
|
32
|
1
|
|
|
|
|
1
|
my %params; |
|
33
|
1
|
0
|
|
|
|
4
|
$params{all} = $opts{all} ? 1 : 0 if defined $opts{all}; |
|
|
|
50
|
|
|
|
|
|
|
34
|
1
|
0
|
|
|
|
4
|
$params{digests} = $opts{digests} ? 1 : 0 if defined $opts{digests}; |
|
|
|
50
|
|
|
|
|
|
|
35
|
1
|
50
|
|
|
|
2
|
$params{filters} = $opts{filters} if defined $opts{filters}; |
|
36
|
1
|
|
|
|
|
12
|
my $result = $self->client->get('/images/json', params => \%params); |
|
37
|
1
|
|
50
|
|
|
18
|
return $self->_wrap_list($result // []); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub build { |
|
42
|
2
|
|
|
2
|
1
|
72
|
my ($self, %opts) = @_; |
|
43
|
2
|
|
|
|
|
6
|
my $context = delete $opts{context}; |
|
44
|
2
|
100
|
|
|
|
201
|
croak "Build context required (tar archive as scalar ref or raw bytes)" unless defined $context; |
|
45
|
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
2
|
my %params; |
|
47
|
1
|
50
|
|
|
|
8
|
$params{dockerfile} = $opts{dockerfile} if defined $opts{dockerfile}; |
|
48
|
1
|
50
|
|
|
|
5
|
$params{t} = $opts{t} if defined $opts{t}; |
|
49
|
1
|
0
|
|
|
|
6
|
$params{q} = $opts{q} ? 1 : 0 if defined $opts{q}; |
|
|
|
50
|
|
|
|
|
|
|
50
|
1
|
0
|
|
|
|
4
|
$params{nocache} = $opts{nocache} ? 1 : 0 if defined $opts{nocache}; |
|
|
|
50
|
|
|
|
|
|
|
51
|
1
|
50
|
|
|
|
4
|
$params{pull} = $opts{pull} if defined $opts{pull}; |
|
52
|
1
|
0
|
|
|
|
5
|
$params{rm} = defined $opts{rm} ? ($opts{rm} ? 1 : 0) : 1; |
|
|
|
50
|
|
|
|
|
|
|
53
|
1
|
0
|
|
|
|
4
|
$params{forcerm} = $opts{forcerm} ? 1 : 0 if defined $opts{forcerm}; |
|
|
|
50
|
|
|
|
|
|
|
54
|
1
|
50
|
|
|
|
4
|
$params{memory} = $opts{memory} if defined $opts{memory}; |
|
55
|
1
|
50
|
|
|
|
3
|
$params{memswap} = $opts{memswap} if defined $opts{memswap}; |
|
56
|
1
|
50
|
|
|
|
4
|
$params{cpushares} = $opts{cpushares} if defined $opts{cpushares}; |
|
57
|
1
|
50
|
|
|
|
5
|
$params{cpusetcpus} = $opts{cpusetcpus} if defined $opts{cpusetcpus}; |
|
58
|
1
|
50
|
|
|
|
3
|
$params{cpuperiod} = $opts{cpuperiod} if defined $opts{cpuperiod}; |
|
59
|
1
|
50
|
|
|
|
5
|
$params{cpuquota} = $opts{cpuquota} if defined $opts{cpuquota}; |
|
60
|
1
|
50
|
|
|
|
20
|
$params{shmsize} = $opts{shmsize} if defined $opts{shmsize}; |
|
61
|
1
|
50
|
|
|
|
4
|
$params{networkmode} = $opts{networkmode} if defined $opts{networkmode}; |
|
62
|
1
|
50
|
|
|
|
4
|
$params{platform} = $opts{platform} if defined $opts{platform}; |
|
63
|
1
|
50
|
|
|
|
7
|
$params{target} = $opts{target} if defined $opts{target}; |
|
64
|
|
|
|
|
|
|
|
|
65
|
1
|
50
|
|
|
|
5
|
if ($opts{buildargs}) { |
|
66
|
0
|
|
|
|
|
0
|
require JSON::MaybeXS; |
|
67
|
0
|
|
|
|
|
0
|
$params{buildargs} = JSON::MaybeXS::encode_json($opts{buildargs}); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
1
|
50
|
|
|
|
4
|
if ($opts{labels}) { |
|
70
|
0
|
|
|
|
|
0
|
require JSON::MaybeXS; |
|
71
|
0
|
|
|
|
|
0
|
$params{labels} = JSON::MaybeXS::encode_json($opts{labels}); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
1
|
50
|
|
|
|
5
|
my $raw = ref $context eq 'SCALAR' ? $$context : $context; |
|
75
|
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
10
|
return $self->client->_request('POST', '/build', |
|
77
|
|
|
|
|
|
|
raw_body => $raw, |
|
78
|
|
|
|
|
|
|
content_type => 'application/x-tar', |
|
79
|
|
|
|
|
|
|
params => \%params, |
|
80
|
|
|
|
|
|
|
); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub pull { |
|
85
|
1
|
|
|
1
|
1
|
3028
|
my ($self, %opts) = @_; |
|
86
|
1
|
50
|
|
|
|
5
|
croak "fromImage required" unless $opts{fromImage}; |
|
87
|
1
|
|
|
|
|
3
|
my %params; |
|
88
|
1
|
|
|
|
|
59
|
$params{fromImage} = $opts{fromImage}; |
|
89
|
1
|
|
50
|
|
|
7
|
$params{tag} = $opts{tag} // 'latest'; |
|
90
|
1
|
|
|
|
|
19
|
return $self->client->post('/images/create', undef, params => \%params); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub inspect { |
|
95
|
2
|
|
|
2
|
1
|
53
|
my ($self, $name) = @_; |
|
96
|
2
|
100
|
|
|
|
193
|
croak "Image name required" unless $name; |
|
97
|
1
|
|
|
|
|
11
|
my $result = $self->client->get("/images/$name/json"); |
|
98
|
1
|
|
|
|
|
16
|
return $self->_wrap($result); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub history { |
|
103
|
1
|
|
|
1
|
1
|
28
|
my ($self, $name) = @_; |
|
104
|
1
|
50
|
|
|
|
4
|
croak "Image name required" unless $name; |
|
105
|
1
|
|
|
|
|
12
|
return $self->client->get("/images/$name/history"); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub push { |
|
110
|
0
|
|
|
0
|
1
|
0
|
my ($self, $name, %opts) = @_; |
|
111
|
0
|
0
|
|
|
|
0
|
croak "Image name required" unless $name; |
|
112
|
0
|
|
|
|
|
0
|
my %params; |
|
113
|
0
|
0
|
|
|
|
0
|
$params{tag} = $opts{tag} if defined $opts{tag}; |
|
114
|
0
|
|
|
|
|
0
|
return $self->client->post("/images/$name/push", undef, params => \%params); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub tag { |
|
119
|
1
|
|
|
1
|
1
|
602
|
my ($self, $name, %opts) = @_; |
|
120
|
1
|
50
|
|
|
|
5
|
croak "Image name required" unless $name; |
|
121
|
1
|
|
|
|
|
3
|
my %params; |
|
122
|
1
|
50
|
|
|
|
6
|
$params{repo} = $opts{repo} if defined $opts{repo}; |
|
123
|
1
|
50
|
|
|
|
3
|
$params{tag} = $opts{tag} if defined $opts{tag}; |
|
124
|
1
|
|
|
|
|
9
|
return $self->client->post("/images/$name/tag", undef, params => \%params); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub remove { |
|
129
|
2
|
|
|
2
|
1
|
1215
|
my ($self, $name, %opts) = @_; |
|
130
|
2
|
100
|
|
|
|
101
|
croak "Image name required" unless $name; |
|
131
|
1
|
|
|
|
|
2
|
my %params; |
|
132
|
1
|
0
|
|
|
|
4
|
$params{force} = $opts{force} ? 1 : 0 if defined $opts{force}; |
|
|
|
50
|
|
|
|
|
|
|
133
|
1
|
0
|
|
|
|
4
|
$params{noprune} = $opts{noprune} ? 1 : 0 if defined $opts{noprune}; |
|
|
|
50
|
|
|
|
|
|
|
134
|
1
|
|
|
|
|
34
|
return $self->client->delete_request("/images/$name", params => \%params); |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub search { |
|
139
|
1
|
|
|
1
|
1
|
44
|
my ($self, $term, %opts) = @_; |
|
140
|
1
|
50
|
|
|
|
17
|
croak "Search term required" unless $term; |
|
141
|
1
|
|
|
|
|
2
|
my %params; |
|
142
|
1
|
|
|
|
|
3
|
$params{term} = $term; |
|
143
|
1
|
50
|
|
|
|
4
|
$params{limit} = $opts{limit} if defined $opts{limit}; |
|
144
|
1
|
50
|
|
|
|
3
|
$params{filters} = $opts{filters} if defined $opts{filters}; |
|
145
|
1
|
|
|
|
|
13
|
return $self->client->get('/images/search', params => \%params); |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub prune { |
|
150
|
0
|
|
|
0
|
1
|
|
my ($self, %opts) = @_; |
|
151
|
0
|
|
|
|
|
|
my %params; |
|
152
|
0
|
0
|
|
|
|
|
$params{filters} = $opts{filters} if defined $opts{filters}; |
|
153
|
0
|
|
|
|
|
|
return $self->client->post('/images/prune', undef, params => \%params); |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
1; |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
__END__ |