Skip to content

Commit 2744344

Browse files
committed
fix AzureManagedClusterTemplate webhooks
1 parent 05fcd1e commit 2744344

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

api/v1beta1/azuremanagedclustertemplate_webhook.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,38 @@ import (
2121

2222
"k8s.io/apimachinery/pkg/runtime"
2323
ctrl "sigs.k8s.io/controller-runtime"
24+
"sigs.k8s.io/controller-runtime/pkg/webhook"
2425
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2526
)
2627

2728
// SetupWebhookWithManager sets up and registers the webhook with the manager.
2829
func (r *AzureManagedClusterTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
30+
w := new(azureManagedClusterTemplateWebhook)
2931
return ctrl.NewWebhookManagedBy(mgr).
3032
For(r).
31-
WithValidator(&AzureManagedClusterTemplate{}).
33+
WithValidator(w).
3234
Complete()
3335
}
3436

3537
// +kubebuilder:webhook:verbs=update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azuremanagedclustertemplate,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azuremanagedclustertemplates,versions=v1beta1,name=validation.azuremanagedclustertemplates.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
3638

39+
type azureManagedClusterTemplateWebhook struct{}
40+
41+
var (
42+
_ webhook.CustomValidator = &azureManagedClusterTemplateWebhook{}
43+
)
44+
3745
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
38-
func (r *AzureManagedClusterTemplate) ValidateCreate(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
46+
func (_ *azureManagedClusterTemplateWebhook) ValidateCreate(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
3947
return nil, nil
4048
}
4149

4250
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
43-
func (r *AzureManagedClusterTemplate) ValidateUpdate(_ context.Context, _ runtime.Object, _ runtime.Object) (admission.Warnings, error) {
51+
func (_ *azureManagedClusterTemplateWebhook) ValidateUpdate(_ context.Context, _ runtime.Object, _ runtime.Object) (admission.Warnings, error) {
4452
return nil, nil
4553
}
4654

4755
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
48-
func (r *AzureManagedClusterTemplate) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
56+
func (_ *azureManagedClusterTemplateWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
4957
return nil, nil
5058
}

0 commit comments

Comments
 (0)