| 1 | package Dist::Zilla::PluginBundle::Author::GETTY::Docker; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Docker image subsection for @Author::GETTY | ||||||||||||||||||||||||||||
| 3 | 3 | our $VERSION = '0.328'; | |||||||||||||||||||||||||||
| 4 | 3 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | with 'Dist::Zilla::Role::PluginBundle::Easy'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 9 | ▶ | sub mvp_multivalue_args { qw(tags build_arg label platform) } | ||||||||||||||||||||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 13 | ▶ | sub configure { | ||||||||||||||||||||||||||
|
Subroutine
configure: called CC=13 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 13 | my $payload = $self->payload; | |||||||||||||||||||||||||||
| 13 | 3 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 13 | my $defaults = \%Dist::Zilla::PluginBundle::Author::GETTY::DOCKER_DEFAULTS; | |||||||||||||||||||||||||||
| 15 | 3 | ▶ | use warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 13 | ▶ | my $image = $payload->{image} // $defaults->{image}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$payload->{"image"} // $defaults->{"image"}
MC/DC100%2/2
$payload->{"image"} // $defaults->{"image"}
$payload->{"image"}
$defaults->{"image"}
Truth table100%3/3
A // B
A= $payload->{"image"}B= $defaults->{"image"}
| |||||||||||||||||||||||||||||
| 18 | 13 | ▶ | unless (defined $image && length $image) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $image and length $image
MC/DC50%1/2
defined $image and length $image
defined $image
length $image
Truth table66%2/3
A and B
A= defined $imageB= length $image
| |||||||||||||||||||||||||||||
| 19 | 2 | require Carp; | |||||||||||||||||||||||||||
| 20 | 2 | Carp::croak( | |||||||||||||||||||||||||||
| 21 | "[" . $self->name . "] needs either `image = ...` in this subsection " | ||||||||||||||||||||||||||||
| 22 | . "or `docker_image = ...` in [\@Author::GETTY]" | ||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | my $tags = $self->_normalize_tags($payload->{tags}) | ||||||||||||||||||||||||||||
| 27 | // $self->_normalize_tags($defaults->{tags}) | ||||||||||||||||||||||||||||
| 28 | 11 | ▶ | // ['latest', '%V', '%v']; | ||||||||||||||||||||||||||
|
Condition100%5/5
($self->_normalize_tags($payload->{"tags"}) // $self->_normalize_tags($defaults->{"tags"})) // ["latest", "%V", "%v"]
$self->_normalize_tags($payload->{"tags"}) // $self->_normalize_tags($defaults->{"tags"})
MC/DC100%2/2
($self->_normalize_tags($payload->{"tags"}) // $self->_normalize_tags($defaults->{"tags"})) // ["latest", "%V", "%v"]
$self->_normalize_tags($payload->{"tags"})
$self->_normalize_tags($defaults->{"tags"})
Truth table100%3/3
A // B
A= $self->_normalize_tags($payload->{"tags"})B= $self->_normalize_tags($defaults->{"tags"})
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | my $local = exists $payload->{local} ? $payload->{local} | ||||||||||||||||||||||||||||
| 31 | : exists $defaults->{local} ? $defaults->{local} | ||||||||||||||||||||||||||||
| 32 | 11 | ▶ | : 0; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 11 | ▶ | my %plugin_args = ( | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | image => $image, | ||||||||||||||||||||||||||||
| 36 | tag => $tags, | ||||||||||||||||||||||||||||
| 37 | release_push => $local ? 0 : 1, | ||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 11 | ▶ | $plugin_args{_target} = $payload->{target} if defined $payload->{target}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 11 | ▶ | $plugin_args{_network_mode} = $payload->{network_mode} if defined $payload->{network_mode}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 11 | for my $k (qw( | |||||||||||||||||||||||||||
| 44 | dockerfile build_arg label platform build_verbose | ||||||||||||||||||||||||||||
| 45 | pull no_cache rm force_rm fail_if_tag_exists skip_latest_on_trial | ||||||||||||||||||||||||||||
| 46 | )) { | ||||||||||||||||||||||||||||
| 47 | 121 | ▶ | $plugin_args{$k} = $payload->{$k} if exists $payload->{$k}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 11 | $self->add_plugins([ 'Docker::API' => \%plugin_args ]); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 19 | ▶ | sub _normalize_tags { | ||||||||||||||||||||||||||
|
Subroutine
_normalize_tags: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||
| 54 | 19 | my ($self, $tags) = @_; | |||||||||||||||||||||||||||
| 55 | 19 | ▶ | return undef unless defined $tags; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 5 | ▶ | my @list = ref $tags eq 'ARRAY' ? @$tags : ($tags); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 5 | ▶ | my @split = map { split /\s+/ } grep { defined && length } @list; | ||||||||||||||||||||||||||
|
Condition33%1/3
defined $_ && length $_
MC/DC0%0/2
defined $_ && length $_
defined $_
length $_
Truth table33%1/3
A && B
A= defined $_B= length $_
| |||||||||||||||||||||||||||||
| 58 | 5 | ▶ | return @split ? \@split : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 62 | 3 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | 3 | 1; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | __END__ | ||||||||||||||||||||||||||||