Skip to content

Commit

Permalink
Rename ByoHostValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
anusha94 committed May 2, 2022
1 parent 23ea765 commit af4c42d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions apis/infrastructure/v1beta1/byohost_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
4 changes: 2 additions & 2 deletions apis/infrastructure/v1beta1/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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

Expand Down

0 comments on commit af4c42d

Please sign in to comment.