Merge "Update fetch_wheels to add Accept header"

This commit is contained in:
Zuul 2022-10-06 04:10:38 +00:00 committed by Gerrit Code Review
commit 5688c6ffa3
1 changed files with 6 additions and 2 deletions

View File

@ -5,11 +5,11 @@ import os
import platform
import re
import ssl
from distutils.util import strtobool
from urllib import request as urllib2
DOCKER_REGISTRY='registry.hub.docker.com'
MANIFEST_V1 = 'application/vnd.oci.image.manifest.v1+json'
MANIFEST_V2 = 'application/vnd.docker.distribution.manifest.v2+json'
MANIFEST_V2_LIST = 'application/vnd.docker.distribution.manifest.list.v2+json'
@ -18,6 +18,10 @@ ARCH_MAP = {
'aarch64': 'arm64',
}
# Clone from the now-deprecated distutils
def strtobool(v):
return str(v).lower() in ("yes", "true", "t", "1")
def registry_urlopen(r):
if strtobool(os.environ.get('REGISTRY_INSECURE', "False")):
resp = urllib2.urlopen(r, context=ssl._create_unverified_context())
@ -52,7 +56,7 @@ def registry_request(r, token=None):
def get_sha(repo, tag, registry, protocol):
headers = {
'Accept': ', '.join([MANIFEST_V2_LIST, MANIFEST_V2])
'Accept': ', '.join([MANIFEST_V2_LIST, MANIFEST_V2, MANIFEST_V1])
}
url = "{}://{}/v2/{}/manifests/{}".format(protocol, registry, repo, tag)
print(url)