diff --git a/meta-stx-integ/recipes-devtools/python/python-docker/0001-Add-auth_config-to-api.image.inspect_distribution.patch b/meta-stx-integ/recipes-devtools/python/python-docker/0001-Add-auth_config-to-api.image.inspect_distribution.patch new file mode 100644 index 0000000..7d260d5 --- /dev/null +++ b/meta-stx-integ/recipes-devtools/python/python-docker/0001-Add-auth_config-to-api.image.inspect_distribution.patch @@ -0,0 +1,64 @@ +From 55dc1d720418c552657160d1165e2be7e0a80069 Mon Sep 17 00:00:00 2001 +From: Thiago Brito +Date: Tue, 6 Jul 2021 15:41:06 -0300 +Subject: [PATCH 2/2] Add auth_config to api.image.inspect_distribution + +This is an excerpt from docker-py 4.4.4 needed to check if a given image +exists in an authenticated registry. + +Upstream-Status: Backport + +Signed-off-by: Thiago Brito +Signed-off-by: Jackie Huang +--- + docker/api/image.py | 22 +++++++++++++++++----- + 1 file changed, 17 insertions(+), 5 deletions(-) + +diff --git a/docker/api/image.py b/docker/api/image.py +index 5f05d88..8fc9164 100644 +--- a/docker/api/image.py ++++ b/docker/api/image.py +@@ -247,23 +247,35 @@ class ImageApiMixin(object): + + @utils.minimum_version('1.30') + @utils.check_resource('image') +- def inspect_distribution(self, image): ++ def inspect_distribution(self, image, auth_config=None): + """ + Get image digest and platform information by contacting the registry. +- + Args: + image (str): The image name to inspect +- ++ auth_config (dict): Override the credentials that are found in the ++ config for this request. ``auth_config`` should contain the ++ ``username`` and ``password`` keys to be valid. + Returns: + (dict): A dict containing distribution data +- + Raises: + :py:class:`docker.errors.APIError` + If the server returns an error. + """ ++ registry, _ = auth.resolve_repository_name(image) ++ ++ headers = {} ++ if auth_config is None: ++ header = auth.get_config_header(self, registry) ++ if header: ++ headers['X-Registry-Auth'] = header ++ else: ++ log.debug('Sending supplied auth config') ++ headers['X-Registry-Auth'] = auth.encode_header(auth_config) ++ ++ url = self._url("/distribution/{0}/json", image) + + return self._result( +- self._get(self._url("/distribution/{0}/json", image)), True ++ self._get(url, headers=headers), True + ) + + def load_image(self, data, quiet=None): +-- +2.17.1 + diff --git a/meta-stx-integ/recipes-devtools/python/python-docker_3.3.0.bb b/meta-stx-integ/recipes-devtools/python/python-docker_3.3.0.bb index 75bff13..b2531db 100644 --- a/meta-stx-integ/recipes-devtools/python/python-docker_3.3.0.bb +++ b/meta-stx-integ/recipes-devtools/python/python-docker_3.3.0.bb @@ -5,6 +5,10 @@ SECTION = "devel/python" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=34f3846f940453127309b920eeb89660" +SRC_URI += "\ + file://0001-Add-auth_config-to-api.image.inspect_distribution.patch \ + " + SRC_URI[md5sum] = "660c3c0c3776cb88f34fc549d7c89ed2" SRC_URI[sha256sum] = "dc5cc0971a0d36fe94c5ce89bd4adb6c892713500af7b0818708229c3199911a"