-
Notifications
You must be signed in to change notification settings - Fork 140
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
Split JSON patch out into a new module #99
Split JSON patch out into a new module #99
Conversation
Codecov Report
@@ Coverage Diff @@
## main #99 +/- ##
=======================================
Coverage 24.02% 24.02%
=======================================
Files 1 1
Lines 154 154
Branches 29 29
=======================================
Hits 37 37
Misses 112 112
Partials 5 5 Continue to review full report at Codecov.
|
minor_changes: | ||
- k8s_json_patch - split JSON patch functionality out into a separate module (https://github.com/ansible-collections/kubernetes.core/pull/99). |
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.
minor_changes: | |
- k8s_json_patch - split JSON patch functionality out into a separate module (https://github.com/ansible-collections/kubernetes.core/pull/99). | |
major_changes: | |
- k8s - the JSON patch functionality has been removed. This feature never worked. | |
- k8s_json_patch - split JSON patch functionality out into a separate module (https://github.com/ansible-collections/kubernetes.core/pull/99). |
If this truly never worked and this won't change any interfaces/behaviour for existing playbooks that might be trying to use this it doesn't really need to be deprecated, but let's still leave a clear paper trail for users.
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.
I have gone ahead and just deprecated merge_type=json
. While it never worked, it usually failed silently.
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.
Rest LGTM. Feel free to merge after resolving the comments.
I am thinking about having a |
nice! lgtm, and I think it makes sense to have json-patch be its own module with |
JSON patch in the k8s module has likely never worked. Furthermore, having resource_definition double as the parameter for patch operations makes fixing this in k8s difficult. This is due, in part, to the fact that a single patch consists of a list of operations that should be processed as a whole, while resource_definition supports a list of resources that should be processed separately. The merge_type parameter allows more than one merge strategy to be specified, but there is no case where a JSON patch could work for JSON merge or strategic merge, nor the other way around. This commit moves JSON patch functionality out into a separate module. Check mode support is provided through the third party jsonpatch library.
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
29c0c27
to
2433d6d
Compare
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.
re: #99 (comment)
One thing to note is that the other modules do return result
[0][1]. If result
isn't appropriate we should probably change the return value in the other modules as well for 3.0, and it would be nice if it matched what was output here (so probably not patched_output
). As a user I think it would be nicer if there was a consistent return value key I could check, rather than having to check/remember what the output key for the same type of information is for each module separately. Perhaps k8s_object
or something like that would make sense.
0: https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_module.rst#return-values
1: https://github.com/ansible-collections/kubernetes.core/blob/main/docs/kubernetes.core.k8s_scale_module.rst#return-values
- while true; do echo $(date); sleep 10; done | ||
wait: yes | ||
|
||
- name: Add a label and replace the image in checkmode |
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.
Could we add a case that tests the remove
action and verifies it's idempotent?
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.
Hmm, I'm not sure if we can test idempotency for remove ops. The path won't exist the second time around and kubernetes will return an error.
@fabianvf false alarm. |
LGTM |
SUMMARY
JSON patch in the k8s module has likely never worked. Furthermore,
having resource_definition double as the parameter for patch operations
makes fixing this in k8s difficult. This is due, in part, to the fact
that a single patch consists of a list of operations that should be
processed as a whole, while resource_definition supports a list of
resources that should be processed separately. The merge_type parameter
allows more than one merge strategy to be specified, but there is no
case where a JSON patch could work for JSON merge or strategic merge,
nor the other way around.
This commit moves JSON patch functionality out into a separate module.
Check mode support is provided through the third party jsonpatch
library.
ISSUE TYPE
COMPONENT NAME
k8s_json_patch
ADDITIONAL INFORMATION