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

enable extended patch transformer and add tests #1355

Merged
merged 4 commits into from
Jul 16, 2019

Conversation

Liujingfang1
Copy link
Contributor

@Liujingfang1 Liujingfang1 commented Jul 15, 2019

part of #720

enable extended patch transformer in kustomization by adding and triggering the config function

add unit tests for extended transformer to select targets

  • by name
  • by group, version, kind
  • by label selector
  • by name and group, version, kind
  • by name and label selector
  • by group, version, kind and label selector
  • by name, group, version, kind and label selector
  • no match

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 15, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Liujingfang1

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 Jul 15, 2019
@k8s-ci-robot k8s-ci-robot requested review from mengqiy and monopole July 15, 2019 22:21
@Liujingfang1 Liujingfang1 requested review from damienr74 and removed request for mengqiy and monopole July 15, 2019 22:21
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 15, 2019
@Liujingfang1 Liujingfang1 requested a review from mengqiy July 15, 2019 22:21
Copy link
Member

@mengqiy mengqiy left a comment

Choose a reason for hiding this comment

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

Other pieces look good.

@@ -200,7 +200,6 @@ func (k *Kustomization) EnforceFields() []string {
// new field names.
func FixKustomizationPreUnmarshalling(data []byte) []byte {
deprecateFieldsMap := map[string]string{
"patches:": "patchesStrategicMerge:",
Copy link
Member

Choose a reason for hiding this comment

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

Hmm... It seems patches field was deprecated and patchesStrategicMerge is the replacement for it.
But now we want to reuse patches field as a different meaning.

Copy link
Member

Choose a reason for hiding this comment

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

It might be a breaking change for "lazy" people that haven't migrated yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've asked about this as well. The patches keyword has been removed since kustomize v2.0.0, so I think this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I've seen, many users already changed patches to patchesStrategicMerge. Maybe @damienr74 can provide some data for how many patches are used in kustomization.yaml file.

Copy link
Contributor

Choose a reason for hiding this comment

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

On public github it appears there's still about 1k of them out of ~6k. But in any case, they would already be broken for kustomize v2+, so I'm not sure there's much of a concern for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@damienr74 @mengqiy We can address this issue by kustomize edit fix command to convert the old patches to the new patches format. I will have a separate PR for it.

pkg/target/extendedpatch_test.go Show resolved Hide resolved
name: busybox
`)
th.WriteF("/app/base/patch.yaml", `
apiVersion: apps/v1beta2
Copy link
Member

Choose a reason for hiding this comment

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

Can we shrink this patch to

metadata:
  name: busybox
  annotations:
    new-key: new-value

or

metadata:
  annotations:
    new-key: new-value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We couldn't do that. If we remove name, then it's not a valid strategic merge patch.

kind: Deployment
`)
th.WriteF("/app/base/patch.yaml", `
apiVersion: apps/v1beta2
Copy link
Member

Choose a reason for hiding this comment

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

same question here

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 16, 2019
Copy link
Contributor

@damienr74 damienr74 left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 16, 2019
@k8s-ci-robot k8s-ci-robot merged commit 878960d into kubernetes-sigs:master Jul 16, 2019
@mengqiy
Copy link
Member

mengqiy commented Jul 20, 2019

It might be a breaking change for "lazy" people that haven't migrated yet.

It turns out we (kubebuilder) are the "lazy" people, we are still using the deprecatespatches. We need to update it.

But in any case, they would already be broken for kustomize v2+, so I'm not sure there's much of a concern for this.

This seems to be not true. Deprecated patches seems working fine for us even with v3.0.1. I didn't realize we were using patches until today.

MikaelSmith added a commit to MikaelSmith/kustomize that referenced this pull request Oct 26, 2021
Updates the example for patching multiple objects to match the
implementation in kubernetes-sigs#1355, which supports name as a regular expression
(not wildcard pattern). Fixes kubernetes-sigs#4258.
MikaelSmith added a commit to MikaelSmith/kustomize that referenced this pull request Oct 26, 2021
Updates the example for patching multiple objects to match the
implementation in kubernetes-sigs#1355, which supports name as a regular expression
(not wildcard pattern).
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants