@@ -17,6 +17,8 @@ limitations under the License.
1717package v1beta2
1818
1919import (
20+ "context"
21+
2022 "github.com/google/go-cmp/cmp"
2123 apierrors "k8s.io/apimachinery/pkg/api/errors"
2224 "k8s.io/apimachinery/pkg/runtime"
@@ -35,16 +37,17 @@ func (r *AWSClusterTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
3537// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta2-awsclustertemplate,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=awsclustertemplates,versions=v1beta2,name=validation.awsclustertemplate.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
3638// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta2-awsclustertemplate,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=awsclustertemplates,versions=v1beta2,name=default.awsclustertemplate.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
3739
38- var _ webhook.Defaulter = & AWSClusterTemplate {}
39- var _ webhook.Validator = & AWSClusterTemplate {}
40+ var _ webhook.CustomDefaulter = & AWSClusterTemplate {}
41+ var _ webhook.CustomValidator = & AWSClusterTemplate {}
4042
4143// Default implements webhook.Defaulter so a webhook will be registered for the type.
42- func (r * AWSClusterTemplate ) Default () {
44+ func (r * AWSClusterTemplate ) Default (ctx context. Context , obj runtime. Object ) error {
4345 SetObjectDefaults_AWSClusterTemplate (r )
46+ return nil
4447}
4548
4649// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
47- func (r * AWSClusterTemplate ) ValidateCreate () (admission.Warnings , error ) {
50+ func (r * AWSClusterTemplate ) ValidateCreate (ctx context. Context , obj runtime. Object ) (warnings admission.Warnings , err error ) {
4851 var allErrs field.ErrorList
4952
5053 allErrs = append (allErrs , r .Spec .Template .Spec .Bastion .Validate ()... )
@@ -54,7 +57,7 @@ func (r *AWSClusterTemplate) ValidateCreate() (admission.Warnings, error) {
5457}
5558
5659// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
57- func (r * AWSClusterTemplate ) ValidateUpdate (oldRaw runtime.Object ) (admission.Warnings , error ) {
60+ func (r * AWSClusterTemplate ) ValidateUpdate (ctx context. Context , oldRaw runtime.Object , newRaw runtime. Object ) (warnings admission.Warnings , err error ) {
5861 old := oldRaw .(* AWSClusterTemplate )
5962
6063 if ! cmp .Equal (r .Spec , old .Spec ) {
@@ -64,6 +67,6 @@ func (r *AWSClusterTemplate) ValidateUpdate(oldRaw runtime.Object) (admission.Wa
6467}
6568
6669// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
67- func (r * AWSClusterTemplate ) ValidateDelete () (admission.Warnings , error ) {
70+ func (r * AWSClusterTemplate ) ValidateDelete (ctx context. Context , obj runtime. Object ) (warnings admission.Warnings , err error ) {
6871 return nil , nil
6972}
0 commit comments