diff options
Diffstat (limited to 'cloudinit/mergers/m_list.py')
-rw-r--r-- | cloudinit/mergers/m_list.py | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/cloudinit/mergers/m_list.py b/cloudinit/mergers/m_list.py index a56ff007..208c5f52 100644 --- a/cloudinit/mergers/m_list.py +++ b/cloudinit/mergers/m_list.py @@ -20,7 +20,6 @@ class Merger(object): def __init__(self, merger, opts): self._merger = merger - self._discard_non = 'discard_non_list' in opts self._extend = 'extend' in opts def _on_tuple(self, value, merge_with): @@ -29,22 +28,10 @@ class Merger(object): # On encountering a list or tuple type this action will be applied # a new list will be returned, if the value to merge with is itself # a list and we have been told to 'extend', then the value here will - # be extended with the other list. If in 'extend' mode then we will - # attempt to merge instead, which means that values from the list - # to merge with will replace values in te original list (they will - # also be merged recursively). - # - # If the value to merge with is not a list, and we are set to discared - # then no modifications will take place, otherwise we will just append - # the value to merge with onto the end of our own list. + # be extended with the other list. def _on_list(self, value, merge_with): - new_value = list(value) - if isinstance(merge_with, (tuple, list)): - if self._extend: - new_value.extend(merge_with) - else: - return new_value - else: - if not self._discard_non: - new_value.append(merge_with) - return new_value + if not self._extend or not isinstance(merge_with, (tuple, list)): + return merge_with + # Leave the original list alone... + value = list(value) + return value.extend(merge_with) |