Docker/API/Images.pm

filter: Statementstmt 100% 168 / 168 Branchbran 74.6% 121 / 162 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 26 / 26 Podpod 100% 15 / 15 totaltotal 88.6% 336 / 379 CC 84 SCAR 28.9
CC
84
Cov
87%
build
53.9
commit
10.0
list
7.8
CRAP 18.1
↑ Summary Docker/Role/HTTP.pm »
1 package API::Docker::API::Images;
2 # ABSTRACT: Docker Engine Images API
3 52 our $VERSION = '0.006';
4 52 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 52 with 'API::Docker::Role::Filters', 'API::Docker::Role::RegistryAuth',
6 'API::Docker::Role::Using';
7 52 ▶use API::Docker::Role::Entity::Image;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 52 ▶use API::Docker::Type::ImageInspect;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 52 ▶use API::Docker::Type::ImageSummary;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 52 ▶use Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 52 ▶use JSON::MaybeXS qw( encode_json );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 52 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 52 has client => (
16 is => 'ro',
17 required => 1,
18 weak_ref => 1,
19 );
20  
21  
22 # The class is the caller's argument rather than a constant of this module:
23 # `list` and `inspect` are two definitions in the swagger and therefore two
24 # generated classes. Both carry the same convenience methods, composed by
25 # API::Docker::Role::Entity::Image -- see "The two image shapes".
26 #
27 # from_data, not new: this is a daemon response, and the two entry points of
28 # API::Docker::Role::Type read it differently. from_data takes the swagger's
29 # wire names and nothing else, so a key it has not heard of keeps its own
30 # spelling instead of being read as the Perl name of one it has, and a value
31 # that disagrees with the swagger costs its own field rather than the whole
32 # response. `client` is ours rather than the engine's, so it goes beside the
33 # data instead of into it.
34 13 ▶sub _wrap {
Subroutine _wrap: called CC=1 SCAR=0.0
35 13 my ($self, $class, $data) = @_;
36 13 return $class->from_data($data, client => $self->client);
37 }
38  
39 14 ▶sub _wrap_list {
Subroutine _wrap_list: called CC=1 SCAR=0.0
40 14 my ($self, $class, $list) = @_;
41 14 return [ map { $self->_wrap($class, $_) } @$list ];
42 }
43  
44 25 ▶sub list {
Subroutine list: called CC=7 SCAR=20.5
Pod documented
45 25 my ($self, %opts) = @_;
46 25 my %params;
47 25 ▶ $params{all} = $opts{all} ? 1 : 0 if defined $opts{all};
Branch: 2 branches
BranchTrueFalseTotal
if defined $opts{"all"} 1 24 25
$opts{'all'} ? : 1 0 1
48 25 ▶ $params{digests} = $opts{digests} ? 1 : 0 if defined $opts{digests};
Branch: 2 branches
BranchTrueFalseTotal
if defined $opts{"digests"} 0 25 25
$opts{'digests'} ? : 0 0 0
49 $params{filters} = $self->_normalise_filters($opts{filters})
50 25 ▶ if defined $opts{filters};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"filters"} 19 6 25
51 my $result = $self->client->get('/images/json',
52 params => \%params,
53 14 %{ $self->_request_options },
54 );
55 14 ▶ return $self->_wrap_list('API::Docker::Type::ImageSummary', $result // []);
Condition50%1/2
$result // []
l!l
140
MC/DC0%0/1
$result // []
$result
Truth table50%1/2
A
A= $result
Aresult
11
00
56 }
57  
58  
59 14 ▶sub build {
Subroutine build: called CC=29 SCAR=39.9
Pod documented
60 14 my ($self, %opts) = @_;
61 14 my $context = delete $opts{context};
62 14 ▶ croak "Build context required (tar archive as scalar ref or raw bytes)" unless defined $context;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $context 1 13 14
63  
64 13 my %params;
65 13 ▶ $params{dockerfile} = $opts{dockerfile} if defined $opts{dockerfile};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"dockerfile"} 1 12 13
66 13 ▶ $params{t} = $opts{t} if defined $opts{t};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"t"} 8 5 13
67 13 ▶ $params{q} = $opts{q} ? 1 : 0 if defined $opts{q};
Branch: 2 branches
BranchTrueFalseTotal
if defined $opts{"q"} 0 13 13
$opts{'q'} ? : 0 0 0
68 13 ▶ $params{nocache} = $opts{nocache} ? 1 : 0 if defined $opts{nocache};
Branch: 2 branches
BranchTrueFalseTotal
if defined $opts{"nocache"} 0 13 13
$opts{'nocache'} ? : 0 0 0
69 13 ▶ $params{pull} = $opts{pull} if defined $opts{pull};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"pull"} 0 13 13
70 13 ▶ $params{rm} = defined $opts{rm} ? ($opts{rm} ? 1 : 0) : 1;
Branch: 2 branches
BranchTrueFalseTotal
defined $opts{'rm'} ? : 0 13 13
$opts{'rm'} ? : 0 0 0
71 13 ▶ $params{forcerm} = $opts{forcerm} ? 1 : 0 if defined $opts{forcerm};
Branch: 2 branches
BranchTrueFalseTotal
if defined $opts{"forcerm"} 0 13 13
$opts{'forcerm'} ? : 0 0 0
72 13 ▶ $params{memory} = $opts{memory} if defined $opts{memory};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"memory"} 0 13 13
73 13 ▶ $params{memswap} = $opts{memswap} if defined $opts{memswap};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"memswap"} 0 13 13
74 13 ▶ $params{cpushares} = $opts{cpushares} if defined $opts{cpushares};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"cpushares"} 0 13 13
75 13 ▶ $params{cpusetcpus} = $opts{cpusetcpus} if defined $opts{cpusetcpus};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"cpusetcpus"} 0 13 13
76 13 ▶ $params{cpuperiod} = $opts{cpuperiod} if defined $opts{cpuperiod};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"cpuperiod"} 0 13 13
77 13 ▶ $params{cpuquota} = $opts{cpuquota} if defined $opts{cpuquota};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"cpuquota"} 0 13 13
78 13 ▶ $params{shmsize} = $opts{shmsize} if defined $opts{shmsize};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"shmsize"} 0 13 13
79 13 ▶ $params{networkmode} = $opts{networkmode} if defined $opts{networkmode};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"networkmode"} 0 13 13
80 13 ▶ $params{platform} = $opts{platform} if defined $opts{platform};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"platform"} 0 13 13
81 13 ▶ $params{target} = $opts{target} if defined $opts{target};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"target"} 0 13 13
82  
83 13 ▶ $params{buildargs} = encode_json($opts{buildargs}) if $opts{buildargs};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"buildargs"} 0 13 13
84 13 ▶ $params{labels} = encode_json($opts{labels}) if $opts{labels};
Branch: 1 branch
BranchTrueFalseTotal
if $opts{"labels"} 0 13 13
85  
86 13 ▶ my $raw = ref $context eq 'SCALAR' ? $$context : $context;
Branch: 1 branch
BranchTrueFalseTotal
ref $context eq 'SCALAR' ? : 0 13 13
87  
88 # A build's registry credentials ride in X-Registry-Config, not
89 # X-Registry-Auth: the map lets `FROM private.registry/...` authenticate,
90 # and a build may draw base images from several registries at once. Sent
91 # only when given -- an anonymous build needs no header.
92 13 my %headers;
93 $headers{'X-Registry-Config'} =
94 $self->_registry_config_header($opts{registry_config})
95 13 ▶ if defined $opts{registry_config};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"registry_config"} 1 12 13
96  
97 # exists, not truth: an unset callback is a caller bug, and falling back to
98 # the buffered path for it would hand a long build back as silence.
99 return $self->client->_request('POST', '/build',
100 raw_body => $raw,
101 content_type => 'application/x-tar',
102 params => \%params,
103 %headers ? ( headers => \%headers ) : (),
104 13 ▶ %{ $self->_request_options },
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'on_event'} ? : 1 12 13
105 13 ▶ exists $opts{on_event} ? ( on_event => $opts{on_event} ) : ( ndjson => 1 ),
Branch: 1 branch
BranchTrueFalseTotal
%headers ? : 1 12 13
106 );
107 }
108  
109  
110 # The tag query parameter is not a default to hand out unconditionally: the
111 # engine appends it to whatever reference `fromImage` already carries. Docker
112 # lets tag take precedence and silently rewrites `nginx:1.25` to `nginx:latest`
113 # (a wrong image, reported as success); Podman concatenates to
114 # `nginx:1.25:latest` and answers 500 `invalid reference format`. A digest
115 # reference breaks the same way on both. So `tag` is defaulted only when the
116 # reference carries neither -- a `:tag` in the segment after the last `/`, or an
117 # `@digest` anywhere. The colon in a registry `host:port/` is before that
118 # segment, so it is not mistaken for a tag.
119 11 ▶sub _reference_has_tag_or_digest {
Subroutine _reference_has_tag_or_digest: called CC=3 SCAR=11.0
120 11 my ($self, $ref) = @_;
121 11 ▶ return 1 if $ref =~ /\@/;
Branch: 1 branch
BranchTrueFalseTotal
if $ref =~ /\@/ 1 10 11
122 10 my ($last_segment) = $ref =~ m{([^/]*)\z};
123 10 ▶ return $last_segment =~ /:/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$last_segment =~ /:/ ? : 2 8 10
124 }
125  
126 # Only when credentials were given: an anonymous pull needs no header, and the
127 # engine reads X-Registry-Auth off /images/create only to reach a private
128 # registry. This is the plugins/distribution policy, not push's always-send --
129 # push must send even the anonymous {} because the engine rejects a push with
130 # no header at all.
131 16 ▶sub _auth_headers {
Subroutine _auth_headers: called CC=2 SCAR=6.9
132 16 my ($self, $opts) = @_;
133 16 ▶ return () unless defined $opts->{auth};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $opts->{"auth"} 15 1 16
134 1 return (headers => { 'X-Registry-Auth' => $self->_registry_auth_header($opts->{auth}) });
135 }
136  
137 16 ▶sub pull {
Subroutine pull: called CC=5 SCAR=16.1
Pod documented
138 16 my ($self, %opts) = @_;
139 16 ▶ croak "fromImage required" unless $opts{fromImage};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"fromImage"} 0 16 16
140 16 my %params;
141 16 $params{fromImage} = $opts{fromImage};
142 16 ▶ if (defined $opts{tag}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $opts{'tag'}) { } 5 11 16
elsif (not $self->_reference_has_tag_or_digest($opts{'fromImage'})) { } 8 3 11
143 5 $params{tag} = $opts{tag};
144 }
145 elsif (!$self->_reference_has_tag_or_digest($opts{fromImage})) {
146 8 $params{tag} = 'latest';
147 }
148 return $self->client->post('/images/create', undef,
149 params => \%params,
150 $self->_auth_headers(\%opts),
151 16 ▶ %{ $self->_request_options },
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'on_event'} ? : 1 15 16
152 16 exists $opts{on_event} ? ( on_event => $opts{on_event} ) : ( ndjson => 1 ),
153 );
154 }
155  
156  
157 10 ▶sub inspect {
Subroutine inspect: called CC=2 SCAR=6.9
Pod documented
158 10 my ($self, $name) = @_;
159 10 ▶ croak "Image name required" unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 1 9 10
160 my $result = $self->client->get("/images/$name/json",
161 9 %{ $self->_request_options },
162 );
163 8 return $self->_wrap('API::Docker::Type::ImageInspect', $result);
164 }
165  
166  
167 5 ▶sub history {
Subroutine history: called CC=2 SCAR=7.0
Pod documented
168 5 my ($self, $name) = @_;
169 5 ▶ croak "Image name required" unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 5 5
170 return $self->client->get("/images/$name/history",
171 5 %{ $self->_request_options },
172 );
173 }
174  
175  
176 9 ▶sub push {
Subroutine push: called CC=4 SCAR=13.9
Pod documented
177 9 my ($self, $name, %opts) = @_;
178 9 ▶ croak "Image name required" unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 9 9
179 9 my %params;
180 9 ▶ $params{tag} = $opts{tag} if defined $opts{tag};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"tag"} 3 6 9
181  
182 9 my $auth_header = $self->_registry_auth_header($opts{auth});
183  
184 return $self->client->post(
185 "/images/$name/push",
186 undef,
187 params => \%params,
188 headers => { 'X-Registry-Auth' => $auth_header },
189 9 ▶ %{ $self->_request_options },
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'on_event'} ? : 1 8 9
190 9 exists $opts{on_event} ? ( on_event => $opts{on_event} ) : ( ndjson => 1 ),
191 );
192 }
193  
194  
195 6 ▶sub tag {
Subroutine tag: called CC=4 SCAR=14.0
Pod documented
196 6 my ($self, $name, %opts) = @_;
197 6 ▶ croak "Image name required" unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 6 6
198 6 my %params;
199 6 ▶ $params{repo} = $opts{repo} if defined $opts{repo};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"repo"} 6 0 6
200 6 ▶ $params{tag} = $opts{tag} if defined $opts{tag};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"tag"} 2 4 6
201 return $self->client->post("/images/$name/tag", undef,
202 params => \%params,
203 6 %{ $self->_request_options },
204 );
205 }
206  
207  
208 6 ▶sub remove {
Subroutine remove: called CC=6 SCAR=18.7
Pod documented
209 6 my ($self, $name, %opts) = @_;
210 6 ▶ croak "Image name required" unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 1 5 6
211 5 my %params;
212 5 ▶ $params{force} = $opts{force} ? 1 : 0 if defined $opts{force};
Branch: 2 branches
BranchTrueFalseTotal
if defined $opts{"force"} 1 4 5
$opts{'force'} ? : 1 0 1
213 5 ▶ $params{noprune} = $opts{noprune} ? 1 : 0 if defined $opts{noprune};
Branch: 2 branches
BranchTrueFalseTotal
if defined $opts{"noprune"} 0 5 5
$opts{'noprune'} ? : 0 0 0
214 return $self->client->delete_request("/images/$name",
215 params => \%params,
216 5 %{ $self->_request_options },
217 );
218 }
219  
220  
221 6 ▶sub search {
Subroutine search: called CC=4 SCAR=14.0
Pod documented
222 6 my ($self, $term, %opts) = @_;
223 6 ▶ croak "Search term required" unless $term;
Branch: 1 branch
BranchTrueFalseTotal
unless $term 0 6 6
224 6 my %params;
225 6 $params{term} = $term;
226 6 ▶ $params{limit} = $opts{limit} if defined $opts{limit};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"limit"} 0 6 6
227 $params{filters} = $self->_normalise_filters($opts{filters})
228 6 ▶ if defined $opts{filters};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"filters"} 2 4 6
229 return $self->client->get('/images/search',
230 params => \%params,
231 5 %{ $self->_request_options },
232 );
233 }
234  
235  
236 5 ▶sub prune {
Subroutine prune: called CC=2 SCAR=6.9
Pod documented
237 5 my ($self, %opts) = @_;
238 5 my %params;
239 $params{filters} = $self->_normalise_filters($opts{filters})
240 5 ▶ if defined $opts{filters};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"filters"} 1 4 5
241 return $self->client->post('/images/prune', undef,
242 params => \%params,
243 4 %{ $self->_request_options },
244 );
245 }
246  
247  
248 10 ▶sub get {
Subroutine get: called CC=3 SCAR=11.0
Pod documented
249 10 my ($self, $name, %opts) = @_;
250 10 ▶ croak "Image name required" unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 1 9 10
251 # `raw` and `on_chunk` are the same promise made twice -- hand the response
252 # bytes over undecoded -- so only one of them is sent: with a callback there
253 # is no return value for `raw` to describe.
254 return $self->client->get("/images/$name/get",
255 9 ▶ %{ $self->_request_options },
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'on_chunk'} ? : 1 8 9
256 9 exists $opts{on_chunk} ? ( on_chunk => $opts{on_chunk} ) : ( raw => 1 ));
257 }
258  
259  
260 10 ▶sub get_all {
Subroutine get_all: called CC=5 SCAR=16.1
Pod documented
261 10 my ($self, @names) = @_;
262  
263 # The list form has nowhere to put an option: get_all('a', 'b') is names all
264 # the way down, and a trailing `on_chunk => sub {...}` in it would be two
265 # more image names as far as this method can tell. So options ride behind
266 # the ArrayRef form, which already exists for exactly one list.
267 10 my %opts;
268 10 ▶ if (ref $names[0] eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $names[0] eq "ARRAY") 6 4 10
269 6 my $list = shift @names;
270 6 ▶ croak __PACKAGE__ . '->get_all takes options as pairs after the ArrayRef '
Branch: 1 branch
BranchTrueFalseTotal
if @names % 2 1 5 6
271 . 'of names; got an odd number of them' if @names % 2;
272 5 %opts = @names;
273 5 @names = @$list;
274 }
275  
276 9 ▶ croak "At least one image name required" unless @names;
Branch: 1 branch
BranchTrueFalseTotal
unless @names 1 8 9
277 # `names` is a repeated query parameter -- names=a&names=b -- and nothing
278 # else is accepted: measured against Podman 5.4.2, the comma-joined spelling
279 # answers 500 with 'parsing reference "alpine:3,registry:2": invalid
280 # reference format'. An ArrayRef param value is exactly that repetition;
281 # _request escapes each element with its own _uri_encode, which leaves `/`
282 # and `:` raw so an image reference survives intact.
283 return $self->client->get('/images/get', params => { names => \@names },
284 8 ▶ %{ $self->_request_options },
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'on_chunk'} ? : 1 7 8
285 8 exists $opts{on_chunk} ? ( on_chunk => $opts{on_chunk} ) : ( raw => 1 ));
286 }
287  
288  
289 11 ▶sub load {
Subroutine load: called CC=6 SCAR=17.9
Pod documented
290 11 my ($self, $tar, %opts) = @_;
291 11 ▶ croak "Tar archive required (raw bytes or a scalar ref)" unless defined $tar;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $tar 1 10 11
292  
293 10 my %params;
294 10 ▶ $params{quiet} = $opts{quiet} ? 1 : 0 if defined $opts{quiet};
Branch: 2 branches
BranchTrueFalseTotal
if defined $opts{"quiet"} 2 8 10
$opts{'quiet'} ? : 1 1 2
295  
296 10 ▶ my $raw = ref $tar eq 'SCALAR' ? $$tar : $tar;
Branch: 1 branch
BranchTrueFalseTotal
ref $tar eq 'SCALAR' ? : 1 9 10
297  
298 return $self->client->_request('POST', '/images/load',
299 raw_body => $raw,
300 content_type => 'application/x-tar',
301 params => \%params,
302 10 ▶ %{ $self->_request_options },
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'on_event'} ? : 1 9 10
303 10 exists $opts{on_event} ? ( on_event => $opts{on_event} ) : ( ndjson => 1 ),
304 );
305 }
306  
307  
308 12 ▶sub commit {
Subroutine commit: called CC=10 SCAR=23.0
Pod documented
309 12 my ($self, %opts) = @_;
310 12 ▶ croak "container required" unless $opts{container};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"container"} 1 11 12
311  
312 11 my %params;
313 11 $params{container} = $opts{container};
314 11 ▶ $params{repo} = $opts{repo} if defined $opts{repo};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"repo"} 3 8 11
315 11 ▶ $params{tag} = $opts{tag} if defined $opts{tag};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"tag"} 2 9 11
316 11 ▶ $params{comment} = $opts{comment} if defined $opts{comment};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"comment"} 1 10 11
317 11 ▶ $params{author} = $opts{author} if defined $opts{author};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"author"} 1 10 11
318 11 ▶ $params{pause} = $opts{pause} ? 1 : 0 if defined $opts{pause};
Branch: 2 branches
BranchTrueFalseTotal
if defined $opts{"pause"} 2 9 11
$opts{'pause'} ? : 1 1 2
319  
320 # `changes` is a repeated query parameter on the wire, but the engine parses
321 # each value as a Dockerfile snippet and a snippet may span lines, so one
322 # newline-joined value carries a list just as well. Measured against Podman
323 # 5.4.2: changes=LABEL%20a%3Db%0AEXPOSE%208080 and two separate changes=
324 # pairs produce the same image. The joined form is used because it fits the
325 # transport's one-value-per-key params encoder.
326 11 ▶ if (defined $opts{changes}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opts{"changes"}) 2 9 11
327 $params{changes} = ref $opts{changes} eq 'ARRAY'
328 1 ? join("\n", @{$opts{changes}})
329 2 ▶ : $opts{changes};
Branch: 1 branch
BranchTrueFalseTotal
ref $opts{'changes'} eq 'ARRAY' ? : 1 1 2
330 }
331  
332 return $self->client->post('/commit', $opts{config},
333 params => \%params,
334 11 %{ $self->_request_options },
335 );
336 }
337  
338  
339 13 ▶sub build_prune {
Subroutine build_prune: called CC=6 SCAR=17.9
Pod documented
340 13 my ($self, %opts) = @_;
341  
342 13 my %params;
343 # The engine spells this one with a hyphen, and an unquoted
344 # `keep-storage => $n` is not even valid Perl -- the fat comma quotes a
345 # bareword identifier, and keep-storage is a subtraction. So keep_storage is
346 # the documented spelling, the wire name is accepted beside it for anyone
347 # copying out of the Engine reference, and the hyphen is what goes on the
348 # wire. _uri_encode leaves `-` alone, so the key survives unmangled.
349 13 ▶ my $keep_storage = $opts{keep_storage} // $opts{'keep-storage'};
Condition100%3/3
$opts{"keep_storage"} // $opts{"keep-storage"}
l!l&&r!l&&!r
2110
MC/DC100%2/2
$opts{"keep_storage"} // $opts{"keep-storage"}
$opts{"keep_storage"} $opts{"keep-storage"}
Truth table100%3/3
A // B
A= $opts{"keep_storage"}B= $opts{"keep-storage"}
ABresult
1X1
011
000
350 13 ▶ $params{'keep-storage'} = $keep_storage if defined $keep_storage;
Branch: 1 branch
BranchTrueFalseTotal
if defined $keep_storage 3 10 13
351 13 ▶ $params{all} = $opts{all} ? 1 : 0 if defined $opts{all};
Branch: 2 branches
BranchTrueFalseTotal
if defined $opts{"all"} 4 9 13
$opts{'all'} ? : 3 1 4
352 $params{filters} = $self->_normalise_filters($opts{filters})
353 13 ▶ if defined $opts{filters};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"filters"} 3 10 13
354  
355 return $self->client->post('/build/prune', undef,
356 params => \%params,
357 12 %{ $self->_request_options },
358 );
359 }
360  
361  
362  
363 52 1;
364  
365 __END__
↑ Summary Docker/Role/HTTP.pm »