-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add json_patch, json_patch_recipe and json_diff filters #9565
add json_patch, json_patch_recipe and json_diff filters #9565
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contriubtion! I've added some first comments.
Can you also add integration tests (tests/integration/targets/filter_json_patch/
; see for example tests/integration/targets/filter_jc/
for how to install the required library before running the tests)?
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
Many thanks for the valuabe input. I have addressed the - hopefully all - comments. The filter now accepts binary data (even if not possible to pass it from the play) and there is a Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @numo68 Thanks for contributing!
Got a couple of comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. If nobody objects, I'll merge this in a few days.
Backport to stable-10: 💚 backport PR created✅ Backport PR branch: Backported as #9597 🤖 @patchback |
* add json_patch, json_patch_recipe and json_diff filters * fix copyright notices * fix documentation * fix docs, add maintainer * fix review remarks * add integration test * fix docs (positional) * add input validation * formatting fixes * more typing tweaks * documentation fix * fix review comments * simplicfy input checking * accept bytes and bytearray input * add the fail_test argument * fix docs format * fix typing hints * remove unneeded __future__ imports (cherry picked from commit f5c1b9c)
…cipe and json_diff filters (#9597) add json_patch, json_patch_recipe and json_diff filters (#9565) * add json_patch, json_patch_recipe and json_diff filters * fix copyright notices * fix documentation * fix docs, add maintainer * fix review remarks * add integration test * fix docs (positional) * add input validation * formatting fixes * more typing tweaks * documentation fix * fix review comments * simplicfy input checking * accept bytes and bytearray input * add the fail_test argument * fix docs format * fix typing hints * remove unneeded __future__ imports (cherry picked from commit f5c1b9c) Co-authored-by: Stanislav Meduna <[email protected]>
SUMMARY
The Ansible collections lack a good way to modify JSON data. This PR leverages the jsonpatch package and adds three filters implementing RFC 6902 operations on an object.
ISSUE TYPE
COMPONENT NAME
JavaScript Object Notation (JSON) Patch Filter
ADDITIONAL INFORMATION
There is a previous work done in the (https://github.com/ParticleDecay/ansible-jsonpatch) repo, but I think that the operations themselves should be available on arbitrary data, not just on files; a file modification can be added as a role if necessary.
I am a moderate Ansible user, but the first time contributor to Ansible collections, so if I forgot something, please kindly point out the deficiencies and I'll do my best to fix it.
Thanks for a great tool and great modules!