Ignore top-level merge items which evaluate False

There has been recent tripleo regressions caused by heat
setting empty config as '' rather than {} which cause os-apply-config
to error on merge_configs.

This change ignores any top-level config which evaluates to False,
ignoring possible empty data including '', {}, None, []

An os-apply-config release with this fix would likely allow the current
heat pin to be removed Id134664a5df7232da0fb5d9ed62b82e12b3d54a8

Change-Id: Ia5bd99d1550f43760c064b769be3be46b3417331
Closes-Bug: #1426116
Related-Bug: #1425238
This commit is contained in:
Steve Baker 2015-02-27 09:38:21 +13:00
parent 9d70d50ff3
commit 94f9819c67
2 changed files with 7 additions and 1 deletions

View File

@ -58,7 +58,8 @@ def merge_configs(parsed_configs):
'''Returns deep-merged dict from passed list of dicts.'''
final_conf = {}
for conf in parsed_configs:
final_conf = _deep_merge_dict(final_conf, conf)
if conf:
final_conf = _deep_merge_dict(final_conf, conf)
return final_conf

View File

@ -114,3 +114,8 @@ class TestMergeConfigs(testtools.TestCase):
{'a': [4, 5, 6]}]
result = collect_config.merge_configs(list_conflict)
self.assertEqual({'a': [4, 5, 6]}, result)
def test_merge_configs_empty_notdict(self):
list_conflict = [[], {'a': '1'}, '', None, {'b': '2'}, {}]
result = collect_config.merge_configs(list_conflict)
self.assertEqual({'a': '1', 'b': '2'}, result)