mirror of https://github.com/docker/compose.git
Merge pull request #6134 from docker/4841-fix-project-dir
Fix --project-directory handling to apply to .env files as well
This commit is contained in:
commit
901ee4e77b
|
@ -238,11 +238,14 @@ class TopLevelCommand(object):
|
|||
version Show the Docker-Compose version information
|
||||
"""
|
||||
|
||||
def __init__(self, project, project_dir='.', options=None):
|
||||
def __init__(self, project, options=None):
|
||||
self.project = project
|
||||
self.project_dir = '.'
|
||||
self.toplevel_options = options or {}
|
||||
|
||||
@property
|
||||
def project_dir(self):
|
||||
return self.toplevel_options.get('--project-directory') or '.'
|
||||
|
||||
def build(self, options):
|
||||
"""
|
||||
Build or rebuild services.
|
||||
|
|
|
@ -303,6 +303,36 @@ class CLITestCase(DockerClientTestCase):
|
|||
}
|
||||
}
|
||||
|
||||
def test_config_with_dot_env(self):
|
||||
self.base_dir = 'tests/fixtures/default-env-file'
|
||||
result = self.dispatch(['config'])
|
||||
json_result = yaml.load(result.stdout)
|
||||
assert json_result == {
|
||||
'services': {
|
||||
'web': {
|
||||
'command': 'true',
|
||||
'image': 'alpine:latest',
|
||||
'ports': ['5643/tcp', '9999/tcp']
|
||||
}
|
||||
},
|
||||
'version': '2.4'
|
||||
}
|
||||
|
||||
def test_config_with_dot_env_and_override_dir(self):
|
||||
self.base_dir = 'tests/fixtures/default-env-file'
|
||||
result = self.dispatch(['--project-directory', 'alt/', 'config'])
|
||||
json_result = yaml.load(result.stdout)
|
||||
assert json_result == {
|
||||
'services': {
|
||||
'web': {
|
||||
'command': 'echo uwu',
|
||||
'image': 'alpine:3.4',
|
||||
'ports': ['3341/tcp', '4449/tcp']
|
||||
}
|
||||
},
|
||||
'version': '2.4'
|
||||
}
|
||||
|
||||
def test_config_external_volume_v2(self):
|
||||
self.base_dir = 'tests/fixtures/volumes'
|
||||
result = self.dispatch(['-f', 'external-volumes-v2.yml', 'config'])
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
IMAGE=alpine:3.4
|
||||
COMMAND=echo uwu
|
||||
PORT1=3341
|
||||
PORT2=4449
|
|
@ -1,4 +1,6 @@
|
|||
web:
|
||||
version: '2.4'
|
||||
services:
|
||||
web:
|
||||
image: ${IMAGE}
|
||||
command: ${COMMAND}
|
||||
ports:
|
||||
|
|
Loading…
Reference in New Issue