diff options
author | Joffrey F <joffrey@docker.com> | 2017-06-22 11:51:31 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2017-06-22 11:51:31 -0700 |
commit | 320c81047107a4350bb430f24825d116a91d1d8f (patch) | |
tree | f640085fe22f46d606b56a26c6dbd52d2ef5f41f /docker/auth.py | |
parent | a3b1059839ee5314834131f1af9b391fca99bf13 (diff) | |
download | docker-py-1633-credhelpers-support.tar.gz |
Support credHelpers section in config.json1633-credhelpers-support
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/auth.py')
-rw-r--r-- | docker/auth.py | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/docker/auth.py b/docker/auth.py index 7c1ce76..ec9c45b 100644 --- a/docker/auth.py +++ b/docker/auth.py @@ -70,6 +70,15 @@ def split_repo_name(repo_name): return tuple(parts) +def get_credential_store(authconfig, registry): + if not registry or registry == INDEX_NAME: + registry = 'https://index.docker.io/v1/' + + return authconfig.get('credHelpers', {}).get(registry) or authconfig.get( + 'credsStore' + ) + + def resolve_authconfig(authconfig, registry=None): """ Returns the authentication data from the given auth configuration for a @@ -77,13 +86,17 @@ def resolve_authconfig(authconfig, registry=None): with full URLs are stripped down to hostnames before checking for a match. Returns None if no match was found. """ - if 'credsStore' in authconfig: - log.debug( - 'Using credentials store "{0}"'.format(authconfig['credsStore']) - ) - return _resolve_authconfig_credstore( - authconfig, registry, authconfig['credsStore'] - ) + + if 'credHelpers' in authconfig or 'credsStore' in authconfig: + store_name = get_credential_store(authconfig, registry) + if store_name is not None: + log.debug( + 'Using credentials store "{0}"'.format(store_name) + ) + return _resolve_authconfig_credstore( + authconfig, registry, store_name + ) + # Default to the public index server registry = resolve_index_name(registry) if registry else INDEX_NAME log.debug("Looking for auth entry for {0}".format(repr(registry))) @@ -274,6 +287,9 @@ def load_config(config_path=None): if data.get('credsStore'): log.debug("Found 'credsStore' section") res.update({'credsStore': data['credsStore']}) + if data.get('credHelpers'): + log.debug("Found 'credHelpers' section") + res.update({'credHelpers': data['credHelpers']}) if res: return res else: |