Skip to content

Commit 541edd7

Browse files
committed
Don't raise InvalidConfigError when auth dict doesn't have an 'auth' key
Signed-off-by: Joffrey F <[email protected]>
1 parent e743254 commit 541edd7

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

docker/auth/auth.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def parse_auth(entries, raise_on_error=False):
117117

118118
conf = {}
119119
for registry, entry in six.iteritems(entries):
120-
if not (isinstance(entry, dict) and 'auth' in entry):
120+
if not isinstance(entry, dict):
121121
log.debug(
122122
'Config entry for key {0} is not auth config'.format(registry)
123123
)
@@ -130,6 +130,16 @@ def parse_auth(entries, raise_on_error=False):
130130
'Invalid configuration for registry {0}'.format(registry)
131131
)
132132
return {}
133+
if 'auth' not in entry:
134+
# Starting with engine v1.11 (API 1.23), an empty dictionary is
135+
# a valid value in the auths config.
136+
# https://github.com/docker/compose/issues/3265
137+
log.debug(
138+
'Auth data for {0} is absent. Client might be using a '
139+
'credentials store instead.'
140+
)
141+
return {}
142+
133143
username, password = decode_auth(entry['auth'])
134144
log.debug(
135145
'Found entry (registry={0}, username={1})'
@@ -189,6 +199,9 @@ def load_config(config_path=None):
189199
if data.get('HttpHeaders'):
190200
log.debug("Found 'HttpHeaders' section")
191201
res.update({'HttpHeaders': data['HttpHeaders']})
202+
if data.get('credsStore'):
203+
log.debug("Found 'credsStore' section")
204+
res.update({'credsStore': data['credsStore']})
192205
if res:
193206
return res
194207
else:

tests/unit/auth_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,5 @@ def test_load_config_invalid_auth_dict(self):
459459
with open(dockercfg_path, 'w') as f:
460460
json.dump(config, f)
461461

462-
self.assertRaises(
463-
errors.InvalidConfigFile, auth.load_config, dockercfg_path
464-
)
462+
cfg = auth.load_config(dockercfg_path)
463+
assert cfg == {}

0 commit comments

Comments
 (0)