| 1 | # | ||||||||||||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||||||||||||
| 3 | # | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package Rex::Virtualization::Docker::import; | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 1 | ▶ | use v5.14.4; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | our $VERSION = '1.16.1'; # VERSION | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 1 | ▶ | use Rex::Logger; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 1 | ▶ | use Rex::Helper::Run; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | 1 | ▶ | use Rex::Virtualization::Docker::images; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | ▶ | sub execute { | ||||||||||||||||||
|
Subroutine
execute: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||
| 18 | 0 | my ( $class, $arg1, %opt ) = @_; | |||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 0 | ▶ | unless ($arg1) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | 0 | die("You have to define the vm name!"); | |||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 0 | my $dom = $arg1; | |||||||||||||||||||
| 25 | 0 | Rex::Logger::debug( "importing: $dom -> " . $opt{file} ); | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | my $add_cmd = ""; | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 0 | ▶ | if ( -f $opt{file} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 0 | i_run "docker import '$opt{file}' '$dom'", fail_ok => 1; | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | else { | ||||||||||||||||||||
| 33 | 0 | my ( $i_name, $i_tag ) = split( /:/, $opt{file} ); | |||||||||||||||||||
| 34 | 0 | ▶ | $i_tag = "latest" unless $i_tag; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | my @images = grep { $_->{name} eq $i_name && $_->{tag} eq $i_tag } | ||||||||||||||||||
|
Condition0%0/3
$_->{'name'} eq $i_name && $_->{'tag'} eq $i_tag
MC/DC0%0/2
$_->{'name'} eq $i_name && $_->{'tag'} eq $i_tag
$_->{'name'} eq $i_name
$_->{'tag'} eq $i_tag
Truth table0%0/3
A && B
A= $_->{'name'} eq $i_nameB= $_->{'tag'} eq $i_tag
| |||||||||||||||||||||
| 37 | 0 | @{ Rex::Virtualization::Docker::images->execute() }; | |||||||||||||||||||
| 38 | 0 | ▶ | unless (@images) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 0 | i_run "docker pull $opt{file}", fail_ok => 1; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | ▶ | if ( $? != 0 ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 44 | 0 | print("Error importing VM $opt{file}\n"); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 1 | 1; | |||||||||||||||||||