From a77e8b0a59d177eb6942402474b39da3d93f8831 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Jul 03 2018 08:41:32 +0000 Subject: Construct the proper Docker API request to get the image manifest. --- diff --git a/freshmaker/lightblue.py b/freshmaker/lightblue.py index 732119b..99df80c 100644 --- a/freshmaker/lightblue.py +++ b/freshmaker/lightblue.py @@ -33,6 +33,7 @@ import dogpile.cache from itertools import groupby from six.moves import http_client +from six.moves.urllib.parse import urlparse import concurrent.futures from freshmaker import log, conf from freshmaker.kojiservice import koji_service @@ -284,6 +285,16 @@ class ContainerImage(dict): "Could not find pull url for Koji build %r %r" % (nvr, digest)) url = registry_urls[0].split(digest)[0].strip('@') + # If URL does not contain the scheme, use http as default. + if not url.startswith("http"): + url = "http://" + url + # Construct the proper API requests in + # GET /v2//manifests/ format. + parsed_url = urlparse(url) + url = "%s://%s/v2/%s/manifests/%s" % ( + parsed_url.scheme, parsed_url.netloc, parsed_url.path.strip("/"), + digest) + response = requests.get(url, headers=dict(Accept=manifest_list)) if not response.ok: raise KojiLookupError( diff --git a/tests/test_lightblue.py b/tests/test_lightblue.py index 1d8232e..2c0af27 100644 --- a/tests/test_lightblue.py +++ b/tests/test_lightblue.py @@ -1697,7 +1697,9 @@ class TestArchitecturesFromRegistry(helpers.FreshmakerTestCase): result = image._get_architectures_from_registry("foo", self.build) self.assertEqual(result, 'x86_64,s390x,ppc64le') requests.get.assert_called_once_with( - 'blue-pulp-smocker01.sledmat.com:8888/devtools/rust-toolset-7-rhel7', + 'http://blue-pulp-smocker01.sledmat.com:8888/v2/devtools/' + 'rust-toolset-7-rhel7/manifests/' + 'sha256:252084580dd052fd6d16b5eb25397cf2396c69ec485ba34692577ebd25693fa7', headers={'Accept': 'application/vnd.docker.distribution.manifest.list.v2+json'}, )