diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-04-17 10:17:09 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-04-17 10:17:09 -0700 |
commit | 6ad068d1ae175d784481fe8f8e190b2721a221f5 (patch) | |
tree | f93023b84cbf94459ef7ce3f31fd5f32b70b1714 /cloudinit/util.py | |
parent | 66ea1ae9599d27686db2510f3a079485ea8292c3 (diff) | |
download | vyos-cloud-init-6ad068d1ae175d784481fe8f8e190b2721a221f5.tar.gz vyos-cloud-init-6ad068d1ae175d784481fe8f8e190b2721a221f5.zip |
Altering the order of merging.
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r-- | cloudinit/util.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py index 50de55fe..f7ff28cc 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -543,21 +543,16 @@ def make_url(scheme, host, port=None, def mergemanydict(srcs, reverse=False): if reverse: srcs = reversed(srcs) - m_cfg = {} - merge_how = [mergers.default_mergers()] - for a_cfg in srcs: - if a_cfg: - # Take the last merger as the one that - # will define how to merge next... - mergers_to_apply = list(merge_how[-1]) + merged_cfg = {} + for cfg in srcs: + if cfg: + # Figure out which mergers to apply... + mergers_to_apply = mergers.dict_extract_mergers(cfg) + if not mergers_to_apply: + mergers_to_apply = mergers.default_mergers() merger = mergers.construct(mergers_to_apply) - m_cfg = merger.merge(m_cfg, a_cfg) - # If the config has now has new merger set, - # extract them to be used next time... - new_mergers = mergers.dict_extract_mergers(m_cfg) - if new_mergers: - merge_how.append(new_mergers) - return m_cfg + merged_cfg = merger.merge(merged_cfg, cfg) + return merged_cfg @contextlib.contextmanager |