line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Docker::CLI::Wrapper::Container; |
2
|
|
|
|
|
|
|
$Docker::CLI::Wrapper::Container::VERSION = '0.0.5'; |
3
|
1
|
|
|
1
|
|
71114
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
5
|
1
|
|
|
1
|
|
28
|
use 5.014; |
|
1
|
|
|
|
|
3
|
|
6
|
1
|
|
|
1
|
|
524
|
use autodie; |
|
1
|
|
|
|
|
16175
|
|
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
7572
|
use Moo; |
|
1
|
|
|
|
|
11728
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
extends('Docker::CLI::Wrapper::Base'); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has 'container' => ( is => 'ro', required => 1, ); |
13
|
|
|
|
|
|
|
has 'sys' => ( is => 'ro', required => 1, ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub clean_up |
16
|
|
|
|
|
|
|
{ |
17
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
eval { $self->docker( { cmd => [ 'stop', $self->container(), ] } ); }; |
|
0
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
eval { $self->docker( { cmd => [ 'rm', $self->container(), ] } ); }; |
|
0
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub run_docker |
27
|
|
|
|
|
|
|
{ |
28
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
$self->docker( { cmd => [ 'pull', $self->sys() ] } ); |
31
|
0
|
|
|
|
|
|
$self->docker( |
32
|
|
|
|
|
|
|
{ |
33
|
|
|
|
|
|
|
cmd => [ |
34
|
|
|
|
|
|
|
'run', "-t", |
35
|
|
|
|
|
|
|
"-d", "--name", |
36
|
|
|
|
|
|
|
$self->container(), $self->sys(), |
37
|
|
|
|
|
|
|
] |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub exe |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
0
|
1
|
|
my ( $self, $args ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my @user; |
49
|
0
|
0
|
|
|
|
|
if ( exists $args->{user} ) |
50
|
|
|
|
|
|
|
{ |
51
|
0
|
|
|
|
|
|
push @user, ( '--user', $args->{user} ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return $self->docker( |
55
|
0
|
|
|
|
|
|
{ cmd => [ 'exec', @user, $self->container(), @{ $args->{cmd} } ] } ); |
|
0
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub exe_bash_code |
59
|
|
|
|
|
|
|
{ |
60
|
0
|
|
|
0
|
1
|
|
my ( $self, $args ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return $self->exe( |
63
|
|
|
|
|
|
|
{ |
64
|
0
|
|
|
|
|
|
%$args, cmd => [ 'bash', '-c', $args->{code}, ], |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |