diff options
author | Joffrey F <joffrey@docker.com> | 2018-06-26 17:40:49 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2018-06-26 17:40:49 -0700 |
commit | 345be2f38a087e3730103c8d313d31311501ed5d (patch) | |
tree | 20f4dda3c24f5bb1b244b796d8b3cefd13e39efe | |
parent | 5a85cad54785bae45787b2584476c286301329e2 (diff) | |
download | docker-py-c6047-legacy-auth.tar.gz |
Fix support for legacy .dockercfg auth config formatc6047-legacy-auth
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r-- | docker/api/container.py | 5 | ||||
-rw-r--r-- | docker/auth.py | 2 | ||||
-rw-r--r-- | tests/unit/auth_test.py | 6 |
3 files changed, 7 insertions, 6 deletions
diff --git a/docker/api/container.py b/docker/api/container.py index 05676f1..d4f75f5 100644 --- a/docker/api/container.py +++ b/docker/api/container.py @@ -139,8 +139,9 @@ class ContainerApiMixin(object): 'changes': changes } u = self._url("/commit") - return self._result(self._post_json(u, data=conf, params=params), - json=True) + return self._result( + self._post_json(u, data=conf, params=params), json=True + ) def containers(self, quiet=False, all=False, trunc=False, latest=False, since=None, before=None, limit=-1, size=False, diff --git a/docker/auth.py b/docker/auth.py index 0c0cb20..89c0ba5 100644 --- a/docker/auth.py +++ b/docker/auth.py @@ -270,7 +270,7 @@ def load_config(config_path=None, config_dict=None): "Couldn't find auth-related section ; attempting to interpret" "as auth-only file" ) - return parse_auth(config_dict) + return {'auths': parse_auth(config_dict)} def _load_legacy_config(config_file): diff --git a/tests/unit/auth_test.py b/tests/unit/auth_test.py index ee32ca0..63e6353 100644 --- a/tests/unit/auth_test.py +++ b/tests/unit/auth_test.py @@ -318,7 +318,7 @@ class LoadConfigTest(unittest.TestCase): with open(dockercfg_path, 'w') as f: json.dump(config, f) - cfg = auth.load_config(dockercfg_path) + cfg = auth.load_config(dockercfg_path)['auths'] assert registry in cfg assert cfg[registry] is not None cfg = cfg[registry] @@ -345,7 +345,7 @@ class LoadConfigTest(unittest.TestCase): json.dump(config, f) with mock.patch.dict(os.environ, {'DOCKER_CONFIG': folder}): - cfg = auth.load_config(None) + cfg = auth.load_config(None)['auths'] assert registry in cfg assert cfg[registry] is not None cfg = cfg[registry] @@ -422,7 +422,7 @@ class LoadConfigTest(unittest.TestCase): json.dump(config, f) cfg = auth.load_config(dockercfg_path) - assert cfg == {} + assert cfg == {'auths': {}} def test_load_config_invalid_auth_dict(self): folder = tempfile.mkdtemp() |