Skip to content

Patchtransformers - drop copied code, improve deletion handling. #3291

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

Merged
merged 1 commit into from
Nov 30, 2020

Conversation

monopole
Copy link
Contributor

No description provided.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 30, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: monopole

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 30, 2020
// ApplySmPatch applies a strategic-merge patch to the
// selected set of resources.
ApplySmPatch(
selectedSet *resource.IdSet, patch *resource.Resource) error
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we put this method in resmap?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before this PR, the code in the body of this method (reswrangler.ApplySmPatch) lives in both PatchStrategicMergeTransformer and PatchTransformer, and has a bug in both places.

The bug is the test target.IsEmpty, followed by the call to target.CurId. This call fails when enable_kyaml is true, because with an RNode backing, there's isn't an ID at all.

We could fix the code in both places and hope it is maintained in both places, or move it to one place, and fix it there.

The fact that the code operates on a resmap (the loop over m.Resources()) suggests adding the code to resmap. I suppose we could push it down into a filter and have it operate on []RNode, but i'm trying to get enable_kyaml working first before doing futher code cleanup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR should include more tests for reswrangler, to confirm the behavior of delete.
I'll do that.

The actual patch code is covered by all the new tests in resource_test.go this PR adds. They were adapted from the plugin tests.

@Shell32-Natsu
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 30, 2020
@k8s-ci-robot k8s-ci-robot merged commit 83377cf into kubernetes-sigs:master Nov 30, 2020
@monopole monopole deleted the thrashing branch December 1, 2020 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants