Kaydet (Commit) f68a4f95 authored tarafından Joffrey F's avatar Joffrey F

Merge pull request #1022 from docker/1021-empty-auth

Don't raise InvalidConfigError when auth dict doesn't have an 'auth' key
...@@ -117,7 +117,7 @@ def parse_auth(entries, raise_on_error=False): ...@@ -117,7 +117,7 @@ def parse_auth(entries, raise_on_error=False):
conf = {} conf = {}
for registry, entry in six.iteritems(entries): for registry, entry in six.iteritems(entries):
if not (isinstance(entry, dict) and 'auth' in entry): if not isinstance(entry, dict):
log.debug( log.debug(
'Config entry for key {0} is not auth config'.format(registry) 'Config entry for key {0} is not auth config'.format(registry)
) )
...@@ -130,6 +130,16 @@ def parse_auth(entries, raise_on_error=False): ...@@ -130,6 +130,16 @@ def parse_auth(entries, raise_on_error=False):
'Invalid configuration for registry {0}'.format(registry) 'Invalid configuration for registry {0}'.format(registry)
) )
return {} return {}
if 'auth' not in entry:
# Starting with engine v1.11 (API 1.23), an empty dictionary is
# a valid value in the auths config.
# https://github.com/docker/compose/issues/3265
log.debug(
'Auth data for {0} is absent. Client might be using a '
'credentials store instead.'
)
return {}
username, password = decode_auth(entry['auth']) username, password = decode_auth(entry['auth'])
log.debug( log.debug(
'Found entry (registry={0}, username={1})' 'Found entry (registry={0}, username={1})'
...@@ -189,6 +199,9 @@ def load_config(config_path=None): ...@@ -189,6 +199,9 @@ def load_config(config_path=None):
if data.get('HttpHeaders'): if data.get('HttpHeaders'):
log.debug("Found 'HttpHeaders' section") log.debug("Found 'HttpHeaders' section")
res.update({'HttpHeaders': data['HttpHeaders']}) res.update({'HttpHeaders': data['HttpHeaders']})
if data.get('credsStore'):
log.debug("Found 'credsStore' section")
res.update({'credsStore': data['credsStore']})
if res: if res:
return res return res
else: else:
......
...@@ -459,6 +459,5 @@ class LoadConfigTest(base.Cleanup, base.BaseTestCase): ...@@ -459,6 +459,5 @@ class LoadConfigTest(base.Cleanup, base.BaseTestCase):
with open(dockercfg_path, 'w') as f: with open(dockercfg_path, 'w') as f:
json.dump(config, f) json.dump(config, f)
self.assertRaises( cfg = auth.load_config(dockercfg_path)
errors.InvalidConfigFile, auth.load_config, dockercfg_path assert cfg == {}
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment