Skip to content

Commit d088a2e

Browse files
committed
PCP-5293 Upgrade controller-runtime version to v0.20.4
1 parent 849d5d6 commit d088a2e

File tree

8 files changed

+344
-322
lines changed

8 files changed

+344
-322
lines changed

api/v1beta1/azurecluster_webhook.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"context"
2021
"reflect"
2122

2223
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -39,21 +40,22 @@ func (c *AzureCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
3940
// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azurecluster,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=azureclusters,versions=v1beta1,name=validation.azurecluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
4041
// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-azurecluster,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=azureclusters,versions=v1beta1,name=default.azurecluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
4142

42-
var _ webhook.Validator = &AzureCluster{}
43-
var _ webhook.Defaulter = &AzureCluster{}
43+
var _ webhook.CustomValidator = &AzureCluster{}
44+
var _ webhook.CustomDefaulter = &AzureCluster{}
4445

4546
// Default implements webhook.Defaulter so a webhook will be registered for the type.
46-
func (c *AzureCluster) Default() {
47+
func (c *AzureCluster) Default(ctx context.Context, obj runtime.Object) error {
4748
c.setDefaults()
49+
return nil
4850
}
4951

5052
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
51-
func (c *AzureCluster) ValidateCreate() (admission.Warnings, error) {
53+
func (c *AzureCluster) ValidateCreate(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
5254
return c.validateCluster(nil)
5355
}
5456

5557
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
56-
func (c *AzureCluster) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
58+
func (c *AzureCluster) ValidateUpdate(ctx context.Context, oldRaw runtime.Object, newRaw runtime.Object) (warnings admission.Warnings, err error) {
5759
var allErrs field.ErrorList
5860
old := oldRaw.(*AzureCluster)
5961

@@ -196,6 +198,6 @@ func (c *AzureCluster) validateSubnetUpdate(old *AzureCluster) field.ErrorList {
196198
}
197199

198200
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
199-
func (c *AzureCluster) ValidateDelete() (admission.Warnings, error) {
201+
func (c *AzureCluster) ValidateDelete(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
200202
return nil, nil
201203
}

api/v1beta1/azureclusteridentity_webhook.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"context"
21+
2022
apierrors "k8s.io/apimachinery/pkg/api/errors"
2123
"k8s.io/apimachinery/pkg/runtime"
2224
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -36,15 +38,15 @@ func (c *AzureClusterIdentity) SetupWebhookWithManager(mgr ctrl.Manager) error {
3638

3739
// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azureclusteridentity,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=azureclusteridentities,versions=v1beta1,name=validation.azureclusteridentity.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
3840

39-
var _ webhook.Validator = &AzureClusterIdentity{}
41+
var _ webhook.CustomValidator = &AzureClusterIdentity{}
4042

4143
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
42-
func (c *AzureClusterIdentity) ValidateCreate() (admission.Warnings, error) {
44+
func (c *AzureClusterIdentity) ValidateCreate(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
4345
return c.validateClusterIdentity()
4446
}
4547

4648
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
47-
func (c *AzureClusterIdentity) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
49+
func (c *AzureClusterIdentity) ValidateUpdate(ctx context.Context, oldRaw runtime.Object, newRaw runtime.Object) (warnings admission.Warnings, err error) {
4850
var allErrs field.ErrorList
4951
old := oldRaw.(*AzureClusterIdentity)
5052
if err := webhookutils.ValidateImmutable(
@@ -60,6 +62,6 @@ func (c *AzureClusterIdentity) ValidateUpdate(oldRaw runtime.Object) (admission.
6062
}
6163

6264
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
63-
func (c *AzureClusterIdentity) ValidateDelete() (admission.Warnings, error) {
65+
func (c *AzureClusterIdentity) ValidateDelete(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
6466
return nil, nil
6567
}

api/v1beta1/azureclustertemplate_webhook.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"context"
2021
"reflect"
2122

2223
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -40,22 +41,23 @@ func (c *AzureClusterTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
4041
// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azureclustertemplate,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=azureclustertemplates,versions=v1beta1,name=validation.azureclustertemplate.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
4142
// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta1-azureclustertemplate,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=azureclustertemplates,versions=v1beta1,name=default.azureclustertemplate.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
4243

43-
var _ webhook.Defaulter = &AzureClusterTemplate{}
44+
var _ webhook.CustomDefaulter = &AzureClusterTemplate{}
4445

4546
// Default implements webhook.Defaulter so a webhook will be registered for the type.
46-
func (c *AzureClusterTemplate) Default() {
47+
func (c *AzureClusterTemplate) Default(ctx context.Context, obj runtime.Object) error {
4748
c.setDefaults()
49+
return nil
4850
}
4951

50-
var _ webhook.Validator = &AzureClusterTemplate{}
52+
var _ webhook.CustomValidator = &AzureClusterTemplate{}
5153

5254
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
53-
func (c *AzureClusterTemplate) ValidateCreate() (admission.Warnings, error) {
55+
func (c *AzureClusterTemplate) ValidateCreate(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
5456
return c.validateClusterTemplate()
5557
}
5658

5759
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
58-
func (c *AzureClusterTemplate) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
60+
func (c *AzureClusterTemplate) ValidateUpdate(ctx context.Context, oldRaw runtime.Object, newRaw runtime.Object) (warnings admission.Warnings, err error) {
5961
var allErrs field.ErrorList
6062
old := oldRaw.(*AzureClusterTemplate)
6163
if !reflect.DeepEqual(c.Spec.Template.Spec, old.Spec.Template.Spec) {
@@ -71,6 +73,6 @@ func (c *AzureClusterTemplate) ValidateUpdate(oldRaw runtime.Object) (admission.
7173
}
7274

7375
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
74-
func (c *AzureClusterTemplate) ValidateDelete() (admission.Warnings, error) {
76+
func (c *AzureClusterTemplate) ValidateDelete(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
7577
return nil, nil
7678
}

api/v1beta1/azuremanagedcluster_webhook.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"context"
2021
"k8s.io/apimachinery/pkg/runtime"
2122
ctrl "sigs.k8s.io/controller-runtime"
2223
"sigs.k8s.io/controller-runtime/pkg/webhook"
@@ -32,19 +33,19 @@ func (r *AzureManagedCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
3233

3334
// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azuremanagedcluster,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azuremanagedclusters,versions=v1beta1,name=validation.azuremanagedclusters.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
3435

35-
var _ webhook.Validator = &AzureManagedCluster{}
36+
var _ webhook.CustomValidator = &AzureManagedCluster{}
3637

3738
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
38-
func (r *AzureManagedCluster) ValidateCreate() (admission.Warnings, error) {
39+
func (r *AzureManagedCluster) ValidateCreate(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
3940
return nil, nil
4041
}
4142

4243
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
43-
func (r *AzureManagedCluster) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
44+
func (r *AzureManagedCluster) ValidateUpdate(ctx context.Context, oldObj runtime.Object, newObj runtime.Object) (warnings admission.Warnings, err error) {
4445
return nil, nil
4546
}
4647

4748
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
48-
func (r *AzureManagedCluster) ValidateDelete() (admission.Warnings, error) {
49+
func (r *AzureManagedCluster) ValidateDelete(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
4950
return nil, nil
5051
}

api/v1beta1/azuremanagedclustertemplate_webhook.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"context"
2021
"k8s.io/apimachinery/pkg/runtime"
2122
ctrl "sigs.k8s.io/controller-runtime"
2223
"sigs.k8s.io/controller-runtime/pkg/webhook"
@@ -32,19 +33,19 @@ func (r *AzureManagedClusterTemplate) SetupWebhookWithManager(mgr ctrl.Manager)
3233

3334
// +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
3435

35-
var _ webhook.Validator = &AzureManagedClusterTemplate{}
36+
var _ webhook.CustomValidator = &AzureManagedClusterTemplate{}
3637

3738
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
38-
func (r *AzureManagedClusterTemplate) ValidateCreate() (admission.Warnings, error) {
39+
func (r *AzureManagedClusterTemplate) ValidateCreate(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
3940
return nil, nil
4041
}
4142

4243
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
43-
func (r *AzureManagedClusterTemplate) ValidateUpdate(_ runtime.Object) (admission.Warnings, error) {
44+
func (r *AzureManagedClusterTemplate) ValidateUpdate(ctx context.Context, oldObj runtime.Object, newObj runtime.Object) (warnings admission.Warnings, err error) {
4445
return nil, nil
4546
}
4647

4748
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
48-
func (r *AzureManagedClusterTemplate) ValidateDelete() (admission.Warnings, error) {
49+
func (r *AzureManagedClusterTemplate) ValidateDelete(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
4950
return nil, nil
5051
}

exp/api/v1beta1/azuremachinepoolmachine_webhook.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20+
"context"
21+
2022
"github.com/pkg/errors"
2123
"k8s.io/apimachinery/pkg/runtime"
2224
ctrl "sigs.k8s.io/controller-runtime"
@@ -33,15 +35,15 @@ func (ampm *AzureMachinePoolMachine) SetupWebhookWithManager(mgr ctrl.Manager) e
3335

3436
// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta1-azuremachinepoolmachine,mutating=false,failurePolicy=fail,groups=infrastructure.cluster.x-k8s.io,resources=azuremachinepoolmachines,versions=v1beta1,name=azuremachinepoolmachine.kb.io,sideEffects=None,admissionReviewVersions=v1;v1beta1
3537

36-
var _ webhook.Validator = &AzureMachinePoolMachine{}
38+
var _ webhook.CustomValidator = &AzureMachinePoolMachine{}
3739

3840
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
39-
func (ampm *AzureMachinePoolMachine) ValidateCreate() (admission.Warnings, error) {
41+
func (ampm *AzureMachinePoolMachine) ValidateCreate(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
4042
return nil, nil
4143
}
4244

4345
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
44-
func (ampm *AzureMachinePoolMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
46+
func (ampm *AzureMachinePoolMachine) ValidateUpdate(ctx context.Context, old runtime.Object, new runtime.Object) (warnings admission.Warnings, err error) {
4547
oldMachine, ok := old.(*AzureMachinePoolMachine)
4648
if !ok {
4749
return nil, errors.New("expected and AzureMachinePoolMachine")
@@ -55,6 +57,6 @@ func (ampm *AzureMachinePoolMachine) ValidateUpdate(old runtime.Object) (admissi
5557
}
5658

5759
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
58-
func (ampm *AzureMachinePoolMachine) ValidateDelete() (admission.Warnings, error) {
60+
func (ampm *AzureMachinePoolMachine) ValidateDelete(ctx context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
5961
return nil, nil
6062
}

0 commit comments

Comments
 (0)