@@ -293,41 +293,22 @@ def _set_auth_headers(self, headers):
293
293
# Send the full auth configuration (if any exists), since the build
294
294
# could use any (or all) of the registries.
295
295
if self ._auth_configs :
296
- auth_cfgs = self ._auth_configs
297
- auth_data = {}
298
- if auth_cfgs .get ('credsStore' ):
299
- # Using a credentials store, we need to retrieve the
300
- # credentials for each registry listed in the config.json file
301
- # Matches CLI behavior: https://github.com/docker/docker/blob/
302
- # 67b85f9d26f1b0b2b240f2d794748fac0f45243c/cliconfig/
303
- # credentials/native_store.go#L68-L83
304
- for registry in auth_cfgs .get ('auths' , {}).keys ():
305
- auth_data [registry ] = auth .resolve_authconfig (
306
- auth_cfgs , registry ,
307
- credstore_env = self .credstore_env ,
308
- )
309
- else :
310
- for registry in auth_cfgs .get ('credHelpers' , {}).keys ():
311
- auth_data [registry ] = auth .resolve_authconfig (
312
- auth_cfgs , registry ,
313
- credstore_env = self .credstore_env
314
- )
315
- for registry , creds in auth_cfgs .get ('auths' , {}).items ():
316
- if registry not in auth_data :
317
- auth_data [registry ] = creds
318
- # See https://github.com/docker/docker-py/issues/1683
319
- if auth .INDEX_NAME in auth_data :
320
- auth_data [auth .INDEX_URL ] = auth_data [auth .INDEX_NAME ]
296
+ auth_data = self ._auth_configs .get_all_credentials ()
297
+
298
+ # See https://github.com/docker/docker-py/issues/1683
299
+ if auth .INDEX_URL not in auth_data and auth .INDEX_URL in auth_data :
300
+ auth_data [auth .INDEX_URL ] = auth_data .get (auth .INDEX_NAME , {})
321
301
322
302
log .debug (
323
303
'Sending auth config ({0})' .format (
324
304
', ' .join (repr (k ) for k in auth_data .keys ())
325
305
)
326
306
)
327
307
328
- headers ['X-Registry-Config' ] = auth .encode_header (
329
- auth_data
330
- )
308
+ if auth_data :
309
+ headers ['X-Registry-Config' ] = auth .encode_header (
310
+ auth_data
311
+ )
331
312
else :
332
313
log .debug ('No auth config found' )
333
314
0 commit comments