mirror of https://github.com/docker/compose.git
Fix config merging for isolation and storage_opt keys
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
afa5d93c90
commit
db819bf0b2
|
@ -91,6 +91,7 @@ DOCKER_CONFIG_KEYS = [
|
|||
'healthcheck',
|
||||
'image',
|
||||
'ipc',
|
||||
'isolation',
|
||||
'labels',
|
||||
'links',
|
||||
'mac_address',
|
||||
|
@ -1042,6 +1043,7 @@ def merge_service_dicts(base, override, version):
|
|||
md.merge_mapping('networks', parse_networks)
|
||||
md.merge_mapping('sysctls', parse_sysctls)
|
||||
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('secrets', types.ServiceSecret.parse)
|
||||
md.merge_sequence('configs', types.ServiceConfig.parse)
|
||||
|
|
|
@ -85,6 +85,7 @@ HOST_CONFIG_KEYS = [
|
|||
'group_add',
|
||||
'init',
|
||||
'ipc',
|
||||
'isolation',
|
||||
'read_only',
|
||||
'log_driver',
|
||||
'log_opt',
|
||||
|
|
|
@ -1343,8 +1343,11 @@ class ConfigTest(unittest.TestCase):
|
|||
mount = config_data.services[0].get('volumes')[0]
|
||||
assert mount.target == '/web'
|
||||
assert mount.type == 'bind'
|
||||
assert (not mount.source.startswith('~')
|
||||
and mount.source.endswith('{}web'.format(os.path.sep)))
|
||||
assert (
|
||||
not mount.source.startswith('~') and mount.source.endswith(
|
||||
'{}web'.format(os.path.sep)
|
||||
)
|
||||
)
|
||||
|
||||
def test_config_invalid_ipam_config(self):
|
||||
with pytest.raises(ConfigurationError) as excinfo:
|
||||
|
@ -2667,6 +2670,45 @@ class ConfigTest(unittest.TestCase):
|
|||
['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):
|
||||
config_details = build_config_details({
|
||||
'version': '2',
|
||||
|
|
Loading…
Reference in New Issue