mirror of https://github.com/docker/compose.git
Merge pull request #2612 from dnephin/merge_extends_from_multiple_files
Fix extends with multiple files
This commit is contained in:
commit
ab98c70dd1
|
@ -516,6 +516,8 @@ def merge_service_dicts_from_files(base, override):
|
|||
new_service = merge_service_dicts(base, override)
|
||||
if 'extends' in override:
|
||||
new_service['extends'] = override['extends']
|
||||
elif 'extends' in base:
|
||||
new_service['extends'] = base['extends']
|
||||
return new_service
|
||||
|
||||
|
||||
|
|
|
@ -738,6 +738,37 @@ class ConfigTest(unittest.TestCase):
|
|||
}
|
||||
]
|
||||
|
||||
def test_merge_service_dicts_from_files_with_extends_in_base(self):
|
||||
base = {
|
||||
'volumes': ['.:/app'],
|
||||
'extends': {'service': 'app'}
|
||||
}
|
||||
override = {
|
||||
'image': 'alpine:edge',
|
||||
}
|
||||
actual = config.merge_service_dicts_from_files(base, override)
|
||||
assert actual == {
|
||||
'image': 'alpine:edge',
|
||||
'volumes': ['.:/app'],
|
||||
'extends': {'service': 'app'}
|
||||
}
|
||||
|
||||
def test_merge_service_dicts_from_files_with_extends_in_override(self):
|
||||
base = {
|
||||
'volumes': ['.:/app'],
|
||||
'extends': {'service': 'app'}
|
||||
}
|
||||
override = {
|
||||
'image': 'alpine:edge',
|
||||
'extends': {'service': 'foo'}
|
||||
}
|
||||
actual = config.merge_service_dicts_from_files(base, override)
|
||||
assert actual == {
|
||||
'image': 'alpine:edge',
|
||||
'volumes': ['.:/app'],
|
||||
'extends': {'service': 'foo'}
|
||||
}
|
||||
|
||||
|
||||
class PortsTest(unittest.TestCase):
|
||||
INVALID_PORTS_TYPES = [
|
||||
|
|
Loading…
Reference in New Issue