From 1706b172f01abf16ee60687423235da8c5cc902b Mon Sep 17 00:00:00 2001 From: Anusha Hegde Date: Thu, 28 Apr 2022 17:55:30 +0000 Subject: [PATCH 1/5] Implement low level admission handler interface To intercept the ByoHost req object, implementing the low level Handle function. Fix and refactor existing test and code for byohost webhook --- .../infrastructure/v1beta1/byohost_webhook.go | 61 +++++++++---------- .../v1beta1/byohost_webhook_test.go | 9 ++- .../v1beta1/webhook_suite_test.go | 6 +- ...rastructure.cluster.x-k8s.io_byohosts.yaml | 2 +- main.go | 8 +-- 5 files changed, 42 insertions(+), 44 deletions(-) diff --git a/apis/infrastructure/v1beta1/byohost_webhook.go b/apis/infrastructure/v1beta1/byohost_webhook.go index 58c2243e4..52d565ebd 100644 --- a/apis/infrastructure/v1beta1/byohost_webhook.go +++ b/apis/infrastructure/v1beta1/byohost_webhook.go @@ -4,48 +4,43 @@ package v1beta1 import ( - "errors" - - apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/runtime/schema" - ctrl "sigs.k8s.io/controller-runtime" - logf "sigs.k8s.io/controller-runtime/pkg/log" - "sigs.k8s.io/controller-runtime/pkg/webhook" -) - -// log is for logging in this package -var byohostlog = logf.Log.WithName("byohost-resource") + "context" + "net/http" -// SetupWebhookWithManager sets up the webhook for the byohost resource -func (byoHost *ByoHost) SetupWebhookWithManager(mgr ctrl.Manager) error { - return ctrl.NewWebhookManagedBy(mgr). - For(byoHost). - Complete() -} + v1 "k8s.io/api/admission/v1" + "sigs.k8s.io/controller-runtime/pkg/webhook/admission" +) //+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-byohost,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=byohosts,verbs=create;update;delete,versions=v1beta1,name=vbyohost.kb.io,admissionReviewVersions={v1,v1beta1} -var _ webhook.Validator = &ByoHost{} - -// ValidateCreate implements webhook.Validator so a webhook will be registered for the type -func (byoHost *ByoHost) ValidateCreate() error { - return nil +// +k8s:deepcopy-gen=false +// ByohHostValidator validates ByoHosts +type ByohHostValidator struct { + // Client client.Client + decoder *admission.Decoder } -// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type -func (byoHost *ByoHost) ValidateUpdate(old runtime.Object) error { - return nil -} +// nolint: gocritic +// Handle handles all the requests for ByoHost resource +func (v *ByohHostValidator) Handle(ctx context.Context, req admission.Request) admission.Response { -// ValidateDelete implements webhook.Validator so a webhook will be registered for the type -func (byoHost *ByoHost) ValidateDelete() error { - byohostlog.Info("validate delete", "name", byoHost.Name) - groupResource := schema.GroupResource{Group: "infrastructure.cluster.x-k8s.io", Resource: "byohost"} + if req.Operation == v1.Delete { + byoHost := &ByoHost{} + err := v.decoder.DecodeRaw(req.OldObject, byoHost) + if err != nil { + return admission.Errored(http.StatusBadRequest, err) + } - if byoHost.Status.MachineRef != nil { - return apierrors.NewForbidden(groupResource, byoHost.Name, errors.New("cannot delete ByoHost when MachineRef is assigned")) + if byoHost.Status.MachineRef != nil { + return admission.Denied("cannot delete ByoHost when MachineRef is assigned") + } } + return admission.Allowed("") +} + +// InjectDecoder injects the decoder. +func (v *ByohHostValidator) InjectDecoder(d *admission.Decoder) error { + v.decoder = d return nil } diff --git a/apis/infrastructure/v1beta1/byohost_webhook_test.go b/apis/infrastructure/v1beta1/byohost_webhook_test.go index e47139f2d..a3ccd8861 100644 --- a/apis/infrastructure/v1beta1/byohost_webhook_test.go +++ b/apis/infrastructure/v1beta1/byohost_webhook_test.go @@ -43,10 +43,12 @@ var _ = Describe("ByohostWebhook", func() { Spec: byohv1beta1.ByoHostSpec{}, } Expect(k8sClientUncached.Create(ctx, byoHost)).Should(Succeed()) + }) It("should not reject the request", func() { - err := byoHost.ValidateDelete() + + err := k8sClientUncached.Delete(ctx, byoHost) Expect(err).To(BeNil()) }) @@ -78,12 +80,13 @@ var _ = Describe("ByohostWebhook", func() { APIVersion: byoHost.APIVersion, } Expect(ph.Patch(ctx, byoHost, patch.WithStatusObservedGeneration{})).Should(Succeed()) + }) It("should reject the request", func() { - err := byoHost.ValidateDelete() + err := k8sClientUncached.Delete(ctx, byoHost) Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError("byohost.infrastructure.cluster.x-k8s.io \"" + byoHost.Name + "\" is forbidden: cannot delete ByoHost when MachineRef is assigned")) + Expect(err).To(MatchError("admission webhook \"vbyohost.kb.io\" denied the request: cannot delete ByoHost when MachineRef is assigned")) }) }) }) diff --git a/apis/infrastructure/v1beta1/webhook_suite_test.go b/apis/infrastructure/v1beta1/webhook_suite_test.go index d5fa6ed8c..f687230c3 100644 --- a/apis/infrastructure/v1beta1/webhook_suite_test.go +++ b/apis/infrastructure/v1beta1/webhook_suite_test.go @@ -28,6 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/envtest/printer" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" + "sigs.k8s.io/controller-runtime/pkg/webhook" ) // These tests use Ginkgo (BDD-style Go testing framework). Refer to @@ -97,12 +98,11 @@ var _ = BeforeSuite(func() { }) Expect(err).NotTo(HaveOccurred()) - err = (&byohv1beta1.ByoHost{}).SetupWebhookWithManager(mgr) - Expect(err).NotTo(HaveOccurred()) - err = (&byohv1beta1.ByoCluster{}).SetupWebhookWithManager(mgr) Expect(err).NotTo(HaveOccurred()) + mgr.GetWebhookServer().Register("/validate-infrastructure-cluster-x-k8s-io-v1beta1-byohost", &webhook.Admission{Handler: &byohv1beta1.ByohHostValidator{}}) + //+kubebuilder:scaffold:webhook go func() { diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_byohosts.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_byohosts.yaml index 4fd6d0a26..724e9172e 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_byohosts.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_byohosts.yaml @@ -77,7 +77,7 @@ spec: type: object installationSecret: description: InstallationSecret is an optional reference to InstallationSecret - generated by InstallerController for k8s installation + generated by InstallerController for K8s installation properties: apiVersion: description: API version of the referent. diff --git a/main.go b/main.go index 2b4685ca3..365390be1 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,7 @@ import ( clientgoscheme "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/healthz" + "sigs.k8s.io/controller-runtime/pkg/webhook" byohcontrollers "github.com/vmware-tanzu/cluster-api-provider-bringyourownhost/controllers/infrastructure" @@ -118,14 +119,13 @@ func main() { os.Exit(1) } - if err = (&infrastructurev1beta1.ByoHost{}).SetupWebhookWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create webhook", "webhook", "ByoHost") - os.Exit(1) - } if err = (&infrastructurev1beta1.ByoCluster{}).SetupWebhookWithManager(mgr); err != nil { setupLog.Error(err, "unable to create webhook", "webhook", "ByoCluster") os.Exit(1) } + + mgr.GetWebhookServer().Register("/validate-infrastructure-cluster-x-k8s-io-v1beta1-byohost", &webhook.Admission{Handler: &infrastructurev1beta1.ByohHostValidator{}}) + //+kubebuilder:scaffold:builder if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { From 93699b002179bf783cb07655e8b2e9165a5fe398 Mon Sep 17 00:00:00 2001 From: Anusha Hegde Date: Fri, 29 Apr 2022 06:54:10 +0000 Subject: [PATCH 2/5] Add webhook handles for byohost update requests --- .../infrastructure/v1beta1/byohost_webhook.go | 10 +++ .../v1beta1/byohost_webhook_test.go | 89 +++++++++++++++++++ .../v1beta1/webhook_suite_test.go | 20 +++-- 3 files changed, 114 insertions(+), 5 deletions(-) diff --git a/apis/infrastructure/v1beta1/byohost_webhook.go b/apis/infrastructure/v1beta1/byohost_webhook.go index 52d565ebd..ecab558e5 100644 --- a/apis/infrastructure/v1beta1/byohost_webhook.go +++ b/apis/infrastructure/v1beta1/byohost_webhook.go @@ -34,6 +34,16 @@ func (v *ByohHostValidator) Handle(ctx context.Context, req admission.Request) a if byoHost.Status.MachineRef != nil { return admission.Denied("cannot delete ByoHost when MachineRef is assigned") } + } else { + byoHost := &ByoHost{} + err := v.decoder.Decode(req, byoHost) + if err != nil { + return admission.Errored(http.StatusBadRequest, err) + } + + if req.UserInfo.Username != "admin" && req.UserInfo.Username != byoHost.Name { + return admission.Denied("User does not have the permission to perform this operation") + } } return admission.Allowed("") diff --git a/apis/infrastructure/v1beta1/byohost_webhook_test.go b/apis/infrastructure/v1beta1/byohost_webhook_test.go index a3ccd8861..02ecd35bc 100644 --- a/apis/infrastructure/v1beta1/byohost_webhook_test.go +++ b/apis/infrastructure/v1beta1/byohost_webhook_test.go @@ -18,6 +18,95 @@ import ( var _ = Describe("ByohostWebhook", func() { + Context("When ByoHost gets an update request", func() { + var ( + byoHost *byohv1beta1.ByoHost + ctx context.Context + k8sClientUncached client.Client + ) + + BeforeEach(func() { + ctx = context.Background() + var clientErr error + + k8sClientUncached, clientErr = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + Expect(clientErr).NotTo(HaveOccurred()) + + byoHost = &byohv1beta1.ByoHost{ + TypeMeta: metav1.TypeMeta{ + Kind: "ByoHost", + APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", + }, + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "byohost-", + Namespace: "default", + }, + Spec: byohv1beta1.ByoHostSpec{}, + } + Expect(k8sClientUncached.Create(ctx, byoHost)).Should(Succeed()) + + }) + + It("should allow request coming from admin user", func() { + byoMachine := &byohv1beta1.ByoMachine{ + TypeMeta: metav1.TypeMeta{ + Kind: "ByoMachine", + APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", + }, + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "byomachine-", + Namespace: "default", + }, + Spec: byohv1beta1.ByoMachineSpec{}, + } + Expect(k8sClientUncached.Create(ctx, byoMachine)).Should(Succeed()) + ph, err := patch.NewHelper(byoHost, k8sClientUncached) + Expect(err).ShouldNot(HaveOccurred()) + byoHost.Status.MachineRef = &corev1.ObjectReference{ + Kind: "ByoMachine", + Namespace: byoMachine.Namespace, + Name: byoMachine.Name, + UID: byoMachine.UID, + APIVersion: byoHost.APIVersion, + } + + err = ph.Patch(ctx, byoHost, patch.WithStatusObservedGeneration{}) + Expect(err).ToNot(HaveOccurred()) + }) + + It("should allow request coming from the right host agent user", func() { + byoMachine := &byohv1beta1.ByoMachine{ + TypeMeta: metav1.TypeMeta{ + Kind: "ByoMachine", + APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", + }, + ObjectMeta: metav1.ObjectMeta{ + GenerateName: "byomachine-", + Namespace: "default", + }, + Spec: byohv1beta1.ByoMachineSpec{}, + } + Expect(k8sClientUncached.Create(ctx, byoMachine)).Should(Succeed()) + ph, err := patch.NewHelper(byoHost, testUserK8sClient) + Expect(err).ShouldNot(HaveOccurred()) + byoHost.Status.MachineRef = &corev1.ObjectReference{ + Kind: "ByoMachine", + Namespace: byoMachine.Namespace, + Name: byoMachine.Name, + UID: byoMachine.UID, + APIVersion: byoHost.APIVersion, + } + + err = ph.Patch(ctx, byoHost, patch.WithStatusObservedGeneration{}) + Expect(err).To(HaveOccurred()) + // Expect(err).To(MatchError("admission webhook \"vbyohost.kb.io\" denied the request: User does not have the permission to perform this operation")) + }) + + It("should deny request coming from any other host agent user", func() { + + }) + }) + Context("When ByoHost gets a delete request", func() { var ( byoHost *byohv1beta1.ByoHost diff --git a/apis/infrastructure/v1beta1/webhook_suite_test.go b/apis/infrastructure/v1beta1/webhook_suite_test.go index f687230c3..2f9d8c741 100644 --- a/apis/infrastructure/v1beta1/webhook_suite_test.go +++ b/apis/infrastructure/v1beta1/webhook_suite_test.go @@ -35,11 +35,12 @@ import ( // http://onsi.github.io/ginkgo/ to learn more about Ginkgo. var ( - cfg *rest.Config - k8sClient client.Client - testEnv *envtest.Environment - ctx context.Context - cancel context.CancelFunc + cfg *rest.Config + k8sClient client.Client + testUserK8sClient client.Client + testEnv *envtest.Environment + ctx context.Context + cancel context.CancelFunc ) func TestAPIs(t *testing.T) { @@ -97,6 +98,15 @@ var _ = BeforeSuite(func() { MetricsBindAddress: "0", }) Expect(err).NotTo(HaveOccurred()) + user, err := testEnv.ControlPlane.AddUser(envtest.User{ + Name: "test-user", + Groups: []string{"system:byoh"}, + }, nil) + Expect(err).NotTo(HaveOccurred()) + + testUserK8sClient, err = client.New(user.Config(), client.Options{Scheme: scheme.Scheme}) + Expect(err).NotTo(HaveOccurred()) + Expect(k8sClient).NotTo(BeNil()) err = (&byohv1beta1.ByoCluster{}).SetupWebhookWithManager(mgr) Expect(err).NotTo(HaveOccurred()) From e38017cbafef426a2d55388da4ba185c2b4474d1 Mon Sep 17 00:00:00 2001 From: Anusha Hegde Date: Fri, 29 Apr 2022 06:57:14 +0000 Subject: [PATCH 3/5] Fix lint issues --- apis/infrastructure/v1beta1/byohost_webhook.go | 1 - 1 file changed, 1 deletion(-) diff --git a/apis/infrastructure/v1beta1/byohost_webhook.go b/apis/infrastructure/v1beta1/byohost_webhook.go index ecab558e5..d7c828b9c 100644 --- a/apis/infrastructure/v1beta1/byohost_webhook.go +++ b/apis/infrastructure/v1beta1/byohost_webhook.go @@ -23,7 +23,6 @@ type ByohHostValidator struct { // nolint: gocritic // Handle handles all the requests for ByoHost resource func (v *ByohHostValidator) Handle(ctx context.Context, req admission.Request) admission.Response { - if req.Operation == v1.Delete { byoHost := &ByoHost{} err := v.decoder.DecodeRaw(req.OldObject, byoHost) From 23ea765350df3090af89af1b3c59ef021bd63379 Mon Sep 17 00:00:00 2001 From: Anusha Hegde Date: Sat, 30 Apr 2022 00:34:11 +0000 Subject: [PATCH 4/5] Remove update flow --- .../infrastructure/v1beta1/byohost_webhook.go | 12 +-- .../v1beta1/byohost_webhook_test.go | 89 ------------------- 2 files changed, 2 insertions(+), 99 deletions(-) diff --git a/apis/infrastructure/v1beta1/byohost_webhook.go b/apis/infrastructure/v1beta1/byohost_webhook.go index d7c828b9c..039ee2de4 100644 --- a/apis/infrastructure/v1beta1/byohost_webhook.go +++ b/apis/infrastructure/v1beta1/byohost_webhook.go @@ -33,18 +33,10 @@ func (v *ByohHostValidator) Handle(ctx context.Context, req admission.Request) a if byoHost.Status.MachineRef != nil { return admission.Denied("cannot delete ByoHost when MachineRef is assigned") } - } else { - byoHost := &ByoHost{} - err := v.decoder.Decode(req, byoHost) - if err != nil { - return admission.Errored(http.StatusBadRequest, err) - } - - if req.UserInfo.Username != "admin" && req.UserInfo.Username != byoHost.Name { - return admission.Denied("User does not have the permission to perform this operation") - } } + // TODO: verify if req.UserInfo.Username has rbac permission to update the byohost + return admission.Allowed("") } diff --git a/apis/infrastructure/v1beta1/byohost_webhook_test.go b/apis/infrastructure/v1beta1/byohost_webhook_test.go index 02ecd35bc..a3ccd8861 100644 --- a/apis/infrastructure/v1beta1/byohost_webhook_test.go +++ b/apis/infrastructure/v1beta1/byohost_webhook_test.go @@ -18,95 +18,6 @@ import ( var _ = Describe("ByohostWebhook", func() { - Context("When ByoHost gets an update request", func() { - var ( - byoHost *byohv1beta1.ByoHost - ctx context.Context - k8sClientUncached client.Client - ) - - BeforeEach(func() { - ctx = context.Background() - var clientErr error - - k8sClientUncached, clientErr = client.New(cfg, client.Options{Scheme: scheme.Scheme}) - Expect(clientErr).NotTo(HaveOccurred()) - - byoHost = &byohv1beta1.ByoHost{ - TypeMeta: metav1.TypeMeta{ - Kind: "ByoHost", - APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", - }, - ObjectMeta: metav1.ObjectMeta{ - GenerateName: "byohost-", - Namespace: "default", - }, - Spec: byohv1beta1.ByoHostSpec{}, - } - Expect(k8sClientUncached.Create(ctx, byoHost)).Should(Succeed()) - - }) - - It("should allow request coming from admin user", func() { - byoMachine := &byohv1beta1.ByoMachine{ - TypeMeta: metav1.TypeMeta{ - Kind: "ByoMachine", - APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", - }, - ObjectMeta: metav1.ObjectMeta{ - GenerateName: "byomachine-", - Namespace: "default", - }, - Spec: byohv1beta1.ByoMachineSpec{}, - } - Expect(k8sClientUncached.Create(ctx, byoMachine)).Should(Succeed()) - ph, err := patch.NewHelper(byoHost, k8sClientUncached) - Expect(err).ShouldNot(HaveOccurred()) - byoHost.Status.MachineRef = &corev1.ObjectReference{ - Kind: "ByoMachine", - Namespace: byoMachine.Namespace, - Name: byoMachine.Name, - UID: byoMachine.UID, - APIVersion: byoHost.APIVersion, - } - - err = ph.Patch(ctx, byoHost, patch.WithStatusObservedGeneration{}) - Expect(err).ToNot(HaveOccurred()) - }) - - It("should allow request coming from the right host agent user", func() { - byoMachine := &byohv1beta1.ByoMachine{ - TypeMeta: metav1.TypeMeta{ - Kind: "ByoMachine", - APIVersion: "infrastructure.cluster.x-k8s.io/v1beta1", - }, - ObjectMeta: metav1.ObjectMeta{ - GenerateName: "byomachine-", - Namespace: "default", - }, - Spec: byohv1beta1.ByoMachineSpec{}, - } - Expect(k8sClientUncached.Create(ctx, byoMachine)).Should(Succeed()) - ph, err := patch.NewHelper(byoHost, testUserK8sClient) - Expect(err).ShouldNot(HaveOccurred()) - byoHost.Status.MachineRef = &corev1.ObjectReference{ - Kind: "ByoMachine", - Namespace: byoMachine.Namespace, - Name: byoMachine.Name, - UID: byoMachine.UID, - APIVersion: byoHost.APIVersion, - } - - err = ph.Patch(ctx, byoHost, patch.WithStatusObservedGeneration{}) - Expect(err).To(HaveOccurred()) - // Expect(err).To(MatchError("admission webhook \"vbyohost.kb.io\" denied the request: User does not have the permission to perform this operation")) - }) - - It("should deny request coming from any other host agent user", func() { - - }) - }) - Context("When ByoHost gets a delete request", func() { var ( byoHost *byohv1beta1.ByoHost From 04dcef97a87bb23d7389eee5e2ea54a8e781699a Mon Sep 17 00:00:00 2001 From: Anusha Hegde Date: Mon, 2 May 2022 04:52:49 +0000 Subject: [PATCH 5/5] Rename ByoHostValidator --- apis/infrastructure/v1beta1/byohost_webhook.go | 8 ++++---- apis/infrastructure/v1beta1/webhook_suite_test.go | 4 ++-- main.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apis/infrastructure/v1beta1/byohost_webhook.go b/apis/infrastructure/v1beta1/byohost_webhook.go index 039ee2de4..9ed845ee7 100644 --- a/apis/infrastructure/v1beta1/byohost_webhook.go +++ b/apis/infrastructure/v1beta1/byohost_webhook.go @@ -14,15 +14,15 @@ import ( //+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-byohost,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=byohosts,verbs=create;update;delete,versions=v1beta1,name=vbyohost.kb.io,admissionReviewVersions={v1,v1beta1} // +k8s:deepcopy-gen=false -// ByohHostValidator validates ByoHosts -type ByohHostValidator struct { +// ByoHostValidator validates ByoHosts +type ByoHostValidator struct { // Client client.Client decoder *admission.Decoder } // nolint: gocritic // Handle handles all the requests for ByoHost resource -func (v *ByohHostValidator) Handle(ctx context.Context, req admission.Request) admission.Response { +func (v *ByoHostValidator) Handle(ctx context.Context, req admission.Request) admission.Response { if req.Operation == v1.Delete { byoHost := &ByoHost{} err := v.decoder.DecodeRaw(req.OldObject, byoHost) @@ -41,7 +41,7 @@ func (v *ByohHostValidator) Handle(ctx context.Context, req admission.Request) a } // InjectDecoder injects the decoder. -func (v *ByohHostValidator) InjectDecoder(d *admission.Decoder) error { +func (v *ByoHostValidator) InjectDecoder(d *admission.Decoder) error { v.decoder = d return nil } diff --git a/apis/infrastructure/v1beta1/webhook_suite_test.go b/apis/infrastructure/v1beta1/webhook_suite_test.go index 2f9d8c741..6cb81f0c9 100644 --- a/apis/infrastructure/v1beta1/webhook_suite_test.go +++ b/apis/infrastructure/v1beta1/webhook_suite_test.go @@ -100,7 +100,7 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) user, err := testEnv.ControlPlane.AddUser(envtest.User{ Name: "test-user", - Groups: []string{"system:byoh"}, + Groups: []string{"byoh:hosts"}, }, nil) Expect(err).NotTo(HaveOccurred()) @@ -111,7 +111,7 @@ var _ = BeforeSuite(func() { err = (&byohv1beta1.ByoCluster{}).SetupWebhookWithManager(mgr) Expect(err).NotTo(HaveOccurred()) - mgr.GetWebhookServer().Register("/validate-infrastructure-cluster-x-k8s-io-v1beta1-byohost", &webhook.Admission{Handler: &byohv1beta1.ByohHostValidator{}}) + mgr.GetWebhookServer().Register("/validate-infrastructure-cluster-x-k8s-io-v1beta1-byohost", &webhook.Admission{Handler: &byohv1beta1.ByoHostValidator{}}) //+kubebuilder:scaffold:webhook diff --git a/main.go b/main.go index 365390be1..4d1dd2bed 100644 --- a/main.go +++ b/main.go @@ -124,7 +124,7 @@ func main() { os.Exit(1) } - mgr.GetWebhookServer().Register("/validate-infrastructure-cluster-x-k8s-io-v1beta1-byohost", &webhook.Admission{Handler: &infrastructurev1beta1.ByohHostValidator{}}) + mgr.GetWebhookServer().Register("/validate-infrastructure-cluster-x-k8s-io-v1beta1-byohost", &webhook.Admission{Handler: &infrastructurev1beta1.ByoHostValidator{}}) //+kubebuilder:scaffold:builder