#294 Construct the proper Docker API request to get the image manifest.
Merged a year ago by jkaluza. Opened a year ago by jkaluza.
jkaluza/freshmaker lb-arches  into  master

file modified
+11

@@ -33,6 +33,7 @@ 

  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 @@ 

                  "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/<name>/manifests/<reference> 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(

file modified
+3 -1

@@ -1697,7 +1697,9 @@ 

          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'},

          )

  

The pull "URL" in Koji container build is not real URL, but only string based on which the image can be found. To get the manifest of particular image, Freshmaker needs to parse the pull string and construct the proper API request. This PR does that.

Pull-Request has been merged by jkaluza

a year ago