summaryrefslogtreecommitdiffstats
path: root/src/virtBootstrap
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2017-07-18 10:12:52 +0100
committerCédric Bosdonnat <cbosdonnat@suse.com>2017-07-18 17:43:14 +0200
commit3e7cbbdcc953b5249b9b462a97acff0176dfcbfd (patch)
tree0b145cfb362baed789a0415b6eb5ef2dd6d96da4 /src/virtBootstrap
parent0ea92b352ad4495a9ee902f00773272df6676487 (diff)
downloadvirt-bootstrap.git-3e7cbbdcc953b5249b9b462a97acff0176dfcbfd.tar.gz
virt-bootstrap.git-3e7cbbdcc953b5249b9b462a97acff0176dfcbfd.tar.xz
virt-bootstrap.git-3e7cbbdcc953b5249b9b462a97acff0176dfcbfd.zip
DockerSource: Encapsulate layers' info retrieval
This change makes it easier to test the code.
Diffstat (limited to 'src/virtBootstrap')
-rw-r--r--src/virtBootstrap/sources.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/virtBootstrap/sources.py b/src/virtBootstrap/sources.py
index b832e34..eaf3f8f 100644
--- a/src/virtBootstrap/sources.py
+++ b/src/virtBootstrap/sources.py
@@ -108,6 +108,8 @@ class DockerSource(object):
self.insecure = kwargs['not_secure']
self.no_cache = kwargs['no_cache']
self.progress = kwargs['progress'].update_progress
+ self.manifest = None
+ self.layers = []
if self.username and not self.password:
self.password = getpass.getpass()
@@ -126,14 +128,18 @@ class DockerSource(object):
self.url = "docker://" + registry + image
self.images_dir = utils.get_image_dir(self.no_cache)
- # Retrive manifest from registry
+ self.retrieve_layers_info()
+
+ def retrieve_layers_info(self):
+ """
+ Retrive manifest from registry and get layers' digest,
+ sum_type, size and file_path in a list.
+ """
self.manifest = utils.get_image_details(self.url, raw=True,
insecure=self.insecure,
username=self.username,
password=self.password)
- # Get layers' digest, sum_type, size and file_path in a list
- self.layers = []
for layer in self.manifest['layers']:
sum_type, layer_sum = layer['digest'].split(':')
file_path = os.path.join(self.images_dir, layer_sum + '.tar')