diff --git a/pkg/plugin/v2/webhook.go b/pkg/plugin/v2/webhook.go index 7f34cd40e01..aeae540891b 100644 --- a/pkg/plugin/v2/webhook.go +++ b/pkg/plugin/v2/webhook.go @@ -96,6 +96,12 @@ func (p *createWebhookPlugin) Validate() error { " --programmatic-validation and --conversion to be true", p.commandName) } + // check if resource exist to create webhook + if !p.config.HasResource(p.resource.GVK()) { + return fmt.Errorf("%s create webhook requires an api with the group,"+ + " kind and version provided", p.commandName) + } + return nil } diff --git a/pkg/plugin/v3/webhook.go b/pkg/plugin/v3/webhook.go index 2c643f204a6..929023ad096 100644 --- a/pkg/plugin/v3/webhook.go +++ b/pkg/plugin/v3/webhook.go @@ -96,6 +96,12 @@ func (p *createWebhookPlugin) Validate() error { " --programmatic-validation and --conversion to be true", p.commandName) } + // check if resource exist to create webhook + if !p.config.HasResource(p.resource.GVK()) { + return fmt.Errorf("%s create webhook requires an api with the group,"+ + " kind and version provided", p.commandName) + } + return nil }