Skip to content

Commit 1dce895

Browse files
Fix usage of deprecated webhook.Validator interface
Replace usage of deprecated `webhook.Validator` interface with `admission.CustomValidator`. Signed-off-by: Saeid Askari <saskari@redhat.com>
1 parent 1c017aa commit 1dce895

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

api/v1/policy_webhook.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package v1
55

66
import (
7+
"context"
78
"encoding/json"
89
"errors"
910
"fmt"
@@ -34,10 +35,10 @@ func (r *Policy) SetupWebhookWithManager(mgr ctrl.Manager) error {
3435

3536
//+kubebuilder:webhook:path=/validate-policy-open-cluster-management-io-v1-policy,mutating=false,failurePolicy=Ignore,sideEffects=None,groups=policy.open-cluster-management.io,resources=policies,verbs=create,versions=v1,name=policy.open-cluster-management.io.webhook,admissionReviewVersions=v1
3637

37-
var _ webhook.Validator = &Policy{}
38+
var _ webhook.CustomValidator = &Policy{}
3839

39-
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
40-
func (r *Policy) ValidateCreate() (admission.Warnings, error) {
40+
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type
41+
func (r *Policy) ValidateCreate(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
4142
log := policylog.WithValues("policyName", r.Name, "policyNamespace", r.Namespace)
4243
log.V(1).Info("Validate policy creation request")
4344

@@ -54,8 +55,8 @@ func (r *Policy) ValidateCreate() (admission.Warnings, error) {
5455
return nil, nil
5556
}
5657

57-
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
58-
func (r *Policy) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
58+
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type
59+
func (r *Policy) ValidateUpdate(_ context.Context, _, _ runtime.Object) (admission.Warnings, error) {
5960
log := policylog.WithValues("policyName", r.Name, "policyNamespace", r.Namespace)
6061
log.V(1).Info("Validate policy update request")
6162

@@ -67,8 +68,8 @@ func (r *Policy) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
6768
return nil, nil
6869
}
6970

70-
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
71-
func (r *Policy) ValidateDelete() (admission.Warnings, error) {
71+
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type
72+
func (r *Policy) ValidateDelete(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
7273
return nil, nil
7374
}
7475

0 commit comments

Comments
 (0)