Docker/API/System.pm

filter: Statementstmt 100% 41 / 41 Branchbran 100% 16 / 16 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 9 / 9 Podpod 100% 6 / 6 totaltotal 100% 77 / 77 CC 10 SCAR 13.3
CC
10
Cov
100%
auth
6.0
events
5.0
BEGIN
1.0
CRAP 3.8
« Docker/Role/JSONBody.pm ↑ Summary Docker/Role/RegistryAuth.pm »
1 package API::Docker::API::System;
2 # ABSTRACT: Docker Engine System 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 Carp qw( croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 52 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 52 has client => (
12 is => 'ro',
13 required => 1,
14 weak_ref => 1,
15 );
16  
17  
18 4 ▶sub info {
Subroutine info: called CC=1 SCAR=0.0
Pod documented
19 4 my ($self) = @_;
20 return $self->client->get('/info',
21 4 %{ $self->_request_options },
22 );
23 }
24  
25  
26 6 ▶sub version {
Subroutine version: called CC=1 SCAR=0.0
Pod documented
27 6 my ($self) = @_;
28 return $self->client->get('/version',
29 6 %{ $self->_request_options },
30 );
31 }
32  
33  
34 4 ▶sub ping {
Subroutine ping: called CC=1 SCAR=0.0
Pod documented
35 4 my ($self) = @_;
36 return $self->client->get('/_ping',
37 4 %{ $self->_request_options },
38 );
39 }
40  
41  
42 14 ▶sub events {
Subroutine events: called CC=5 SCAR=16.1
Pod documented
43 14 my ($self, %opts) = @_;
44 14 my %params;
45 14 ▶ $params{since} = $opts{since} if defined $opts{since};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"since"} 9 5 14
46 14 ▶ $params{until} = $opts{until} if defined $opts{until};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"until"} 7 7 14
47 $params{filters} = $self->_normalise_filters($opts{filters})
48 14 ▶ if defined $opts{filters};
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"filters"} 1 13 14
49 # croak_on_error => 0: /events is a feed, not the progress of one
50 # operation. An object in it describes something that happened on the
51 # engine, so it is data even if it ever carries an errorDetail key -- this
52 # call must never croak on ordinary event traffic. It holds for the
53 # callback path too, where the check would otherwise run per event.
54 #
55 # exists, not truth: `on_event => $cb` with an unset $cb is a caller bug,
56 # and falling back to the buffered path for it would answer an unbounded
57 # feed by hanging. Handed over as it is, the transport says so instead.
58 return $self->client->get('/events',
59 params => \%params,
60 croak_on_error => 0,
61 13 ▶ %{ $self->_request_options },
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'on_event'} ? : 2 11 13
62 13 exists $opts{on_event} ? ( on_event => $opts{on_event} ) : ( ndjson => 1 ),
63 );
64 }
65  
66  
67 4 ▶sub df {
Subroutine df: called CC=1 SCAR=0.0
Pod documented
68 4 my ($self) = @_;
69 return $self->client->get('/system/df',
70 4 %{ $self->_request_options },
71 );
72 }
73  
74  
75 13 ▶sub auth {
Subroutine auth: called CC=6 SCAR=17.9
Pod documented
76 13 my ($self, %opts) = @_;
77  
78 # Two spellings of the same AuthConfig. The credential keys and the name
79 # `auth` cannot collide -- the engine's AuthConfig has no `auth` field --
80 # so both are accepted, but not at once: which one wins would be a silent
81 # choice about someone's credentials.
82 13 my @flat = grep { defined $opts{$_} }
83 qw( username password email serveraddress identitytoken );
84 croak __PACKAGE__ . '->auth takes either auth => $config or the credential '
85 . 'keys themselves, not both (' . join(', ', @flat) . ' given beside auth)'
86 13 ▶ if defined $opts{auth} && @flat;
Branch: 1 branch
BranchTrueFalseTotal
if defined $opts{"auth"} and @flat 1 12 13
Condition100%3/3
defined $opts{"auth"} and @flat
!ll&&!rl&&r
841
MC/DC100%2/2
defined $opts{"auth"} and @flat
defined $opts{"auth"} @flat
Truth table100%3/3
A and B
A= defined $opts{"auth"}B= @flat
ABresult
0X0
100
111
87  
88 my $config = defined $opts{auth}
89 ? $self->_registry_auth_config($opts{auth})
90 12 ▶ : { map { $_ => $opts{$_} } @flat };
Branch: 1 branch
BranchTrueFalseTotal
defined $opts{'auth'} ? : 4 8 12
91  
92 # Stricter than the engine, deliberately. An empty AuthConfig is a valid
93 # body -- Podman answers it 500 'getting username and password: cannot
94 # prompt for username without stdin' -- but a credential check with no
95 # credentials in it is a caller bug, and answering it with the engine's
96 # message would hide that.
97 12 ▶ croak __PACKAGE__ . '->auth requires credentials: pass username/password, '
Branch: 1 branch
BranchTrueFalseTotal
unless keys %$config 2 10 12
98 . 'identitytoken, or auth => $config' unless keys %$config;
99  
100 return $self->client->post('/auth', $config,
101 10 ▶ %{ $self->_request_options },
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'response'} ? : 2 8 10
102 10 (exists $opts{response} ? (response => $opts{response}) : ()));
103 }
104  
105  
106  
107 52 1;
108  
109 __END__
« Docker/Role/JSONBody.pm ↑ Summary Docker/Role/RegistryAuth.pm »