summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2017-07-05 10:08:41 +0100
committerCédric Bosdonnat <cbosdonnat@suse.com>2017-07-05 16:45:56 +0200
commit0095aca7457911d8515967fd03cd53f76abd465e (patch)
tree290dffce677dc750e90cc406deb7c12cd07bad8a
parentc7a25202019cad8a6a9302ab81cc80d547da0ec9 (diff)
downloadvirt-bootstrap.git-0095aca7457911d8515967fd03cd53f76abd465e.tar.gz
virt-bootstrap.git-0095aca7457911d8515967fd03cd53f76abd465e.tar.xz
virt-bootstrap.git-0095aca7457911d8515967fd03cd53f76abd465e.zip
get_image_details: Use connection options
Pass the "not_secure", "username" and "password" values to "skopeo inspect" when manifest is retrieved.
-rw-r--r--src/virtBootstrap/sources.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/virtBootstrap/sources.py b/src/virtBootstrap/sources.py
index 9c61ac2..db4fe36 100644
--- a/src/virtBootstrap/sources.py
+++ b/src/virtBootstrap/sources.py
@@ -246,13 +246,18 @@ def get_image_dir(no_cache=False):
return DEFAULT_IMG_DIR
-def get_image_details(src, raw=False):
+def get_image_details(src, raw=False,
+ insecure=False, username=False, password=False):
"""
Return details of container image from "skopeo inspect" commnad.
"""
cmd = ['skopeo', 'inspect', src]
if raw:
cmd.append('--raw')
+ if insecure:
+ cmd.append('--tls-verify=false')
+ if username and password:
+ cmd.append("--creds=%s:%s" % (username, password))
proc = Popen(cmd, stdout=PIPE, stderr=PIPE)
output, error = proc.communicate()
if error:
@@ -390,6 +395,9 @@ class DockerSource(object):
self.no_cache = kwargs['no_cache']
self.progress = kwargs['progress'].update_progress
+ if self.username and not self.password:
+ self.password = getpass.getpass()
+
registry = kwargs['uri'].netloc
image = kwargs['uri'].path
@@ -405,7 +413,10 @@ class DockerSource(object):
self.images_dir = get_image_dir(self.no_cache)
# Retrive manifest from registry
- self.manifest = get_image_details(self.url, raw=True)
+ self.manifest = 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 = []
@@ -426,8 +437,6 @@ class DockerSource(object):
if self.insecure:
skopeo_copy.append('--src-tls-verify=false')
if self.username:
- if not self.password:
- self.password = getpass.getpass()
skopeo_copy.append('--src-creds={}:{}'.format(self.username,
self.password))
self.progress("Downloading container image", value=0, logger=logger)