Prechádzať zdrojové kódy

Don't allow links or external_links in v2 files

Signed-off-by: Aanand Prasad <[email protected]>
Aanand Prasad 9 rokov pred
rodič
commit
70cce961a8

+ 0 - 2
compose/config/service_schema_v2.json

@@ -66,12 +66,10 @@
         },
 
         "extra_hosts": {"$ref": "#/definitions/list_or_dict"},
-        "external_links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
         "hostname": {"type": "string"},
         "image": {"type": "string"},
         "ipc": {"type": "string"},
         "labels": {"$ref": "#/definitions/list_or_dict"},
-        "links": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
 
         "logging": {
             "type": "object",

+ 12 - 1
tests/acceptance/cli_test.py

@@ -372,7 +372,18 @@ class CLITestCase(DockerClientTestCase):
         web_container = self.project.get_service('simple').containers()[0]
         self.assertFalse(web_container.get('HostConfig.Links'))
 
-    def test_up_with_links(self):
+    def test_up_with_links_is_invalid(self):
+        self.base_dir = 'tests/fixtures/v2-simple'
+
+        result = self.dispatch(
+            ['-f', 'links-invalid.yml', 'up', '-d'],
+            returncode=1)
+
+        # TODO: fix validation error messages for v2 files
+        # assert "Unsupported config option for service 'simple': 'links'" in result.stderr
+        assert "Unsupported config option" in result.stderr
+
+    def test_up_with_links_v1(self):
         self.base_dir = 'tests/fixtures/links-composefile'
         self.dispatch(['up', '-d', 'web'], None)
         web = self.project.get_service('web')

+ 10 - 0
tests/fixtures/v2-simple/links-invalid.yml

@@ -0,0 +1,10 @@
+version: 2
+services:
+  simple:
+    image: busybox:latest
+    command: top
+    links:
+      - another
+  another:
+    image: busybox:latest
+    command: top

+ 1 - 3
tests/unit/config/config_test.py

@@ -268,8 +268,8 @@ class ConfigTest(unittest.TestCase):
             {
                 'name': 'web',
                 'build': os.path.abspath('/'),
-                'links': ['db'],
                 'volumes': [VolumeSpec.parse('/home/user/project:/code')],
+                'links': ['db'],
             },
             {
                 'name': 'db',
@@ -405,7 +405,6 @@ class ConfigTest(unittest.TestCase):
                 'services': {
                     'web': {
                         'image': 'example/web',
-                        'links': ['db'],
                     },
                     'db': {
                         'image': 'example/db',
@@ -431,7 +430,6 @@ class ConfigTest(unittest.TestCase):
                 'name': 'web',
                 'build': os.path.abspath('/'),
                 'image': 'example/web',
-                'links': ['db'],
                 'volumes': [VolumeSpec.parse('/home/user/project:/code')],
             },
             {