@@ -247,12 +247,15 @@ def inspect_image(self, image):
247
247
248
248
@utils .minimum_version ('1.30' )
249
249
@utils .check_resource ('image' )
250
- def inspect_distribution (self , image ):
250
+ def inspect_distribution (self , image , auth_config = None ):
251
251
"""
252
252
Get image digest and platform information by contacting the registry.
253
253
254
254
Args:
255
255
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.
256
259
257
260
Returns:
258
261
(dict): A dict containing distribution data
@@ -261,9 +264,21 @@ def inspect_distribution(self, image):
261
264
:py:class:`docker.errors.APIError`
262
265
If the server returns an error.
263
266
"""
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 )
264
279
265
280
return self ._result (
266
- self ._get (self . _url ( "/distribution/{0}/json" , image ) ), True
281
+ self ._get (url , headers = headers ), True
267
282
)
268
283
269
284
def load_image (self , data , quiet = None ):
@@ -336,10 +351,9 @@ def pull(self, repository, tag=None, stream=False, auth_config=None,
336
351
tag (str): The tag to pull
337
352
stream (bool): Stream the output as a generator. Make sure to
338
353
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.
343
357
decode (bool): Decode the JSON data from the server into dicts.
344
358
Only applies with ``stream=True``
345
359
platform (str): Platform in the format ``os[/arch[/variant]]``
@@ -414,10 +428,9 @@ def push(self, repository, tag=None, stream=False, auth_config=None,
414
428
repository (str): The repository to push to
415
429
tag (str): An optional tag to push
416
430
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.
421
434
decode (bool): Decode the JSON data from the server into dicts.
422
435
Only applies with ``stream=True``
423
436
0 commit comments