Skip to content

Commit 5c74846

Browse files
authored
Merge pull request #2192 from docker/authconfig_fix
Fix empty authconfig detection
2 parents c344660 + bc84ed1 commit 5c74846

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

docker/api/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,10 @@ def _set_auth_headers(self, headers):
286286

287287
# If we don't have any auth data so far, try reloading the config
288288
# file one more time in case anything showed up in there.
289-
if not self._auth_configs:
289+
if not self._auth_configs or self._auth_configs.is_empty:
290290
log.debug("No auth config in memory - loading from filesystem")
291291
self._auth_configs = auth.load_config(
292-
credsore_env=self.credsore_env
292+
credstore_env=self.credstore_env
293293
)
294294

295295
# Send the full auth configuration (if any exists), since the build

docker/api/daemon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def login(self, username, password=None, email=None, registry=None,
127127
self._auth_configs = auth.load_config(
128128
dockercfg_path, credstore_env=self.credstore_env
129129
)
130-
elif not self._auth_configs:
130+
elif not self._auth_configs or self._auth_configs.is_empty:
131131
self._auth_configs = auth.load_config(
132132
credstore_env=self.credstore_env
133133
)

docker/auth.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def resolve_index_name(index_name):
3939

4040
def get_config_header(client, registry):
4141
log.debug('Looking for auth config')
42-
if not client._auth_configs:
42+
if not client._auth_configs or client._auth_configs.is_empty:
4343
log.debug(
4444
"No auth config in memory - loading from filesystem"
4545
)
@@ -212,6 +212,12 @@ def creds_store(self):
212212
def cred_helpers(self):
213213
return self.get('credHelpers', {})
214214

215+
@property
216+
def is_empty(self):
217+
return (
218+
not self.auths and not self.creds_store and not self.cred_helpers
219+
)
220+
215221
def resolve_authconfig(self, registry=None):
216222
"""
217223
Returns the authentication data from the given auth configuration for a

0 commit comments

Comments
 (0)