From b1db95f3e0a8196526dbc615ee577966430d8285 Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Sat, 9 Nov 2024 08:52:08 +0000 Subject: [PATCH] revert the changes done in the PR #4286 We are reverting the changes done in the PR #4286. We are just keeping the e2e tests improvements. We will not able to solve the issue https://github.com/kubernetes-sigs/kubebuilder/issues/4146 without add new markers. We cannot skip the action to write an webhook since it will result in incomplete inplementation in the _webhook.go as in the _webhook_test.go --- .../v4/scaffolds/internal/templates/webhooks/webhook.go | 2 +- pkg/plugins/golang/v4/webhook.go | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/webhooks/webhook.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/webhooks/webhook.go index 7b835251e7e..eb18ee9459b 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/webhooks/webhook.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/webhooks/webhook.go @@ -81,7 +81,7 @@ func (f *Webhook) SetTemplateDefaults() error { if f.Force { f.IfExistsAction = machinery.OverwriteFile } else { - f.IfExistsAction = machinery.SkipFile + f.IfExistsAction = machinery.Error } f.AdmissionReviewVersions = "v1" diff --git a/pkg/plugins/golang/v4/webhook.go b/pkg/plugins/golang/v4/webhook.go index 6f5659ca041..685b216db9d 100644 --- a/pkg/plugins/golang/v4/webhook.go +++ b/pkg/plugins/golang/v4/webhook.go @@ -119,12 +119,9 @@ func (p *createWebhookSubcommand) InjectResource(res *resource.Resource) error { return err } - // Ensure at least one webhook type is specified - if !p.resource.HasDefaultingWebhook() && - !p.resource.HasValidationWebhook() && - !p.resource.HasConversionWebhook() { - return fmt.Errorf("%s create webhook requires at least one of --defaulting, --programmatic-validation, "+ - "and --conversion to be true", p.commandName) + if !p.resource.HasDefaultingWebhook() && !p.resource.HasValidationWebhook() && !p.resource.HasConversionWebhook() { + return fmt.Errorf("%s create webhook requires at least one of --defaulting,"+ + " --programmatic-validation and --conversion to be true", p.commandName) } // check if resource exist to create webhook