diff options
author | Joffrey F <joffrey@docker.com> | 2018-07-10 15:51:17 -0400 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2018-07-19 11:46:02 -0700 |
commit | 87f8956a3206b8b5c16dfb5c1df68e216131f024 (patch) | |
tree | f9925a6504fd74cd7bc7b27576b9908bee963671 | |
parent | e75d79fb7f2a00aef4129465ecb06dd780ad0841 (diff) | |
download | docker-py-2078-credhelpers-support.tar.gz |
Add credHelpers support to set_auth_headers in build2078-credhelpers-support
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r-- | docker/api/build.py | 16 |
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] |