From 70cce961a8223403d36e8d209925e112f1ebd02f Mon Sep 17 00:00:00 2001 From: Aanand Prasad Date: Tue, 12 Jan 2016 17:26:18 +0000 Subject: [PATCH] Don't allow links or external_links in v2 files Signed-off-by: Aanand Prasad --- compose/config/service_schema_v2.json | 2 -- tests/acceptance/cli_test.py | 13 ++++++++++++- tests/fixtures/v2-simple/links-invalid.yml | 10 ++++++++++ tests/unit/config/config_test.py | 4 +--- 4 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 tests/fixtures/v2-simple/links-invalid.yml diff --git a/compose/config/service_schema_v2.json b/compose/config/service_schema_v2.json index d1d0854f3..47b195fcc 100644 --- a/compose/config/service_schema_v2.json +++ b/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", diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index 25808c94b..eab4bdae9 100644 --- a/tests/acceptance/cli_test.py +++ b/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') diff --git a/tests/fixtures/v2-simple/links-invalid.yml b/tests/fixtures/v2-simple/links-invalid.yml new file mode 100644 index 000000000..422f9314e --- /dev/null +++ b/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 diff --git a/tests/unit/config/config_test.py b/tests/unit/config/config_test.py index a59d1d34a..25483e526 100644 --- a/tests/unit/config/config_test.py +++ b/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')], }, {