summaryrefslogtreecommitdiffstats
path: root/src/virtBootstrap/sources/docker_source.py
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2017-08-26 21:41:56 +0100
committerRadostin Stoyanov <rstoyanov1@gmail.com>2017-08-28 15:59:04 +0100
commitb703110e56921697e2f28004da9cf9c4c3fe7787 (patch)
treee681bbb13533f19594381ea6fae08c605e9ff0d6 /src/virtBootstrap/sources/docker_source.py
parent376dd96934de59d72db5fde376533bcba2bdc670 (diff)
downloadvirt-bootstrap.git-b703110e56921697e2f28004da9cf9c4c3fe7787.tar.gz
virt-bootstrap.git-b703110e56921697e2f28004da9cf9c4c3fe7787.tar.xz
virt-bootstrap.git-b703110e56921697e2f28004da9cf9c4c3fe7787.zip
Get layer size if not provided
Docker registry with Manifest v1 does not require the size of layers to be included. However, when this information is not provided we can use os.path.getsize() to get and show the size of tarball. We can also use this function for FileSource to provide consistent output messages.
Diffstat (limited to 'src/virtBootstrap/sources/docker_source.py')
-rw-r--r--src/virtBootstrap/sources/docker_source.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/virtBootstrap/sources/docker_source.py b/src/virtBootstrap/sources/docker_source.py
index 246356a..2dadb42 100644
--- a/src/virtBootstrap/sources/docker_source.py
+++ b/src/virtBootstrap/sources/docker_source.py
@@ -92,15 +92,14 @@ class DockerSource(object):
raise ValueError('Unsupported manifest schema.')
for layer in layers_list:
- layer_digest = layer[digest_field]
- layer_size = layer['size'] if 'size' in layer else None
-
# Store checksums of layers
+ layer_digest = layer[digest_field]
sum_type, layer_sum = layer_digest.split(':')
self.checksums.append([sum_type, layer_sum])
# Store file path and size of each layer
file_path = os.path.join(self.images_dir, layer_sum + '.tar')
+ layer_size = layer.get('size', None)
self.layers.append([file_path, layer_size])
def gen_valid_uri(self, uri):