Skip to content
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

✨ Fix roundtripping issue when genearting JSON patch #251

Closed

Conversation

mengqiy
Copy link
Member

@mengqiy mengqiy commented Dec 14, 2018

fixes kubernetes-sigs/kubebuilder#510
The change should be backward compatible

An alternative is in #256.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mengqiy
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: directxman12

If they are not already assigned, you can assign the PR to them by writing /assign @directxman12 in a comment when ready.

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 14, 2018
@mengqiy
Copy link
Member Author

mengqiy commented Dec 14, 2018

cc: @FillZpp

Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one suggestion.

// If the original raw object is provided, it will be used to calculate json patch.
// It is STRONGLY recommended to use the original raw object to avoid the roundtripping
// issue for non-pointer fields.
func NewJSONPatch(original, current runtime.Object, originalRaw ...byte) ([]jsonpatch.JsonPatchOperation, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is STRONGLY recommended to provide originalRaw, it will help to not to treat this field optional. I know that will introduce a breaking change, but I think thats ok (we can include this for next major release). Also using originalRaw... is also not intuitive (I know its clever because it keeps this change backward compatible) when you expect a slice of bytes.

So my recommendation would be to introduce it with breaking change with originalRaw []byte as the last arg.

@mengqiy mengqiy added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 14, 2018
@mengqiy mengqiy removed the request for review from pwittrock December 18, 2018 00:05
@mengqiy
Copy link
Member Author

mengqiy commented Jan 16, 2019

Closing in favor of #256.

@mengqiy mengqiy closed this Jan 16, 2019
@mengqiy mengqiy deleted the fix_roundtripping_when_gen_patch branch January 16, 2019 00:19
DirectXMan12 pushed a commit that referenced this pull request Jan 31, 2020
Add annotation tests into test projects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] mutating webhook admission failed because of wrong json patch
3 participants