@@ -230,19 +230,35 @@ def _set_auth_headers(self, headers):
230
230
# Send the full auth configuration (if any exists), since the build
231
231
# could use any (or all) of the registries.
232
232
if self ._auth_configs :
233
+ auth_data = {}
234
+ if self ._auth_configs .get ('credsStore' ):
235
+ # Using a credentials store, we need to retrieve the
236
+ # credentials for each registry listed in the config.json file
237
+ # Matches CLI behavior: https://github.com/docker/docker/blob/
238
+ # 67b85f9d26f1b0b2b240f2d794748fac0f45243c/cliconfig/
239
+ # credentials/native_store.go#L68-L83
240
+ for registry in self ._auth_configs .keys ():
241
+ if registry == 'credsStore' or registry == 'HttpHeaders' :
242
+ continue
243
+ auth_data [registry ] = auth .resolve_authconfig (
244
+ self ._auth_configs , registry
245
+ )
246
+ else :
247
+ auth_data = self ._auth_configs
248
+
233
249
log .debug (
234
250
'Sending auth config ({0})' .format (
235
- ', ' .join (repr (k ) for k in self . _auth_configs .keys ())
251
+ ', ' .join (repr (k ) for k in auth_data .keys ())
236
252
)
237
253
)
238
254
239
255
if utils .compare_version ('1.19' , self ._version ) >= 0 :
240
256
headers ['X-Registry-Config' ] = auth .encode_header (
241
- self . _auth_configs
257
+ auth_data
242
258
)
243
259
else :
244
260
headers ['X-Registry-Config' ] = auth .encode_header ({
245
- 'configs' : self . _auth_configs
261
+ 'configs' : auth_data
246
262
})
247
263
else :
248
264
log .debug ('No auth config found' )
0 commit comments