Fix config merging for isolation and storage_opt keys

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2018-11-02 11:35:34 -07:00
parent 8a0090c18c
commit 4682e766a3
3 changed files with 42 additions and 0 deletions

View File

@ -91,6 +91,7 @@ DOCKER_CONFIG_KEYS = [
'healthcheck', 'healthcheck',
'image', 'image',
'ipc', 'ipc',
'isolation',
'labels', 'labels',
'links', 'links',
'mac_address', 'mac_address',
@ -1042,6 +1043,7 @@ def merge_service_dicts(base, override, version):
md.merge_mapping('networks', parse_networks) md.merge_mapping('networks', parse_networks)
md.merge_mapping('sysctls', parse_sysctls) md.merge_mapping('sysctls', parse_sysctls)
md.merge_mapping('depends_on', parse_depends_on) md.merge_mapping('depends_on', parse_depends_on)
md.merge_mapping('storage_opt', parse_flat_dict)
md.merge_sequence('links', ServiceLink.parse) md.merge_sequence('links', ServiceLink.parse)
md.merge_sequence('secrets', types.ServiceSecret.parse) md.merge_sequence('secrets', types.ServiceSecret.parse)
md.merge_sequence('configs', types.ServiceConfig.parse) md.merge_sequence('configs', types.ServiceConfig.parse)

View File

@ -85,6 +85,7 @@ HOST_CONFIG_KEYS = [
'group_add', 'group_add',
'init', 'init',
'ipc', 'ipc',
'isolation',
'read_only', 'read_only',
'log_driver', 'log_driver',
'log_opt', 'log_opt',

View File

@ -2644,6 +2644,45 @@ class ConfigTest(unittest.TestCase):
['c 7:128 rwm', 'x 3:244 rw', 'f 0:128 n'] ['c 7:128 rwm', 'x 3:244 rw', 'f 0:128 n']
) )
def test_merge_isolation(self):
base = {
'image': 'bar',
'isolation': 'default',
}
override = {
'isolation': 'hyperv',
}
actual = config.merge_service_dicts(base, override, V2_3)
assert actual == {
'image': 'bar',
'isolation': 'hyperv',
}
def test_merge_storage_opt(self):
base = {
'image': 'bar',
'storage_opt': {
'size': '1G',
'readonly': 'false',
}
}
override = {
'storage_opt': {
'size': '2G',
'encryption': 'aes',
}
}
actual = config.merge_service_dicts(base, override, V2_3)
assert actual['storage_opt'] == {
'size': '2G',
'readonly': 'false',
'encryption': 'aes',
}
def test_external_volume_config(self): def test_external_volume_config(self):
config_details = build_config_details({ config_details = build_config_details({
'version': '2', 'version': '2',