summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-07-10 15:51:17 -0400
committerJoffrey F <joffrey@docker.com>2018-08-09 17:11:47 -0700
commitd4345b5824a23d088bf9c44d9fb87382f159a43a (patch)
treee80dec4121481962e22865d1ff3b0230c2101f56
parentf71d1cf3cfdce2cce77edc9dcdc33879175d44f7 (diff)
downloaddocker-py-d4345b5824a23d088bf9c44d9fb87382f159a43a.tar.gz
Add credHelpers support to set_auth_headers in build
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/api/build.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/docker/api/build.py b/docker/api/build.py
index 419255f..0486dce 100644
--- a/docker/api/build.py
+++ b/docker/api/build.py
@@ -293,20 +293,28 @@ class BuildApiMixin(object):
# Send the full auth configuration (if any exists), since the build
# could use any (or all) of the registries.
if self._auth_configs:
+ auth_cfgs = self._auth_configs
auth_data = {}
- if self._auth_configs.get('credsStore'):
+ if auth_cfgs.get('credsStore'):
# Using a credentials store, we need to retrieve the
# credentials for each registry listed in the config.json file
# Matches CLI behavior: https://github.com/docker/docker/blob/
# 67b85f9d26f1b0b2b240f2d794748fac0f45243c/cliconfig/
# credentials/native_store.go#L68-L83
- for registry in self._auth_configs.get('auths', {}).keys():
+ for registry in auth_cfgs.get('auths', {}).keys():
auth_data[registry] = auth.resolve_authconfig(
- self._auth_configs, registry,
+ auth_cfgs, registry,
credstore_env=self.credstore_env,
)
else:
- auth_data = self._auth_configs.get('auths', {}).copy()
+ for registry in auth_cfgs.get('credHelpers', {}).keys():
+ auth_data[registry] = auth.resolve_authconfig(
+ auth_cfgs, registry,
+ credstore_env=self.credstore_env
+ )
+ for registry, creds in auth_cfgs.get('auths', {}).items():
+ if registry not in auth_data:
+ auth_data[registry] = creds
# See https://github.com/docker/docker-py/issues/1683
if auth.INDEX_NAME in auth_data:
auth_data[auth.INDEX_URL] = auth_data[auth.INDEX_NAME]