diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-05-09 23:04:03 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2013-05-09 23:04:03 -0700 |
commit | 670b46d151477d32056f3fa4eb968c7960f3b472 (patch) | |
tree | 97200d4e7a7460fdc32d9014cf77c6aafa4ade0a /cloudinit/mergers | |
parent | b22a82787378e442cb477d2368ccd7653fd95594 (diff) | |
download | vyos-cloud-init-670b46d151477d32056f3fa4eb968c7960f3b472.tar.gz vyos-cloud-init-670b46d151477d32056f3fa4eb968c7960f3b472.zip |
Allow lists to have no_replace option.
Diffstat (limited to 'cloudinit/mergers')
-rw-r--r-- | cloudinit/mergers/m_list.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cloudinit/mergers/m_list.py b/cloudinit/mergers/m_list.py index 1184ded7..76591bea 100644 --- a/cloudinit/mergers/m_list.py +++ b/cloudinit/mergers/m_list.py @@ -17,7 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. DEF_MERGE_TYPE = 'replace' -MERGE_TYPES = ('append', 'prepend', DEF_MERGE_TYPE,) +MERGE_TYPES = ('append', 'prepend', DEF_MERGE_TYPE, 'no_replace') def _has_any(what, *keys): for k in keys: @@ -67,14 +67,16 @@ class Merger(object): return merged_list def merge_same_index(old_v, new_v): + if self._method == 'no_replace': + # Leave it be... + return old_v if isinstance(new_v, (list, tuple)) and self._recurse_array: return self._merger.merge(old_v, new_v) if isinstance(new_v, (str, basestring)) and self._recurse_str: return self._merger.merge(old_v, new_v) if isinstance(new_v, (dict)) and self._recurse_dict: return self._merger.merge(old_v, new_v) - # Otherwise leave it be... - return old_v + return new_v # Ok now we are replacing same indexes merged_list.extend(value) |