lib/Rex/Virtualization/Docker/import.pm

filter: Statementstmt 52.7% 19 / 36 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 42.3% 25 / 59 CC 7 SCAR 34.2
CC
7
Cov
39%
execute
56.0
BEGIN
1.0
BEGIN
1.0
CRAP 30.6
« lib/Rex/Virtualization/Lxc/copy.pm ↑ Summary lib/Rex/Commands/Download.pm »
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
BranchTrueFalseTotal
unless ($arg1) 0 0 0
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
BranchTrueFalseTotal
if (-f $opt{'file'}) { } 0 0 0
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
BranchTrueFalseTotal
unless $i_tag 0 0 0
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
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
37 0 @{ Rex::Virtualization::Docker::images->execute() };
38 0 ▶ unless (@images) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@images) 0 0 0
39 0 i_run "docker pull $opt{file}", fail_ok => 1;
40 }
41 }
42  
43 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
44 0 print("Error importing VM $opt{file}\n");
45 }
46 }
47  
48 1 1;
« lib/Rex/Virtualization/Lxc/copy.pm ↑ Summary lib/Rex/Commands/Download.pm »