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

✨ Move the webhookcainjection_patch.yaml file creation from init project to webhook creation #1728

Merged
merged 1 commit into from
Oct 21, 2020

Conversation

prafull01
Copy link
Contributor

@prafull01 prafull01 commented Oct 19, 2020

Description of the Change:
webhookcainjection_patch.yaml file is created at the init of the project, I have changed that to be created at the time of webhook creation.

Motivation:
I am a consumer of the kubebuilder plugins would like that each plugin only scaffold manifests which are related to its domain so that, I can decide what plugins I'd like to consume or not.

Fixes: #1727

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 19, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @prafull01. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 19, 2020
@prafull01
Copy link
Contributor Author

/cc @camilamacedo86

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package kdefault
package webhook
Copy link
Contributor

Choose a reason for hiding this comment

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

This file will still be scaffolded in config/default, so should remain in the config/kdefault package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done..

@@ -37,7 +37,8 @@ func (f *InjectCAPatch) SetTemplateDefaults() error {

f.TemplateBody = injectCAPatchTemplate

f.IfExistsAction = file.Error
// If file webhookcainjection_patch.yaml exist, skip its creation
Copy link
Contributor

Choose a reason for hiding this comment

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

Only the v3 plugin should be changed, so revert changes in pkg/plugin/v2.

Copy link
Member

@camilamacedo86 camilamacedo86 Oct 19, 2020

Choose a reason for hiding this comment

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

IMO would be fine do it for v2+ since it shows a bug introduced instead of a RFE. However, I would be ok with change only for v3+

Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand correctly, scaffolding this patch during init is intentional because it is directly referenced in config/default/kustomization.yaml. @DirectXMan12 is that correct?

Copy link
Member

@camilamacedo86 camilamacedo86 Oct 20, 2020

Choose a reason for hiding this comment

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

Hi @estroz,

I do not think that it was intentional. Note that, it may be hurting concepts such as encapsulation, single responsibility principle and almost for sure cohesion that may cause unexpected sides effects such difficulty to read, maintain/improve and extend, to mention a few. Also, IMO:

As @pwittrock spoke well another day, it is very hard for users to know and maintain so many config files, in this way, allow the init create/delete/update webhooks manifests not make harder ONLY for us(contributors) but also for users since it means more unnecessary config files for their scenarios. So, a use case that it hurts, for example, would be I am an operator dev would like to see specific manifests which are required/useful for the webhooks only/if my project has webhooks

Also, note that when we introduce the plugin design we start to allow the plugins to be consumed for the other projects. Then, it means that as a developer I can decide to consume only the init and the create the plugin as well which means that my projects would NOT support webhooks then, would not make sense have webhooks flags or scaffolded manifests in the init command/plugin. It shows hurt the domains of responsibility as described in #1644.

Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify what I mean: the choice to scaffold this file in init may have been sub-optimal, but it was a conscious (intentional) one. Regardless the right move is to move this to create webhook.

Copy link
Contributor

@estroz estroz left a comment

Choose a reason for hiding this comment

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

If we're only making these changes to support the outcome of #1644's discussion about flags, we should hold off on reviewing this PR until that discussion is finalized. If we decide to go with create webhook --webhook-version over init --webhook-version, then this PR can go ahead for review.

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 19, 2020
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 19, 2020
@camilamacedo86
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 19, 2020
@camilamacedo86
Copy link
Member

I think we can :
/hold cancel

based on the discussion made in the bug triage meeting.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 20, 2020
@@ -19,6 +19,8 @@ package scaffolds
import (
"fmt"

"sigs.k8s.io/kubebuilder/pkg/plugin/v3/scaffolds/internal/templates/config/kdefault"
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Sort the import. It needs to be at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -37,7 +37,8 @@ func (f *InjectCAPatch) SetTemplateDefaults() error {

f.TemplateBody = injectCAPatchTemplate

f.IfExistsAction = file.Error
// If file webhookcainjection_patch.yaml exist, skip its creation
f.IfExistsAction = file.Skip
Copy link
Member

@camilamacedo86 camilamacedo86 Oct 20, 2020

Choose a reason for hiding this comment

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

I liked that 👍
Great work

Comment on lines 126 to 128
&webhook.Kustomization{},
&webhook.KustomizeConfigWebhook{},
&webhook.Service{},
Copy link
Member

Choose a reason for hiding this comment

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

IMO, I think we need also move these ones to the webhook plugin as well since they are specific to the webhook plugin and are not useful to projects which as not in the webhooks. I mean, it shows to be the same scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I also thinks the same.. Should I move all the webhook related scaffolding in this PR itself? Or should we wait for discussion to be finalized on #1644 ?

Copy link
Member

Choose a reason for hiding this comment

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

I understood that we agreed to move forward with into the bug triage. However, let's see if @estroz would like to hold on that until we finalized on #1644.

Copy link
Contributor

@estroz estroz 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 Oct 20, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: estroz, prafull01

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 Oct 20, 2020
@estroz
Copy link
Contributor

estroz commented Oct 20, 2020

I don't think this is a bug. @prafull01 can you remove :bug: and add :sparkles: to the title?

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 20, 2020
@prafull01 prafull01 changed the title 🐛 Fix the webhookcainjection_patch.yaml file creation from init project to webhook creation ✨ Fix the webhookcainjection_patch.yaml file creation from init project to webhook creation Oct 21, 2020
@prafull01 prafull01 changed the title ✨ Fix the webhookcainjection_patch.yaml file creation from init project to webhook creation ✨ Move the webhookcainjection_patch.yaml file creation from init project to webhook creation Oct 21, 2020
@camilamacedo86
Copy link
Member

camilamacedo86 commented Oct 21, 2020

Since @estroz /lgtm this one and just hold until the author be able to update its title with ✨ then, shows that all is done to get it merged. IMO: We will still require a follow up for https://github.com/kubernetes-sigs/kubebuilder/pull/1728/files#r508778432. To address that the issue #1734 was raised.
However, it shows fine we move forward with so

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 21, 2020
@estroz
Copy link
Contributor

estroz commented Oct 21, 2020

The PR will merge with the wrong commit message if you remove the hold @camilamacedo86

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 21, 2020
@estroz
Copy link
Contributor

estroz commented Oct 21, 2020

Ah didn’t see the title was updated.

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 21, 2020
@k8s-ci-robot k8s-ci-robot merged commit 5439752 into kubernetes-sigs:master Oct 21, 2020
@prafull01 prafull01 deleted the webhook-cainjection branch October 21, 2020 20:19
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The manifest config/default/webhookcainjection_patch.yaml ought to be scaffold in the webhook plugin
4 participants