| 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
| |||||||||||||||||||||||||||||
| 46 | 14 | ▶ | $params{until} = $opts{until} if defined $opts{until}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | $params{filters} = $self->_normalise_filters($opts{filters}) | ||||||||||||||||||||||||||||
| 48 | 14 | ▶ | if defined $opts{filters}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
defined $opts{"auth"} and @flat
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
| |||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | my $config = defined $opts{auth} | ||||||||||||||||||||||||||||
| 89 | ? $self->_registry_auth_config($opts{auth}) | ||||||||||||||||||||||||||||
| 90 | 12 | ▶ | : { map { $_ => $opts{$_} } @flat }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 98 | . 'identitytoken, or auth => $config' unless keys %$config; | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | return $self->client->post('/auth', $config, | ||||||||||||||||||||||||||||
| 101 | 10 | ▶ | %{ $self->_request_options }, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 102 | 10 | (exists $opts{response} ? (response => $opts{response}) : ())); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 52 | 1; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | __END__ | ||||||||||||||||||||||||||||