Skip to content

Commit d4345b5

Browse files
committed
Add credHelpers support to set_auth_headers in build
Signed-off-by: Joffrey F <[email protected]>
1 parent f71d1cf commit d4345b5

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docker/api/build.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,20 +293,28 @@ def _set_auth_headers(self, headers):
293293
# Send the full auth configuration (if any exists), since the build
294294
# could use any (or all) of the registries.
295295
if self._auth_configs:
296+
auth_cfgs = self._auth_configs
296297
auth_data = {}
297-
if self._auth_configs.get('credsStore'):
298+
if auth_cfgs.get('credsStore'):
298299
# Using a credentials store, we need to retrieve the
299300
# credentials for each registry listed in the config.json file
300301
# Matches CLI behavior: https://github.com/docker/docker/blob/
301302
# 67b85f9d26f1b0b2b240f2d794748fac0f45243c/cliconfig/
302303
# credentials/native_store.go#L68-L83
303-
for registry in self._auth_configs.get('auths', {}).keys():
304+
for registry in auth_cfgs.get('auths', {}).keys():
304305
auth_data[registry] = auth.resolve_authconfig(
305-
self._auth_configs, registry,
306+
auth_cfgs, registry,
306307
credstore_env=self.credstore_env,
307308
)
308309
else:
309-
auth_data = self._auth_configs.get('auths', {}).copy()
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
310318
# See https://github.com/docker/docker-py/issues/1683
311319
if auth.INDEX_NAME in auth_data:
312320
auth_data[auth.INDEX_URL] = auth_data[auth.INDEX_NAME]

0 commit comments

Comments
 (0)