Browse Source

Fix dns and dns_search when used strings and without extends.

Signed-off-by: Daniel Nephin <[email protected]>
Daniel Nephin 10 years ago
parent
commit
fa3528ea25
2 changed files with 23 additions and 2 deletions
  1. 4 0
      compose/config/config.py
  2. 19 2
      tests/unit/config/config_test.py

+ 4 - 0
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'])

+ 19 - 2
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):