mirror of https://github.com/docker/docs.git
Merge pull request #1624 from mnowster/1519_relax_service_name_restrictions
1519 relax service name restrictions
This commit is contained in:
commit
40b8c3c892
|
@ -47,7 +47,7 @@ DOCKER_START_KEYS = [
|
||||||
'security_opt',
|
'security_opt',
|
||||||
]
|
]
|
||||||
|
|
||||||
VALID_NAME_CHARS = '[a-zA-Z0-9]'
|
VALID_NAME_CHARS = '[a-zA-Z0-9\._\-]'
|
||||||
|
|
||||||
|
|
||||||
class BuildError(Exception):
|
class BuildError(Exception):
|
||||||
|
|
|
@ -28,24 +28,29 @@ class ServiceTest(unittest.TestCase):
|
||||||
self.mock_client = mock.create_autospec(docker.Client)
|
self.mock_client = mock.create_autospec(docker.Client)
|
||||||
|
|
||||||
def test_name_validations(self):
|
def test_name_validations(self):
|
||||||
self.assertRaises(ConfigError, lambda: Service(name=''))
|
self.assertRaises(ConfigError, lambda: Service(name='', image='foo'))
|
||||||
|
|
||||||
self.assertRaises(ConfigError, lambda: Service(name=' '))
|
self.assertRaises(ConfigError, lambda: Service(name=' ', image='foo'))
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='/'))
|
self.assertRaises(ConfigError, lambda: Service(name='/', image='foo'))
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='!'))
|
self.assertRaises(ConfigError, lambda: Service(name='!', image='foo'))
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='\xe2'))
|
self.assertRaises(ConfigError, lambda: Service(name='\xe2', image='foo'))
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='_'))
|
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='____'))
|
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='foo_bar'))
|
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='__foo_bar__'))
|
|
||||||
|
|
||||||
Service('a', image='foo')
|
Service('a', image='foo')
|
||||||
Service('foo', image='foo')
|
Service('foo', image='foo')
|
||||||
|
Service('foo-bar', image='foo')
|
||||||
|
Service('foo.bar', image='foo')
|
||||||
|
Service('foo_bar', image='foo')
|
||||||
|
Service('_', image='foo')
|
||||||
|
Service('___', image='foo')
|
||||||
|
Service('-', image='foo')
|
||||||
|
Service('--', image='foo')
|
||||||
|
Service('.__.', image='foo')
|
||||||
|
|
||||||
def test_project_validation(self):
|
def test_project_validation(self):
|
||||||
self.assertRaises(ConfigError, lambda: Service('bar'))
|
self.assertRaises(ConfigError, lambda: Service('bar'))
|
||||||
self.assertRaises(ConfigError, lambda: Service(name='foo', project='_', image='foo'))
|
self.assertRaises(ConfigError, lambda: Service(name='foo', project='>', image='foo'))
|
||||||
Service(name='foo', project='bar', image='foo')
|
|
||||||
|
Service(name='foo', project='bar.bar__', image='foo')
|
||||||
|
|
||||||
def test_containers(self):
|
def test_containers(self):
|
||||||
service = Service('db', self.mock_client, 'myproject', image='foo')
|
service = Service('db', self.mock_client, 'myproject', image='foo')
|
||||||
|
|
Loading…
Reference in New Issue