mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
[FactCache] define first_order_merge method (#55781)
* Add first_order_merge method Add test for updating a key that already exists * changelog
This commit is contained in:
parent
1e6edf2ccc
commit
598a058afe
3 changed files with 21 additions and 0 deletions
|
@ -58,6 +58,19 @@ class FactCache(MutableMapping):
|
|||
""" Flush the fact cache of all keys. """
|
||||
self._plugin.flush()
|
||||
|
||||
def first_order_merge(self, key, value):
|
||||
host_facts = {key: value}
|
||||
|
||||
try:
|
||||
host_cache = self._plugin.get(key)
|
||||
if host_cache:
|
||||
host_cache.update(value)
|
||||
host_facts[key] = host_cache
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
super(FactCache, self).update(host_facts)
|
||||
|
||||
def update(self, *args):
|
||||
"""
|
||||
Backwards compat shim
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue