We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Empty auth dictionary should be valid
docker/compose#3265


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `docker/auth/auth.py`
Content:
```
1 # Copyright 2013 dotCloud inc.
2 
3 #    Licensed under the Apache License, Version 2.0 (the "License");
4 #    you may not use this file except in compliance with the License.
5 #    You may obtain a copy of the License at
6 
7 #        http://www.apache.org/licenses/LICENSE-2.0
8 
9 #    Unless required by applicable law or agreed to in writing, software
10 #    distributed under the License is distributed on an "AS IS" BASIS,
11 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #    See the License for the specific language governing permissions and
13 #    limitations under the License.
14 
15 import base64
16 import json
17 import logging
18 import os
19 
20 import six
21 
22 from .. import errors
23 
24 INDEX_NAME = 'docker.io'
25 INDEX_URL = 'https://{0}/v1/'.format(INDEX_NAME)
26 DOCKER_CONFIG_FILENAME = os.path.join('.docker', 'config.json')
27 LEGACY_DOCKER_CONFIG_FILENAME = '.dockercfg'
28 
29 log = logging.getLogger(__name__)
30 
31 
32 def resolve_repository_name(repo_name):
33     if '://' in repo_name:
34         raise errors.InvalidRepository(
35             'Repository name cannot contain a scheme ({0})'.format(repo_name)
36         )
37 
38     index_name, remote_name = split_repo_name(repo_name)
39     if index_name[0] == '-' or index_name[-1] == '-':
40         raise errors.InvalidRepository(
41             'Invalid index name ({0}). Cannot begin or end with a'
42             ' hyphen.'.format(index_name)
43         )
44     return resolve_index_name(index_name), remote_name
45 
46 
47 def resolve_index_name(index_name):
48     index_name = convert_to_hostname(index_name)
49     if index_name == 'index.' + INDEX_NAME:
50         index_name = INDEX_NAME
51     return index_name
52 
53 
54 def split_repo_name(repo_name):
55     parts = repo_name.split('/', 1)
56     if len(parts) == 1 or (
57         '.' not in parts[0] and ':' not in parts[0] and parts[0] != 'localhost'
58     ):
59         # This is a docker index repo (ex: username/foobar or ubuntu)
60         return INDEX_NAME, repo_name
61     return tuple(parts)
62 
63 
64 def resolve_authconfig(authconfig, registry=None):
65     """
66     Returns the authentication data from the given auth configuration for a
67     specific registry. As with the Docker client, legacy entries in the config
68     with full URLs are stripped down to hostnames before checking for a match.
69     Returns None if no match was found.
70     """
71     # Default to the public index server
72     registry = resolve_index_name(registry) if registry else INDEX_NAME
73     log.debug("Looking for auth entry for {0}".format(repr(registry)))
74 
75     if registry in authconfig:
76         log.debug("Found {0}".format(repr(registry)))
77         return authconfig[registry]
78 
79     for key, config in six.iteritems(authconfig):
80         if resolve_index_name(key) == registry:
81             log.debug("Found {0}".format(repr(key)))
82             return config
83 
84     log.debug("No entry found")
85     return None
86 
87 
88 def convert_to_hostname(url):
89     return url.replace('http://', '').replace('https://', '').split('/', 1)[0]
90 
91 
92 def decode_auth(auth):
93     if isinstance(auth, six.string_types):
94         auth = auth.encode('ascii')
95     s = base64.b64decode(auth)
96     login, pwd = s.split(b':', 1)
97     return login.decode('utf8'), pwd.decode('utf8')
98 
99 
100 def encode_header(auth):
101     auth_json = json.dumps(auth).encode('ascii')
102     return base64.urlsafe_b64encode(auth_json)
103 
104 
105 def parse_auth(entries, raise_on_error=False):
106     """
107     Parses authentication entries
108 
109     Args:
110       entries:        Dict of authentication entries.
111       raise_on_error: If set to true, an invalid format will raise
112                       InvalidConfigFile
113 
114     Returns:
115       Authentication registry.
116     """
117 
118     conf = {}
119     for registry, entry in six.iteritems(entries):
120         if not (isinstance(entry, dict) and 'auth' in entry):
121             log.debug(
122                 'Config entry for key {0} is not auth config'.format(registry)
123             )
124             # We sometimes fall back to parsing the whole config as if it was
125             # the auth config by itself, for legacy purposes. In that case, we
126             # fail silently and return an empty conf if any of the keys is not
127             # formatted properly.
128             if raise_on_error:
129                 raise errors.InvalidConfigFile(
130                     'Invalid configuration for registry {0}'.format(registry)
131                 )
132             return {}
133         username, password = decode_auth(entry['auth'])
134         log.debug(
135             'Found entry (registry={0}, username={1})'
136             .format(repr(registry), repr(username))
137         )
138         conf[registry] = {
139             'username': username,
140             'password': password,
141             'email': entry.get('email'),
142             'serveraddress': registry,
143         }
144     return conf
145 
146 
147 def find_config_file(config_path=None):
148     environment_path = os.path.join(
149         os.environ.get('DOCKER_CONFIG'),
150         os.path.basename(DOCKER_CONFIG_FILENAME)
151     ) if os.environ.get('DOCKER_CONFIG') else None
152 
153     paths = [
154         config_path,  # 1
155         environment_path,  # 2
156         os.path.join(os.path.expanduser('~'), DOCKER_CONFIG_FILENAME),  # 3
157         os.path.join(
158             os.path.expanduser('~'), LEGACY_DOCKER_CONFIG_FILENAME
159         )  # 4
160     ]
161 
162     for path in paths:
163         if path and os.path.exists(path):
164             return path
165     return None
166 
167 
168 def load_config(config_path=None):
169     """
170     Loads authentication data from a Docker configuration file in the given
171     root directory or if config_path is passed use given path.
172     Lookup priority:
173         explicit config_path parameter > DOCKER_CONFIG environment variable >
174         ~/.docker/config.json > ~/.dockercfg
175     """
176     config_file = find_config_file(config_path)
177 
178     if not config_file:
179         log.debug("File doesn't exist")
180         return {}
181 
182     try:
183         with open(config_file) as f:
184             data = json.load(f)
185             res = {}
186             if data.get('auths'):
187                 log.debug("Found 'auths' section")
188                 res.update(parse_auth(data['auths'], raise_on_error=True))
189             if data.get('HttpHeaders'):
190                 log.debug("Found 'HttpHeaders' section")
191                 res.update({'HttpHeaders': data['HttpHeaders']})
192             if res:
193                 return res
194             else:
195                 log.debug("Couldn't find 'auths' or 'HttpHeaders' sections")
196                 f.seek(0)
197                 return parse_auth(json.load(f))
198     except (IOError, KeyError, ValueError) as e:
199         # Likely missing new Docker config file or it's in an
200         # unknown format, continue to attempt to read old location
201         # and format.
202         log.debug(e)
203 
204     log.debug("Attempting to parse legacy auth file format")
205     try:
206         data = []
207         with open(config_file) as f:
208             for line in f.readlines():
209                 data.append(line.strip().split(' = ')[1])
210             if len(data) < 2:
211                 # Not enough data
212                 raise errors.InvalidConfigFile(
213                     'Invalid or empty configuration file!'
214                 )
215 
216         username, password = decode_auth(data[0])
217         return {
218             INDEX_NAME: {
219                 'username': username,
220                 'password': password,
221                 'email': data[1],
222                 'serveraddress': INDEX_URL,
223             }
224         }
225     except Exception as e:
226         log.debug(e)
227         pass
228 
229     log.debug("All parsing attempts failed - returning empty config")
230     return {}
231
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/docker/auth/auth.py b/docker/auth/auth.py
--- a/docker/auth/auth.py
+++ b/docker/auth/auth.py
@@ -117,7 +117,7 @@
 
     conf = {}
     for registry, entry in six.iteritems(entries):
-        if not (isinstance(entry, dict) and 'auth' in entry):
+        if not isinstance(entry, dict):
             log.debug(
                 'Config entry for key {0} is not auth config'.format(registry)
             )
@@ -130,6 +130,16 @@
                     'Invalid configuration for registry {0}'.format(registry)
                 )
             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'])
         log.debug(
             'Found entry (registry={0}, username={1})'
@@ -189,6 +199,9 @@
             if data.get('HttpHeaders'):
                 log.debug("Found 'HttpHeaders' section")
                 res.update({'HttpHeaders': data['HttpHeaders']})
+            if data.get('credsStore'):
+                log.debug("Found 'credsStore' section")
+                res.update({'credsStore': data['credsStore']})
             if res:
                 return res
             else:

{"golden_diff": "diff --git a/docker/auth/auth.py b/docker/auth/auth.py\n--- a/docker/auth/auth.py\n+++ b/docker/auth/auth.py\n@@ -117,7 +117,7 @@\n \n     conf = {}\n     for registry, entry in six.iteritems(entries):\n-        if not (isinstance(entry, dict) and 'auth' in entry):\n+        if not isinstance(entry, dict):\n             log.debug(\n                 'Config entry for key {0} is not auth config'.format(registry)\n             )\n@@ -130,6 +130,16 @@\n                     'Invalid configuration for registry {0}'.format(registry)\n                 )\n             return {}\n+        if 'auth' not in entry:\n+            # Starting with engine v1.11 (API 1.23), an empty dictionary is\n+            # a valid value in the auths config.\n+            # https://github.com/docker/compose/issues/3265\n+            log.debug(\n+                'Auth data for {0} is absent. Client might be using a '\n+                'credentials store instead.'\n+            )\n+            return {}\n+\n         username, password = decode_auth(entry['auth'])\n         log.debug(\n             'Found entry (registry={0}, username={1})'\n@@ -189,6 +199,9 @@\n             if data.get('HttpHeaders'):\n                 log.debug(\"Found 'HttpHeaders' section\")\n                 res.update({'HttpHeaders': data['HttpHeaders']})\n+            if data.get('credsStore'):\n+                log.debug(\"Found 'credsStore' section\")\n+                res.update({'credsStore': data['credsStore']})\n             if res:\n                 return res\n             else:\n", "issue": "Empty auth dictionary should be valid\ndocker/compose#3265\n\n", "before_files": [{"content": "# Copyright 2013 dotCloud inc.\n\n#    Licensed under the Apache License, Version 2.0 (the \"License\");\n#    you may not use this file except in compliance with the License.\n#    You may obtain a copy of the License at\n\n#        http://www.apache.org/licenses/LICENSE-2.0\n\n#    Unless required by applicable law or agreed to in writing, software\n#    distributed under the License is distributed on an \"AS IS\" BASIS,\n#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n#    See the License for the specific language governing permissions and\n#    limitations under the License.\n\nimport base64\nimport json\nimport logging\nimport os\n\nimport six\n\nfrom .. import errors\n\nINDEX_NAME = 'docker.io'\nINDEX_URL = 'https://{0}/v1/'.format(INDEX_NAME)\nDOCKER_CONFIG_FILENAME = os.path.join('.docker', 'config.json')\nLEGACY_DOCKER_CONFIG_FILENAME = '.dockercfg'\n\nlog = logging.getLogger(__name__)\n\n\ndef resolve_repository_name(repo_name):\n    if '://' in repo_name:\n        raise errors.InvalidRepository(\n            'Repository name cannot contain a scheme ({0})'.format(repo_name)\n        )\n\n    index_name, remote_name = split_repo_name(repo_name)\n    if index_name[0] == '-' or index_name[-1] == '-':\n        raise errors.InvalidRepository(\n            'Invalid index name ({0}). Cannot begin or end with a'\n            ' hyphen.'.format(index_name)\n        )\n    return resolve_index_name(index_name), remote_name\n\n\ndef resolve_index_name(index_name):\n    index_name = convert_to_hostname(index_name)\n    if index_name == 'index.' + INDEX_NAME:\n        index_name = INDEX_NAME\n    return index_name\n\n\ndef split_repo_name(repo_name):\n    parts = repo_name.split('/', 1)\n    if len(parts) == 1 or (\n        '.' not in parts[0] and ':' not in parts[0] and parts[0] != 'localhost'\n    ):\n        # This is a docker index repo (ex: username/foobar or ubuntu)\n        return INDEX_NAME, repo_name\n    return tuple(parts)\n\n\ndef resolve_authconfig(authconfig, registry=None):\n    \"\"\"\n    Returns the authentication data from the given auth configuration for a\n    specific registry. As with the Docker client, legacy entries in the config\n    with full URLs are stripped down to hostnames before checking for a match.\n    Returns None if no match was found.\n    \"\"\"\n    # Default to the public index server\n    registry = resolve_index_name(registry) if registry else INDEX_NAME\n    log.debug(\"Looking for auth entry for {0}\".format(repr(registry)))\n\n    if registry in authconfig:\n        log.debug(\"Found {0}\".format(repr(registry)))\n        return authconfig[registry]\n\n    for key, config in six.iteritems(authconfig):\n        if resolve_index_name(key) == registry:\n            log.debug(\"Found {0}\".format(repr(key)))\n            return config\n\n    log.debug(\"No entry found\")\n    return None\n\n\ndef convert_to_hostname(url):\n    return url.replace('http://', '').replace('https://', '').split('/', 1)[0]\n\n\ndef decode_auth(auth):\n    if isinstance(auth, six.string_types):\n        auth = auth.encode('ascii')\n    s = base64.b64decode(auth)\n    login, pwd = s.split(b':', 1)\n    return login.decode('utf8'), pwd.decode('utf8')\n\n\ndef encode_header(auth):\n    auth_json = json.dumps(auth).encode('ascii')\n    return base64.urlsafe_b64encode(auth_json)\n\n\ndef parse_auth(entries, raise_on_error=False):\n    \"\"\"\n    Parses authentication entries\n\n    Args:\n      entries:        Dict of authentication entries.\n      raise_on_error: If set to true, an invalid format will raise\n                      InvalidConfigFile\n\n    Returns:\n      Authentication registry.\n    \"\"\"\n\n    conf = {}\n    for registry, entry in six.iteritems(entries):\n        if not (isinstance(entry, dict) and 'auth' in entry):\n            log.debug(\n                'Config entry for key {0} is not auth config'.format(registry)\n            )\n            # We sometimes fall back to parsing the whole config as if it was\n            # the auth config by itself, for legacy purposes. In that case, we\n            # fail silently and return an empty conf if any of the keys is not\n            # formatted properly.\n            if raise_on_error:\n                raise errors.InvalidConfigFile(\n                    'Invalid configuration for registry {0}'.format(registry)\n                )\n            return {}\n        username, password = decode_auth(entry['auth'])\n        log.debug(\n            'Found entry (registry={0}, username={1})'\n            .format(repr(registry), repr(username))\n        )\n        conf[registry] = {\n            'username': username,\n            'password': password,\n            'email': entry.get('email'),\n            'serveraddress': registry,\n        }\n    return conf\n\n\ndef find_config_file(config_path=None):\n    environment_path = os.path.join(\n        os.environ.get('DOCKER_CONFIG'),\n        os.path.basename(DOCKER_CONFIG_FILENAME)\n    ) if os.environ.get('DOCKER_CONFIG') else None\n\n    paths = [\n        config_path,  # 1\n        environment_path,  # 2\n        os.path.join(os.path.expanduser('~'), DOCKER_CONFIG_FILENAME),  # 3\n        os.path.join(\n            os.path.expanduser('~'), LEGACY_DOCKER_CONFIG_FILENAME\n        )  # 4\n    ]\n\n    for path in paths:\n        if path and os.path.exists(path):\n            return path\n    return None\n\n\ndef load_config(config_path=None):\n    \"\"\"\n    Loads authentication data from a Docker configuration file in the given\n    root directory or if config_path is passed use given path.\n    Lookup priority:\n        explicit config_path parameter > DOCKER_CONFIG environment variable >\n        ~/.docker/config.json > ~/.dockercfg\n    \"\"\"\n    config_file = find_config_file(config_path)\n\n    if not config_file:\n        log.debug(\"File doesn't exist\")\n        return {}\n\n    try:\n        with open(config_file) as f:\n            data = json.load(f)\n            res = {}\n            if data.get('auths'):\n                log.debug(\"Found 'auths' section\")\n                res.update(parse_auth(data['auths'], raise_on_error=True))\n            if data.get('HttpHeaders'):\n                log.debug(\"Found 'HttpHeaders' section\")\n                res.update({'HttpHeaders': data['HttpHeaders']})\n            if res:\n                return res\n            else:\n                log.debug(\"Couldn't find 'auths' or 'HttpHeaders' sections\")\n                f.seek(0)\n                return parse_auth(json.load(f))\n    except (IOError, KeyError, ValueError) as e:\n        # Likely missing new Docker config file or it's in an\n        # unknown format, continue to attempt to read old location\n        # and format.\n        log.debug(e)\n\n    log.debug(\"Attempting to parse legacy auth file format\")\n    try:\n        data = []\n        with open(config_file) as f:\n            for line in f.readlines():\n                data.append(line.strip().split(' = ')[1])\n            if len(data) < 2:\n                # Not enough data\n                raise errors.InvalidConfigFile(\n                    'Invalid or empty configuration file!'\n                )\n\n        username, password = decode_auth(data[0])\n        return {\n            INDEX_NAME: {\n                'username': username,\n                'password': password,\n                'email': data[1],\n                'serveraddress': INDEX_URL,\n            }\n        }\n    except Exception as e:\n        log.debug(e)\n        pass\n\n    log.debug(\"All parsing attempts failed - returning empty config\")\n    return {}\n", "path": "docker/auth/auth.py"}], "after_files": [{"content": "# Copyright 2013 dotCloud inc.\n\n#    Licensed under the Apache License, Version 2.0 (the \"License\");\n#    you may not use this file except in compliance with the License.\n#    You may obtain a copy of the License at\n\n#        http://www.apache.org/licenses/LICENSE-2.0\n\n#    Unless required by applicable law or agreed to in writing, software\n#    distributed under the License is distributed on an \"AS IS\" BASIS,\n#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n#    See the License for the specific language governing permissions and\n#    limitations under the License.\n\nimport base64\nimport json\nimport logging\nimport os\n\nimport six\n\nfrom .. import errors\n\nINDEX_NAME = 'docker.io'\nINDEX_URL = 'https://{0}/v1/'.format(INDEX_NAME)\nDOCKER_CONFIG_FILENAME = os.path.join('.docker', 'config.json')\nLEGACY_DOCKER_CONFIG_FILENAME = '.dockercfg'\n\nlog = logging.getLogger(__name__)\n\n\ndef resolve_repository_name(repo_name):\n    if '://' in repo_name:\n        raise errors.InvalidRepository(\n            'Repository name cannot contain a scheme ({0})'.format(repo_name)\n        )\n\n    index_name, remote_name = split_repo_name(repo_name)\n    if index_name[0] == '-' or index_name[-1] == '-':\n        raise errors.InvalidRepository(\n            'Invalid index name ({0}). Cannot begin or end with a'\n            ' hyphen.'.format(index_name)\n        )\n    return resolve_index_name(index_name), remote_name\n\n\ndef resolve_index_name(index_name):\n    index_name = convert_to_hostname(index_name)\n    if index_name == 'index.' + INDEX_NAME:\n        index_name = INDEX_NAME\n    return index_name\n\n\ndef split_repo_name(repo_name):\n    parts = repo_name.split('/', 1)\n    if len(parts) == 1 or (\n        '.' not in parts[0] and ':' not in parts[0] and parts[0] != 'localhost'\n    ):\n        # This is a docker index repo (ex: username/foobar or ubuntu)\n        return INDEX_NAME, repo_name\n    return tuple(parts)\n\n\ndef resolve_authconfig(authconfig, registry=None):\n    \"\"\"\n    Returns the authentication data from the given auth configuration for a\n    specific registry. As with the Docker client, legacy entries in the config\n    with full URLs are stripped down to hostnames before checking for a match.\n    Returns None if no match was found.\n    \"\"\"\n    # Default to the public index server\n    registry = resolve_index_name(registry) if registry else INDEX_NAME\n    log.debug(\"Looking for auth entry for {0}\".format(repr(registry)))\n\n    if registry in authconfig:\n        log.debug(\"Found {0}\".format(repr(registry)))\n        return authconfig[registry]\n\n    for key, config in six.iteritems(authconfig):\n        if resolve_index_name(key) == registry:\n            log.debug(\"Found {0}\".format(repr(key)))\n            return config\n\n    log.debug(\"No entry found\")\n    return None\n\n\ndef convert_to_hostname(url):\n    return url.replace('http://', '').replace('https://', '').split('/', 1)[0]\n\n\ndef decode_auth(auth):\n    if isinstance(auth, six.string_types):\n        auth = auth.encode('ascii')\n    s = base64.b64decode(auth)\n    login, pwd = s.split(b':', 1)\n    return login.decode('utf8'), pwd.decode('utf8')\n\n\ndef encode_header(auth):\n    auth_json = json.dumps(auth).encode('ascii')\n    return base64.urlsafe_b64encode(auth_json)\n\n\ndef parse_auth(entries, raise_on_error=False):\n    \"\"\"\n    Parses authentication entries\n\n    Args:\n      entries:        Dict of authentication entries.\n      raise_on_error: If set to true, an invalid format will raise\n                      InvalidConfigFile\n\n    Returns:\n      Authentication registry.\n    \"\"\"\n\n    conf = {}\n    for registry, entry in six.iteritems(entries):\n        if not isinstance(entry, dict):\n            log.debug(\n                'Config entry for key {0} is not auth config'.format(registry)\n            )\n            # We sometimes fall back to parsing the whole config as if it was\n            # the auth config by itself, for legacy purposes. In that case, we\n            # fail silently and return an empty conf if any of the keys is not\n            # formatted properly.\n            if raise_on_error:\n                raise errors.InvalidConfigFile(\n                    'Invalid configuration for registry {0}'.format(registry)\n                )\n            return {}\n        if 'auth' not in entry:\n            # Starting with engine v1.11 (API 1.23), an empty dictionary is\n            # a valid value in the auths config.\n            # https://github.com/docker/compose/issues/3265\n            log.debug(\n                'Auth data for {0} is absent. Client might be using a '\n                'credentials store instead.'\n            )\n            return {}\n\n        username, password = decode_auth(entry['auth'])\n        log.debug(\n            'Found entry (registry={0}, username={1})'\n            .format(repr(registry), repr(username))\n        )\n        conf[registry] = {\n            'username': username,\n            'password': password,\n            'email': entry.get('email'),\n            'serveraddress': registry,\n        }\n    return conf\n\n\ndef find_config_file(config_path=None):\n    environment_path = os.path.join(\n        os.environ.get('DOCKER_CONFIG'),\n        os.path.basename(DOCKER_CONFIG_FILENAME)\n    ) if os.environ.get('DOCKER_CONFIG') else None\n\n    paths = [\n        config_path,  # 1\n        environment_path,  # 2\n        os.path.join(os.path.expanduser('~'), DOCKER_CONFIG_FILENAME),  # 3\n        os.path.join(\n            os.path.expanduser('~'), LEGACY_DOCKER_CONFIG_FILENAME\n        )  # 4\n    ]\n\n    for path in paths:\n        if path and os.path.exists(path):\n            return path\n    return None\n\n\ndef load_config(config_path=None):\n    \"\"\"\n    Loads authentication data from a Docker configuration file in the given\n    root directory or if config_path is passed use given path.\n    Lookup priority:\n        explicit config_path parameter > DOCKER_CONFIG environment variable >\n        ~/.docker/config.json > ~/.dockercfg\n    \"\"\"\n    config_file = find_config_file(config_path)\n\n    if not config_file:\n        log.debug(\"File doesn't exist\")\n        return {}\n\n    try:\n        with open(config_file) as f:\n            data = json.load(f)\n            res = {}\n            if data.get('auths'):\n                log.debug(\"Found 'auths' section\")\n                res.update(parse_auth(data['auths'], raise_on_error=True))\n            if data.get('HttpHeaders'):\n                log.debug(\"Found 'HttpHeaders' section\")\n                res.update({'HttpHeaders': data['HttpHeaders']})\n            if data.get('credsStore'):\n                log.debug(\"Found 'credsStore' section\")\n                res.update({'credsStore': data['credsStore']})\n            if res:\n                return res\n            else:\n                log.debug(\"Couldn't find 'auths' or 'HttpHeaders' sections\")\n                f.seek(0)\n                return parse_auth(json.load(f))\n    except (IOError, KeyError, ValueError) as e:\n        # Likely missing new Docker config file or it's in an\n        # unknown format, continue to attempt to read old location\n        # and format.\n        log.debug(e)\n\n    log.debug(\"Attempting to parse legacy auth file format\")\n    try:\n        data = []\n        with open(config_file) as f:\n            for line in f.readlines():\n                data.append(line.strip().split(' = ')[1])\n            if len(data) < 2:\n                # Not enough data\n                raise errors.InvalidConfigFile(\n                    'Invalid or empty configuration file!'\n                )\n\n        username, password = decode_auth(data[0])\n        return {\n            INDEX_NAME: {\n                'username': username,\n                'password': password,\n                'email': data[1],\n                'serveraddress': INDEX_URL,\n            }\n        }\n    except Exception as e:\n        log.debug(e)\n        pass\n\n    log.debug(\"All parsing attempts failed - returning empty config\")\n    return {}\n", "path": "docker/auth/auth.py"}]}