mirror of https://github.com/docker/compose.git
Merge pull request #4350 from shin-/fix-invalid-depends-on-merge
depends_on merge now retains condition information when present
This commit is contained in:
commit
8a27a0f059
|
@ -818,6 +818,7 @@ def merge_service_dicts(base, override, version):
|
|||
md.merge_mapping('ulimits', parse_ulimits)
|
||||
md.merge_mapping('networks', parse_networks)
|
||||
md.merge_mapping('sysctls', parse_sysctls)
|
||||
md.merge_mapping('depends_on', parse_depends_on)
|
||||
md.merge_sequence('links', ServiceLink.parse)
|
||||
|
||||
for field in ['volumes', 'devices']:
|
||||
|
@ -825,7 +826,7 @@ def merge_service_dicts(base, override, version):
|
|||
|
||||
for field in [
|
||||
'ports', 'cap_add', 'cap_drop', 'expose', 'external_links',
|
||||
'security_opt', 'volumes_from', 'depends_on',
|
||||
'security_opt', 'volumes_from',
|
||||
]:
|
||||
md.merge_field(field, merge_unique_items_lists, default=[])
|
||||
|
||||
|
@ -920,6 +921,9 @@ parse_environment = functools.partial(parse_dict_or_list, split_env, 'environmen
|
|||
parse_labels = functools.partial(parse_dict_or_list, split_kv, 'labels')
|
||||
parse_networks = functools.partial(parse_dict_or_list, lambda k: (k, None), 'networks')
|
||||
parse_sysctls = functools.partial(parse_dict_or_list, split_kv, 'sysctls')
|
||||
parse_depends_on = functools.partial(
|
||||
parse_dict_or_list, lambda k: (k, {'condition': 'service_started'}), 'depends_on'
|
||||
)
|
||||
|
||||
|
||||
def parse_ulimits(ulimits):
|
||||
|
|
|
@ -1713,6 +1713,40 @@ class ConfigTest(unittest.TestCase):
|
|||
}
|
||||
}
|
||||
|
||||
def test_merge_depends_on_no_override(self):
|
||||
base = {
|
||||
'image': 'busybox',
|
||||
'depends_on': {
|
||||
'app1': {'condition': 'service_started'},
|
||||
'app2': {'condition': 'service_healthy'}
|
||||
}
|
||||
}
|
||||
override = {}
|
||||
actual = config.merge_service_dicts(base, override, V2_1)
|
||||
assert actual == base
|
||||
|
||||
def test_merge_depends_on_mixed_syntax(self):
|
||||
base = {
|
||||
'image': 'busybox',
|
||||
'depends_on': {
|
||||
'app1': {'condition': 'service_started'},
|
||||
'app2': {'condition': 'service_healthy'}
|
||||
}
|
||||
}
|
||||
override = {
|
||||
'depends_on': ['app3']
|
||||
}
|
||||
|
||||
actual = config.merge_service_dicts(base, override, V2_1)
|
||||
assert actual == {
|
||||
'image': 'busybox',
|
||||
'depends_on': {
|
||||
'app1': {'condition': 'service_started'},
|
||||
'app2': {'condition': 'service_healthy'},
|
||||
'app3': {'condition': 'service_started'}
|
||||
}
|
||||
}
|
||||
|
||||
def test_external_volume_config(self):
|
||||
config_details = build_config_details({
|
||||
'version': '2',
|
||||
|
|
Loading…
Reference in New Issue