Don't allow links or external_links in v2 files

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
Aanand Prasad 2016-01-12 17:26:18 +00:00
parent 9e17cff0ef
commit 70cce961a8
4 changed files with 23 additions and 6 deletions

View File

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

View File

@ -372,7 +372,18 @@ class CLITestCase(DockerClientTestCase):
web_container = self.project.get_service('simple').containers()[0] web_container = self.project.get_service('simple').containers()[0]
self.assertFalse(web_container.get('HostConfig.Links')) 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.base_dir = 'tests/fixtures/links-composefile'
self.dispatch(['up', '-d', 'web'], None) self.dispatch(['up', '-d', 'web'], None)
web = self.project.get_service('web') web = self.project.get_service('web')

View File

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

View File

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