From fa3528ea2558cc4b1efca9ba5ea061b57191ae30 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Wed, 9 Dec 2015 16:32:39 -0800 Subject: [PATCH] Fix dns and dns_search when used strings and without extends. Signed-off-by: Daniel Nephin --- compose/config/config.py | 4 ++++ tests/unit/config/config_test.py | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/compose/config/config.py b/compose/config/config.py index 853157ee8..a2ccecc4f 100644 --- a/compose/config/config.py +++ b/compose/config/config.py @@ -387,6 +387,10 @@ def process_service(service_config): if 'extra_hosts' in service_dict: service_dict['extra_hosts'] = parse_extra_hosts(service_dict['extra_hosts']) + for field in ['dns', 'dns_search']: + if field in service_dict: + service_dict[field] = to_list(service_dict[field]) + # TODO: move to a validate_service() if 'ulimits' in service_dict: validate_ulimits(service_dict['ulimits']) diff --git a/tests/unit/config/config_test.py b/tests/unit/config/config_test.py index 20705d555..2185b7920 100644 --- a/tests/unit/config/config_test.py +++ b/tests/unit/config/config_test.py @@ -535,6 +535,23 @@ class ConfigTest(unittest.TestCase): })) assert "which is an invalid type" in exc.exconly() + def test_normalize_dns_options(self): + actual = config.load(build_config_details({ + 'web': { + 'image': 'alpine', + 'dns': '8.8.8.8', + 'dns_search': 'domain.local', + } + })) + assert actual == [ + { + 'name': 'web', + 'image': 'alpine', + 'dns': ['8.8.8.8'], + 'dns_search': ['domain.local'], + } + ] + class PortsTest(unittest.TestCase): INVALID_PORTS_TYPES = [ @@ -1080,8 +1097,8 @@ class EnvTest(unittest.TestCase): {'foo': {'image': 'example', 'env_file': 'nonexistent.env'}}, working_dir='tests/fixtures/env')) - assert 'Couldn\'t find env file' in exc.exconly() - assert 'nonexistent.env' in exc.exconly() + assert 'Couldn\'t find env file' in exc.exconly() + assert 'nonexistent.env' in exc.exconly() @mock.patch.dict(os.environ) def test_resolve_environment_from_env_file_with_empty_values(self):