mirror of https://github.com/docker/compose.git
Merge pull request #492 from dnephin/project_name_from_env
Support setting project name from the environment
This commit is contained in:
commit
253b245a1c
|
@ -81,6 +81,7 @@ class Command(DocoptCommand):
|
||||||
def normalize_name(name):
|
def normalize_name(name):
|
||||||
return re.sub(r'[^a-zA-Z0-9]', '', name)
|
return re.sub(r'[^a-zA-Z0-9]', '', name)
|
||||||
|
|
||||||
|
project_name = project_name or os.environ.get('FIG_PROJECT_NAME')
|
||||||
if project_name is not None:
|
if project_name is not None:
|
||||||
return normalize_name(project_name)
|
return normalize_name(project_name)
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,14 @@ class CLITestCase(unittest.TestCase):
|
||||||
project_name = command.get_project_name(None, project_name=name)
|
project_name = command.get_project_name(None, project_name=name)
|
||||||
self.assertEquals('explicitprojectname', project_name)
|
self.assertEquals('explicitprojectname', project_name)
|
||||||
|
|
||||||
|
def test_project_name_from_environment(self):
|
||||||
|
command = TopLevelCommand()
|
||||||
|
name = 'namefromenv'
|
||||||
|
with mock.patch.dict(os.environ):
|
||||||
|
os.environ['FIG_PROJECT_NAME'] = name
|
||||||
|
project_name = command.get_project_name(None)
|
||||||
|
self.assertEquals(project_name, name)
|
||||||
|
|
||||||
def test_yaml_filename_check(self):
|
def test_yaml_filename_check(self):
|
||||||
command = TopLevelCommand()
|
command = TopLevelCommand()
|
||||||
command.base_dir = 'tests/fixtures/longer-filename-figfile'
|
command.base_dir = 'tests/fixtures/longer-filename-figfile'
|
||||||
|
|
Loading…
Reference in New Issue