Allow _.- chars in service names

As VALID_CHARS is shared with project names, these chars are also
now allowed within project names.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-07-01 17:56:39 +01:00
parent 8cf84ea552
commit f33f673b49
2 changed files with 12 additions and 7 deletions

View File

@ -47,7 +47,7 @@ DOCKER_START_KEYS = [
'security_opt',
]
VALID_NAME_CHARS = '[a-zA-Z0-9]'
VALID_NAME_CHARS = '[a-zA-Z0-9\._\-]'
class BuildError(Exception):

View File

@ -34,18 +34,23 @@ class ServiceTest(unittest.TestCase):
self.assertRaises(ConfigError, lambda: Service(name='/', image='foo'))
self.assertRaises(ConfigError, lambda: Service(name='!', image='foo'))
self.assertRaises(ConfigError, lambda: Service(name='\xe2', image='foo'))
self.assertRaises(ConfigError, lambda: Service(name='_', image='foo'))
self.assertRaises(ConfigError, lambda: Service(name='____', image='foo'))
self.assertRaises(ConfigError, lambda: Service(name='foo_bar', image='foo'))
self.assertRaises(ConfigError, lambda: Service(name='__foo_bar__', image='foo'))
Service('a', 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):
self.assertRaises(ConfigError, lambda: Service('bar'))
self.assertRaises(ConfigError, lambda: Service(name='foo', project='_', image='foo'))
Service(name='foo', project='bar', image='foo')
self.assertRaises(ConfigError, lambda: Service(name='foo', project='>', image='foo'))
Service(name='foo', project='bar.bar__', image='foo')
def test_containers(self):
service = Service('db', self.mock_client, 'myproject', image='foo')