File Coverage

lib/Rex/Virtualization/Docker/info.pm
Criterion Covered Total %
statement 14 27 51.8
branch 0 4 0.0
condition n/a
subroutine 5 6 83.3
pod 0 1 0.0
total 19 38 50.0


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Virtualization::Docker::info;
6              
7 1     1   17 use v5.12.5;
  1         5  
8 1     1   6 use warnings;
  1         2  
  1         40  
9              
10             our $VERSION = '1.14.2.2'; # TRIAL VERSION
11              
12 1     1   6 use Rex::Logger;
  1         2  
  1         6  
13 1     1   20 use Rex::Helper::Run;
  1         2  
  1         70  
14 1     1   8 use JSON::MaybeXS;
  1         2  
  1         230  
15              
16             sub execute {
17 0     0 0   my ( $class, $arg1 ) = @_;
18 0           my @dominfo;
19              
20 0 0         if ( !$arg1 ) {
21 0           die('Must define container ID');
22             }
23              
24 0           Rex::Logger::debug("Getting docker info by inspect");
25              
26 0           my $ret = i_run "docker inspect $arg1", fail_ok => 1;
27 0 0         if ( $? != 0 ) {
28 0           return { running => 'off' };
29             }
30              
31 0           my $coder = JSON::MaybeXS->new->allow_nonref;
32 0           my $ref = $coder->decode($ret);
33 0           $ref = $ref->[0];
34 0           $ref->{running} = "on";
35 0           return $ref;
36             }
37              
38             1;