line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Podman::Image; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
513363
|
use Mojo::Base 'Podman::Client'; |
|
5
|
|
|
|
|
16
|
|
|
5
|
|
|
|
|
28
|
|
4
|
|
|
|
|
|
|
|
5
|
5
|
|
|
5
|
|
6236
|
use Archive::Tar; |
|
5
|
|
|
|
|
172385
|
|
|
5
|
|
|
|
|
379
|
|
6
|
5
|
|
|
5
|
|
51
|
use Exporter qw(import); |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
141
|
|
7
|
5
|
|
|
5
|
|
28
|
use Mojo::File qw(path tempfile); |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
2904
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw(build pull); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has 'name' => sub { return '' }; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub build { |
14
|
1
|
|
|
1
|
0
|
4755
|
my ($name, $file, %options) = @_; |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
|
|
11
|
my $self = __PACKAGE__->new; |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
|
|
25
|
my $dir = path($file)->dirname; |
19
|
1
|
|
|
|
|
242
|
my @files = map { $_->basename } @{path($dir)->list({dir => 1})->to_array}; |
|
3
|
|
|
|
|
403
|
|
|
1
|
|
|
|
|
4
|
|
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
38
|
chdir $dir; |
22
|
1
|
|
|
|
|
60
|
my $archive = Archive::Tar->new(); |
23
|
1
|
|
|
|
|
85
|
$archive->add_files(@files); |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
2944
|
my $archive_file = tempfile; |
26
|
1
|
|
|
|
|
836
|
$archive->write($archive_file); |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
3079
|
$self->post( |
29
|
|
|
|
|
|
|
'build', |
30
|
|
|
|
|
|
|
data => $archive_file, |
31
|
|
|
|
|
|
|
parameters => {'file' => path($file)->basename, 't' => $name, %options,}, |
32
|
|
|
|
|
|
|
headers => {'Content-Type' => 'application/x-tar'}, |
33
|
|
|
|
|
|
|
); |
34
|
1
|
|
|
|
|
111
|
$self->get(sprintf "images/%s/exists", $name); |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
33
|
return $self->name($name); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub pull { |
40
|
1
|
|
|
1
|
1
|
29838
|
my ($name, $tag, %options) = @_; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
89
|
my $self = __PACKAGE__->new; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
50
|
|
|
57
|
my $reference = sprintf "%s:%s", $name, $tag // 'latest'; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
55
|
$self->post('images/pull', parameters => {reference => $reference, tlsVerify => 1, %options,}); |
47
|
1
|
|
|
|
|
67
|
$self->get(sprintf "images/%s/exists", $name); |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
33
|
return $self->name($name); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub inspect { |
53
|
1
|
|
|
1
|
1
|
4887
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
|
|
13
|
my $data = $self->get(sprintf "images/%s/json", $self->name)->json; |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
372
|
my $tag = (split /:/, $data->{RepoTags}->[0])[1]; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
8
|
my %inspect = (Tag => $tag, Id => $data->{Id}, Created => $data->{Created}, Size => $data->{Size},); |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
11
|
return \%inspect; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub remove { |
65
|
1
|
|
|
1
|
1
|
1894
|
my ($self, $force) = @_; |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
50
|
|
|
5
|
$self->delete('images', parameters => {images => $self->name, force => $force // 0,}); |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
35
|
return 1; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |