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 the CRD kustomization path logic to ensure webhook patches are generated exclusively for resources that are configured with webhooks #3838

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

camilamacedo86
Copy link
Member

@camilamacedo86 camilamacedo86 commented Mar 31, 2024

This PR addresses a bug in the generation process of the dist/installer for the testdata sample with multi-group layouts. Previously, the process incorrectly generated webhook patches for all resources, leading to failures in installer creation. With this update, webhook patches are now correctly generated only for resources that have webhooks configured, resolving the issue and ensuring successful generation of the installer.

Closes: #3761

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 31, 2024
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 31, 2024
@camilamacedo86 camilamacedo86 changed the title 🐛 fix crd/kustomize path to generate webhooks patches for resources which has webhook 🐛 Fix the CRD kustomization path logic to ensure webhook patches are generated exclusively for resources that are configured with webhooks Mar 31, 2024
@camilamacedo86
Copy link
Member Author

/test pull-kubebuilder-e2e-k8s-1-26-6

Copy link
Contributor

@Kavinjsir Kavinjsir left a comment

Choose a reason for hiding this comment

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

/lgtm

Comment on lines 92 to 95
if !f.Resource.Webhooks.IsEmpty() {
webhookPatch := make([]string, 0)
// Change the line to uncomment the patch line
webhookPatch = append(webhookPatch, fmt.Sprintf(webhookPatchCodeFragment, suffix))
fragments[machinery.NewMarkerFor(f.Path, webhookPatchMarker)] = webhookPatch
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: does it make sense if we simplify the code lines like:

Suggested change
if !f.Resource.Webhooks.IsEmpty() {
webhookPatch := make([]string, 0)
// Change the line to uncomment the patch line
webhookPatch = append(webhookPatch, fmt.Sprintf(webhookPatchCodeFragment, suffix))
fragments[machinery.NewMarkerFor(f.Path, webhookPatchMarker)] = webhookPatch
}
if !f.Resource.Webhooks.IsEmpty() {
webhookPatch := fmt.Sprintf(webhookPatchCodeFragment, suffix)
fragments[machinery.NewMarkerFor(f.Path, webhookPatchMarker)] = []string{webhookPatch}
}

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 1, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, Kavinjsir

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 needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 1, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 2, 2024
…nerated exclusively for resources that are configured with webhooks
@Kavinjsir
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 Apr 2, 2024
@k8s-ci-robot k8s-ci-robot merged commit 4e206d8 into kubernetes-sigs:master Apr 2, 2024
17 checks passed
@camilamacedo86 camilamacedo86 deleted the fix-dist-g branch April 2, 2024 18:59
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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

webhook patches has not been generated properly for projects with multi-group layout
3 participants