Fix env_file and environment when used with extends.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2015-11-18 14:51:01 -05:00
commit 1e8f76767f
3 changed files with 60 additions and 13 deletions

View file

@ -46,7 +46,8 @@ class DockerClientTestCase(unittest.TestCase):
service_config = ServiceConfig('.', None, name, kwargs)
options = process_service(service_config)
options['environment'] = resolve_environment('.', kwargs)
options['environment'] = resolve_environment(
service_config._replace(config=options))
labels = options.setdefault('labels', {})
labels['com.docker.compose.test-name'] = self.id()

View file

@ -1317,6 +1317,54 @@ class ExtendsTest(unittest.TestCase):
},
]))
def test_extends_with_environment_and_env_files(self):
tmpdir = py.test.ensuretemp('test_extends_with_environment')
self.addCleanup(tmpdir.remove)
commondir = tmpdir.mkdir('common')
commondir.join('base.yml').write("""
app:
image: 'example/app'
env_file:
- 'envs'
environment:
- SECRET
""")
tmpdir.join('docker-compose.yml').write("""
ext:
extends:
file: common/base.yml
service: app
env_file:
- 'envs'
environment:
- THING
""")
commondir.join('envs').write("""
COMMON_ENV_FILE=1
""")
tmpdir.join('envs').write("""
FROM_ENV_FILE=1
""")
expected = [
{
'name': 'ext',
'image': 'example/app',
'environment': {
'SECRET': 'secret',
'FROM_ENV_FILE': '1',
'COMMON_ENV_FILE': '1',
'THING': 'thing',
},
},
]
with mock.patch.dict(os.environ):
os.environ['SECRET'] = 'secret'
os.environ['THING'] = 'thing'
config = load_from_filename(str(tmpdir.join('docker-compose.yml')))
assert config == expected
@pytest.mark.xfail(IS_WINDOWS_PLATFORM, reason='paths use slash')
class ExpandPathTest(unittest.TestCase):