summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-11-30 15:40:14 -0800
committerJoffrey F <joffrey@docker.com>2018-11-30 15:56:39 -0800
commitbc84ed11ec7f7e20f27139a5e44ae0862d5a1f7b (patch)
tree0e273f39aab7f0014e8b36194308d70ee38abd48
parentc344660f20353bedec6c18ef22b25b3083c8fe3f (diff)
downloaddocker-py-authconfig_fix.tar.gz
Fix empty authconfig detectionauthconfig_fix
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/api/build.py4
-rw-r--r--docker/api/daemon.py2
-rw-r--r--docker/auth.py8
3 files changed, 10 insertions, 4 deletions
diff --git a/docker/api/build.py b/docker/api/build.py
index c4fc37e..5db5838 100644
--- a/docker/api/build.py
+++ b/docker/api/build.py
@@ -286,10 +286,10 @@ class BuildApiMixin(object):
# If we don't have any auth data so far, try reloading the config
# file one more time in case anything showed up in there.
- if not self._auth_configs:
+ if not self._auth_configs or self._auth_configs.is_empty:
log.debug("No auth config in memory - loading from filesystem")
self._auth_configs = auth.load_config(
- credsore_env=self.credsore_env
+ credstore_env=self.credstore_env
)
# Send the full auth configuration (if any exists), since the build
diff --git a/docker/api/daemon.py b/docker/api/daemon.py
index a2936f2..f715a13 100644
--- a/docker/api/daemon.py
+++ b/docker/api/daemon.py
@@ -127,7 +127,7 @@ class DaemonApiMixin(object):
self._auth_configs = auth.load_config(
dockercfg_path, credstore_env=self.credstore_env
)
- elif not self._auth_configs:
+ elif not self._auth_configs or self._auth_configs.is_empty:
self._auth_configs = auth.load_config(
credstore_env=self.credstore_env
)
diff --git a/docker/auth.py b/docker/auth.py
index c1b874f..58b35eb 100644
--- a/docker/auth.py
+++ b/docker/auth.py
@@ -39,7 +39,7 @@ def resolve_index_name(index_name):
def get_config_header(client, registry):
log.debug('Looking for auth config')
- if not client._auth_configs:
+ if not client._auth_configs or client._auth_configs.is_empty:
log.debug(
"No auth config in memory - loading from filesystem"
)
@@ -212,6 +212,12 @@ class AuthConfig(dict):
def cred_helpers(self):
return self.get('credHelpers', {})
+ @property
+ def is_empty(self):
+ return (
+ not self.auths and not self.creds_store and not self.cred_helpers
+ )
+
def resolve_authconfig(self, registry=None):
"""
Returns the authentication data from the given auth configuration for a