Commit c74bf344 authored by David Johnson's avatar David Johnson

Handle Docker image history more carefully; Docker returns different things.

parent f5195cb4
...@@ -302,12 +302,23 @@ my %layer_size = (); ...@@ -302,12 +302,23 @@ my %layer_size = ();
if ($debug) { if ($debug) {
print "DEBUG: history: " . Dumper($content) . "\n"; print "DEBUG: history: " . Dumper($content) . "\n";
} }
foreach my $h (@{$content}) { # Sometimes history comes as a simple array of hashes; other times, it
next # is a array of one array of hashes. Go figure...
if (!exists($h->{"Id"}) || !exists($h->{"Size"})); my $histref;
my $size = $h->{"Size"}; if (defined($content) && ref($content) eq 'ARRAY') {
if ($h->{"Id"} =~ /^([\w\d]+):([\w\d]+)$/) { $histref = $content[0];
$layer_size{$2} = $size; if (ref($histref) eq 'ARRAY') {
$histref = $histref->[0];
}
}
if (defined($histref)) {
foreach my $h (@{$histref}) {
next
if (!exists($h->{"Id"}) || !exists($h->{"Size"}));
my $size = $h->{"Size"};
if ($h->{"Id"} =~ /^([\w\d]+):([\w\d]+)$/) {
$layer_size{$2} = $size;
}
} }
} }
if ($debug) { if ($debug) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment