From 0095aca7457911d8515967fd03cd53f76abd465e Mon Sep 17 00:00:00 2001 From: Radostin Stoyanov Date: Wed, 5 Jul 2017 10:08:41 +0100 Subject: get_image_details: Use connection options Pass the "not_secure", "username" and "password" values to "skopeo inspect" when manifest is retrieved. --- src/virtBootstrap/sources.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') 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) -- cgit