mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-03 23:14:02 -07:00
[PR #10539/3de073fb backport][stable-11] json_query: extend list of type aliases for compatibility with ansible-core 2.19 (#10560)
json_query: extend list of type aliases for compatibility with ansible-core 2.19 (#10539)
* Extend list of type aliases for json_query.
* Improve tests.
---------
(cherry picked from commit 3de073fb6f
)
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
fc2e2db6e4
commit
9380f9ef7d
3 changed files with 33 additions and 5 deletions
|
@ -124,10 +124,17 @@ def json_query(data, expr):
|
|||
'json_query filter')
|
||||
|
||||
# Hack to handle Ansible Unsafe text, AnsibleMapping and AnsibleSequence
|
||||
# See issue: https://github.com/ansible-collections/community.general/issues/320
|
||||
jmespath.functions.REVERSE_TYPES_MAP['string'] = jmespath.functions.REVERSE_TYPES_MAP['string'] + ('AnsibleUnicode', 'AnsibleUnsafeText', )
|
||||
jmespath.functions.REVERSE_TYPES_MAP['array'] = jmespath.functions.REVERSE_TYPES_MAP['array'] + ('AnsibleSequence', )
|
||||
jmespath.functions.REVERSE_TYPES_MAP['object'] = jmespath.functions.REVERSE_TYPES_MAP['object'] + ('AnsibleMapping', )
|
||||
# See issues https://github.com/ansible-collections/community.general/issues/320
|
||||
# and https://github.com/ansible/ansible/issues/85600.
|
||||
jmespath.functions.REVERSE_TYPES_MAP['string'] = jmespath.functions.REVERSE_TYPES_MAP['string'] + (
|
||||
'AnsibleUnicode', 'AnsibleUnsafeText', '_AnsibleTaggedStr',
|
||||
)
|
||||
jmespath.functions.REVERSE_TYPES_MAP['array'] = jmespath.functions.REVERSE_TYPES_MAP['array'] + (
|
||||
'AnsibleSequence', '_AnsibleLazyTemplateList',
|
||||
)
|
||||
jmespath.functions.REVERSE_TYPES_MAP['object'] = jmespath.functions.REVERSE_TYPES_MAP['object'] + (
|
||||
'AnsibleMapping', '_AnsibleLazyTemplateDict',
|
||||
)
|
||||
try:
|
||||
return jmespath.search(expr, data)
|
||||
except jmespath.exceptions.JMESPathError as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue