@@ -247,12 +247,15 @@ def inspect_image(self, image):
247247
248248 @utils .minimum_version ('1.30' )
249249 @utils .check_resource ('image' )
250- def inspect_distribution (self , image ):
250+ def inspect_distribution (self , image , auth_config = None ):
251251 """
252252 Get image digest and platform information by contacting the registry.
253253
254254 Args:
255255 image (str): The image name to inspect
256+ auth_config (dict): Override the credentials that are found in the
257+ config for this request. ``auth_config`` should contain the
258+ ``username`` and ``password`` keys to be valid.
256259
257260 Returns:
258261 (dict): A dict containing distribution data
@@ -261,9 +264,21 @@ def inspect_distribution(self, image):
261264 :py:class:`docker.errors.APIError`
262265 If the server returns an error.
263266 """
267+ registry , _ = auth .resolve_repository_name (image )
268+
269+ headers = {}
270+ if auth_config is None :
271+ header = auth .get_config_header (self , registry )
272+ if header :
273+ headers ['X-Registry-Auth' ] = header
274+ else :
275+ log .debug ('Sending supplied auth config' )
276+ headers ['X-Registry-Auth' ] = auth .encode_header (auth_config )
277+
278+ url = self ._url ("/distribution/{0}/json" , image )
264279
265280 return self ._result (
266- self ._get (self . _url ( "/distribution/{0}/json" , image ) ), True
281+ self ._get (url , headers = headers ), True
267282 )
268283
269284 def load_image (self , data , quiet = None ):
@@ -336,10 +351,9 @@ def pull(self, repository, tag=None, stream=False, auth_config=None,
336351 tag (str): The tag to pull
337352 stream (bool): Stream the output as a generator. Make sure to
338353 consume the generator, otherwise pull might get cancelled.
339- auth_config (dict): Override the credentials that
340- :py:meth:`~docker.api.daemon.DaemonApiMixin.login` has set for
341- this request. ``auth_config`` should contain the ``username``
342- and ``password`` keys to be valid.
354+ auth_config (dict): Override the credentials that are found in the
355+ config for this request. ``auth_config`` should contain the
356+ ``username`` and ``password`` keys to be valid.
343357 decode (bool): Decode the JSON data from the server into dicts.
344358 Only applies with ``stream=True``
345359 platform (str): Platform in the format ``os[/arch[/variant]]``
@@ -414,10 +428,9 @@ def push(self, repository, tag=None, stream=False, auth_config=None,
414428 repository (str): The repository to push to
415429 tag (str): An optional tag to push
416430 stream (bool): Stream the output as a blocking generator
417- auth_config (dict): Override the credentials that
418- :py:meth:`~docker.api.daemon.DaemonApiMixin.login` has set for
419- this request. ``auth_config`` should contain the ``username``
420- and ``password`` keys to be valid.
431+ auth_config (dict): Override the credentials that are found in the
432+ config for this request. ``auth_config`` should contain the
433+ ``username`` and ``password`` keys to be valid.
421434 decode (bool): Decode the JSON data from the server into dicts.
422435 Only applies with ``stream=True``
423436
0 commit comments