瀏覽代碼

Disable the use of 'net' in v2

Signed-off-by: Aanand Prasad <[email protected]>
Aanand Prasad 9 年之前
父節點
當前提交
35e347cf92

+ 0 - 1
compose/config/service_schema_v2.json

@@ -89,7 +89,6 @@
         "mac_address": {"type": "string"},
         "mem_limit": {"type": ["number", "string"]},
         "memswap_limit": {"type": ["number", "string"]},
-        "net": {"type": "string"},
         "pid": {"type": ["string", "null"]},
 
         "ports": {

+ 24 - 0
tests/acceptance/cli_test.py

@@ -422,6 +422,30 @@ class CLITestCase(DockerClientTestCase):
         self.assertEqual(len(db.containers()), 1)
         self.assertEqual(len(console.containers()), 0)
 
+    def test_up_with_net_is_invalid(self):
+        self.base_dir = 'tests/fixtures/net-container'
+
+        result = self.dispatch(
+            ['-f', 'v2-invalid.yml', 'up', '-d'],
+            returncode=1)
+
+        # TODO: fix validation error messages for v2 files
+        # assert "Unsupported config option for service 'web': 'net'" in exc.exconly()
+        assert "Unsupported config option" in result.stderr
+
+    def test_up_with_net_v1(self):
+        self.base_dir = 'tests/fixtures/net-container'
+        self.dispatch(['up', '-d'], None)
+
+        bar = self.project.get_service('bar')
+        bar_container = bar.containers()[0]
+
+        foo = self.project.get_service('foo')
+        foo_container = foo.containers()[0]
+
+        assert foo_container.get('HostConfig.NetworkMode') == \
+            'container:{}'.format(bar_container.id)
+
     def test_up_with_no_deps(self):
         self.base_dir = 'tests/fixtures/links-composefile'
         self.dispatch(['up', '-d', '--no-deps', 'web'], None)

+ 7 - 0
tests/fixtures/net-container/docker-compose.yml

@@ -0,0 +1,7 @@
+foo:
+  image: busybox
+  command: top
+  net: "container:bar"
+bar:
+  image: busybox
+  command: top

+ 10 - 0
tests/fixtures/net-container/v2-invalid.yml

@@ -0,0 +1,10 @@
+version: 2
+
+services:
+  foo:
+    image: busybox
+    command: top
+  bar:
+    image: busybox
+    command: top
+    net: "container:foo"