summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2016-12-01 17:50:10 -0800
committerJoffrey F <joffrey@docker.com>2016-12-01 18:04:15 -0800
commitd042c6aeda59f5bf7769085616eb56de8ee5fbe7 (patch)
tree4a4360f4038a4046775f7eea66e0b59b73a41ae2
parent01c33c0f684868290249945f9db9e00d7f03ecd9 (diff)
downloaddocker-py-compose4171_build_auth_headers.tar.gz
Properly fill out auth headers in APIClient.build when usingcompose4171_build_auth_headers
a credentials store Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/api/build.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/docker/api/build.py b/docker/api/build.py
index 7cf4e0f..eb01bce 100644
--- a/docker/api/build.py
+++ b/docker/api/build.py
@@ -230,19 +230,35 @@ 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_data = {}
+ if self._auth_configs.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.keys():
+ if registry == 'credsStore' or registry == 'HttpHeaders':
+ continue
+ auth_data[registry] = auth.resolve_authconfig(
+ self._auth_configs, registry
+ )
+ else:
+ auth_data = self._auth_configs
+
log.debug(
'Sending auth config ({0})'.format(
- ', '.join(repr(k) for k in self._auth_configs.keys())
+ ', '.join(repr(k) for k in auth_data.keys())
)
)
if utils.compare_version('1.19', self._version) >= 0:
headers['X-Registry-Config'] = auth.encode_header(
- self._auth_configs
+ auth_data
)
else:
headers['X-Registry-Config'] = auth.encode_header({
- 'configs': self._auth_configs
+ 'configs': auth_data
})
else:
log.debug('No auth config found')