Skip to content

Commit 3625700

Browse files
authored
Merge pull request #5517 from kluster-api/k132
Bump CAPI to v1.10.2
2 parents d9da21b + 8f54b2f commit 3625700

File tree

49 files changed

+752
-607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+752
-607
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ create-management-cluster: $(KUSTOMIZE) $(ENVSUBST) $(KUBECTL) $(KIND) ## Create
333333
./hack/create-custom-cloud-provider-config.sh
334334

335335
# Deploy CAPI
336-
timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.9.6/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done"
336+
timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api/releases/download/v1.10.2/cluster-api-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done"
337337

338338
# Deploy CAAPH
339339
timeout --foreground 300 bash -c "until curl --retry $(CURL_RETRIES) -sSL https://github.com/kubernetes-sigs/cluster-api-addon-provider-helm/releases/download/v0.2.5/addon-components.yaml | $(ENVSUBST) | $(KUBECTL) apply -f -; do sleep 5; done"

Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ settings = {
2222
"deploy_cert_manager": True,
2323
"preload_images_for_kind": True,
2424
"kind_cluster_name": "capz",
25-
"capi_version": "v1.9.6",
25+
"capi_version": "v1.10.2",
2626
"caaph_version": "v0.2.5",
2727
"cert_manager_version": "v1.17.2",
2828
"kubernetes_version": "v1.30.2",

api/v1alpha1/azureasomanagedcluster_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ import (
3131

3232
// SetupAzureASOManagedClusterWebhookWithManager sets up and registers the webhook with the manager.
3333
func SetupAzureASOManagedClusterWebhookWithManager(mgr ctrl.Manager) error {
34-
azureASOManagedClusterWebhook := &azureASOManagedClusterWebhook{}
34+
w := &azureASOManagedClusterWebhook{}
3535
return ctrl.NewWebhookManagedBy(mgr).
3636
For(&AzureASOManagedCluster{}).
37-
WithValidator(azureASOManagedClusterWebhook).
37+
WithValidator(w).
3838
Complete()
3939
}
4040

api/v1alpha1/azureasomanagedcontrolplane_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ import (
3131

3232
// SetupAzureASOManagedControlPlaneWebhookWithManager sets up and registers the webhook with the manager.
3333
func SetupAzureASOManagedControlPlaneWebhookWithManager(mgr ctrl.Manager) error {
34-
azureASOManagedControlPlaneWebhook := &azureASOManagedControlPlaneWebhook{}
34+
w := &azureASOManagedControlPlaneWebhook{}
3535
return ctrl.NewWebhookManagedBy(mgr).
3636
For(&AzureASOManagedControlPlane{}).
37-
WithValidator(azureASOManagedControlPlaneWebhook).
37+
WithValidator(w).
3838
Complete()
3939
}
4040

api/v1alpha1/azureasomanagedmachinepool_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ import (
3131

3232
// SetupAzureASOManagedMachinePoolWebhookWithManager sets up and registers the webhook with the manager.
3333
func SetupAzureASOManagedMachinePoolWebhookWithManager(mgr ctrl.Manager) error {
34-
azureASOManagedMachinePoolWebhook := &azureASOManagedMachinePoolWebhook{}
34+
w := &azureASOManagedMachinePoolWebhook{}
3535
return ctrl.NewWebhookManagedBy(mgr).
3636
For(&AzureASOManagedMachinePool{}).
37-
WithValidator(azureASOManagedMachinePoolWebhook).
37+
WithValidator(w).
3838
Complete()
3939
}
4040

api/v1beta1/azurecluster_webhook.go

Lines changed: 34 additions & 10 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+
"fmt"
2022
"reflect"
2123

2224
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -31,29 +33,51 @@ import (
3133

3234
// SetupWebhookWithManager sets up and registers the webhook with the manager.
3335
func (c *AzureCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
36+
w := new(AzureClusterWebhook)
3437
return ctrl.NewWebhookManagedBy(mgr).
3538
For(c).
39+
WithValidator(w).
40+
WithDefaulter(w).
3641
Complete()
3742
}
3843

3944
// +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
4045
// +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
4146

42-
var _ webhook.Validator = &AzureCluster{}
43-
var _ webhook.Defaulter = &AzureCluster{}
47+
// AzureClusterWebhook implements validating and mutating webhook for AzureCluster.
48+
type AzureClusterWebhook struct{}
49+
50+
var _ webhook.CustomValidator = &AzureClusterWebhook{}
51+
var _ webhook.CustomDefaulter = &AzureClusterWebhook{}
52+
53+
// Default implements webhook.CustomDefaulter so a webhook will be registered for the type.
54+
func (*AzureClusterWebhook) Default(_ context.Context, obj runtime.Object) error {
55+
c, ok := obj.(*AzureCluster)
56+
if !ok {
57+
return fmt.Errorf("expected an AzureCluster object but got %T", c)
58+
}
4459

45-
// Default implements webhook.Defaulter so a webhook will be registered for the type.
46-
func (c *AzureCluster) Default() {
4760
c.setDefaults()
61+
return nil
4862
}
4963

50-
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
51-
func (c *AzureCluster) ValidateCreate() (admission.Warnings, error) {
64+
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type.
65+
func (*AzureClusterWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
66+
c, ok := obj.(*AzureCluster)
67+
if !ok {
68+
return nil, fmt.Errorf("expected an AzureCluster object but got %T", c)
69+
}
70+
5271
return c.validateCluster(nil)
5372
}
5473

55-
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
56-
func (c *AzureCluster) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
74+
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type.
75+
func (*AzureClusterWebhook) ValidateUpdate(_ context.Context, oldRaw, newObj runtime.Object) (admission.Warnings, error) {
76+
c, ok := newObj.(*AzureCluster)
77+
if !ok {
78+
return nil, fmt.Errorf("expected an AzureCluster object but got %T", c)
79+
}
80+
5781
var allErrs field.ErrorList
5882
old := oldRaw.(*AzureCluster)
5983

@@ -195,7 +219,7 @@ func (c *AzureCluster) validateSubnetUpdate(old *AzureCluster) field.ErrorList {
195219
return allErrs
196220
}
197221

198-
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
199-
func (c *AzureCluster) ValidateDelete() (admission.Warnings, error) {
222+
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type.
223+
func (*AzureClusterWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
200224
return nil, nil
201225
}

api/v1beta1/azurecluster_webhook_test.go

Lines changed: 3 additions & 2 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
"testing"
2122

2223
. "github.com/onsi/gomega"
@@ -108,7 +109,7 @@ func TestAzureCluster_ValidateCreate(t *testing.T) {
108109
for _, tc := range tests {
109110
t.Run(tc.name, func(t *testing.T) {
110111
g := NewWithT(t)
111-
_, err := tc.cluster.ValidateCreate()
112+
_, err := (&AzureClusterWebhook{}).ValidateCreate(context.Background(), tc.cluster)
112113
if tc.wantErr {
113114
g.Expect(err).To(HaveOccurred())
114115
} else {
@@ -344,7 +345,7 @@ func TestAzureCluster_ValidateUpdate(t *testing.T) {
344345
t.Run(tc.name, func(t *testing.T) {
345346
t.Parallel()
346347
g := NewWithT(t)
347-
_, err := tc.cluster.ValidateUpdate(tc.oldCluster)
348+
_, err := (&AzureClusterWebhook{}).ValidateUpdate(context.Background(), tc.oldCluster, tc.cluster)
348349
if tc.wantErr {
349350
g.Expect(err).To(HaveOccurred())
350351
} else {

api/v1beta1/azureclusteridentity_webhook.go

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

1919
import (
20+
"context"
21+
"fmt"
22+
2023
apierrors "k8s.io/apimachinery/pkg/api/errors"
2124
"k8s.io/apimachinery/pkg/runtime"
2225
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -29,22 +32,36 @@ import (
2932

3033
// SetupWebhookWithManager sets up and registers the webhook with the manager.
3134
func (c *AzureClusterIdentity) SetupWebhookWithManager(mgr ctrl.Manager) error {
35+
w := new(azureClusterIdentityWebhook)
3236
return ctrl.NewWebhookManagedBy(mgr).
3337
For(c).
38+
WithValidator(w).
3439
Complete()
3540
}
3641

3742
// +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
3843

39-
var _ webhook.Validator = &AzureClusterIdentity{}
44+
type azureClusterIdentityWebhook struct{}
45+
46+
var _ webhook.CustomValidator = &azureClusterIdentityWebhook{}
47+
48+
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type.
49+
func (*azureClusterIdentityWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
50+
c, ok := obj.(*AzureClusterIdentity)
51+
if !ok {
52+
return nil, fmt.Errorf("expected an AzureClusterIdentity object but got %T", c)
53+
}
4054

41-
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
42-
func (c *AzureClusterIdentity) ValidateCreate() (admission.Warnings, error) {
4355
return c.validateClusterIdentity()
4456
}
4557

46-
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
47-
func (c *AzureClusterIdentity) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
58+
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type.
59+
func (*azureClusterIdentityWebhook) ValidateUpdate(_ context.Context, oldRaw, newObj runtime.Object) (admission.Warnings, error) {
60+
c, ok := newObj.(*AzureClusterIdentity)
61+
if !ok {
62+
return nil, fmt.Errorf("expected an AzureClusterIdentity object but got %T", c)
63+
}
64+
4865
var allErrs field.ErrorList
4966
old := oldRaw.(*AzureClusterIdentity)
5067
if err := webhookutils.ValidateImmutable(
@@ -59,7 +76,7 @@ func (c *AzureClusterIdentity) ValidateUpdate(oldRaw runtime.Object) (admission.
5976
return nil, apierrors.NewInvalid(GroupVersion.WithKind(AzureClusterIdentityKind).GroupKind(), c.Name, allErrs)
6077
}
6178

62-
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
63-
func (c *AzureClusterIdentity) ValidateDelete() (admission.Warnings, error) {
79+
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type.
80+
func (*azureClusterIdentityWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
6481
return nil, nil
6582
}

api/v1beta1/azureclusteridentity_webhook_test.go

Lines changed: 3 additions & 2 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
"testing"
2122

2223
. "github.com/onsi/gomega"
@@ -83,7 +84,7 @@ func TestAzureClusterIdentity_ValidateCreate(t *testing.T) {
8384
for _, tc := range tests {
8485
t.Run(tc.name, func(t *testing.T) {
8586
g := NewWithT(t)
86-
_, err := tc.clusterIdentity.ValidateCreate()
87+
_, err := (&azureClusterIdentityWebhook{}).ValidateCreate(context.Background(), tc.clusterIdentity)
8788
if tc.wantErr {
8889
g.Expect(err).To(HaveOccurred())
8990
} else {
@@ -163,7 +164,7 @@ func TestAzureClusterIdentity_ValidateUpdate(t *testing.T) {
163164
for _, tc := range tests {
164165
t.Run(tc.name, func(t *testing.T) {
165166
g := NewWithT(t)
166-
_, err := tc.clusterIdentity.ValidateUpdate(tc.oldClusterIdentity)
167+
_, err := (&azureClusterIdentityWebhook{}).ValidateUpdate(context.Background(), tc.oldClusterIdentity, tc.clusterIdentity)
167168
if tc.wantErr {
168169
g.Expect(err).To(HaveOccurred())
169170
} else {

api/v1beta1/azureclustertemplate_webhook.go

Lines changed: 33 additions & 10 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+
"fmt"
2022
"reflect"
2123

2224
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -32,30 +34,51 @@ const AzureClusterTemplateImmutableMsg = "AzureClusterTemplate spec.template.spe
3234

3335
// SetupWebhookWithManager will set up the webhook to be managed by the specified manager.
3436
func (c *AzureClusterTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
37+
w := new(azureClusterTemplateWebhook)
3538
return ctrl.NewWebhookManagedBy(mgr).
3639
For(c).
40+
WithValidator(w).
41+
WithDefaulter(w).
3742
Complete()
3843
}
3944

4045
// +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
4146
// +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
4247

43-
var _ webhook.Defaulter = &AzureClusterTemplate{}
48+
type azureClusterTemplateWebhook struct{}
49+
50+
var _ webhook.CustomDefaulter = &azureClusterTemplateWebhook{}
51+
52+
// Default implements webhook.CustomDefaulter so a webhook will be registered for the type.
53+
func (*azureClusterTemplateWebhook) Default(_ context.Context, obj runtime.Object) error {
54+
c, ok := obj.(*AzureClusterTemplate)
55+
if !ok {
56+
return fmt.Errorf("expected an AzureClusterTemplate object but got %T", c)
57+
}
4458

45-
// Default implements webhook.Defaulter so a webhook will be registered for the type.
46-
func (c *AzureClusterTemplate) Default() {
4759
c.setDefaults()
60+
return nil
4861
}
4962

50-
var _ webhook.Validator = &AzureClusterTemplate{}
63+
var _ webhook.CustomValidator = &azureClusterTemplateWebhook{}
64+
65+
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type.
66+
func (*azureClusterTemplateWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
67+
c, ok := obj.(*AzureClusterTemplate)
68+
if !ok {
69+
return nil, fmt.Errorf("expected an AzureClusterTemplate object but got %T", c)
70+
}
5171

52-
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
53-
func (c *AzureClusterTemplate) ValidateCreate() (admission.Warnings, error) {
5472
return c.validateClusterTemplate()
5573
}
5674

57-
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
58-
func (c *AzureClusterTemplate) ValidateUpdate(oldRaw runtime.Object) (admission.Warnings, error) {
75+
// ValidateUpdate implements webhook.CustomValidator so a webhook will be registered for the type.
76+
func (*azureClusterTemplateWebhook) ValidateUpdate(_ context.Context, oldRaw, newObj runtime.Object) (admission.Warnings, error) {
77+
c, ok := newObj.(*AzureClusterTemplate)
78+
if !ok {
79+
return nil, fmt.Errorf("expected an AzureClusterTemplate object but got %T", c)
80+
}
81+
5982
var allErrs field.ErrorList
6083
old := oldRaw.(*AzureClusterTemplate)
6184
if !reflect.DeepEqual(c.Spec.Template.Spec, old.Spec.Template.Spec) {
@@ -70,7 +93,7 @@ func (c *AzureClusterTemplate) ValidateUpdate(oldRaw runtime.Object) (admission.
7093
return nil, apierrors.NewInvalid(GroupVersion.WithKind(AzureClusterTemplateKind).GroupKind(), c.Name, allErrs)
7194
}
7295

73-
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
74-
func (c *AzureClusterTemplate) ValidateDelete() (admission.Warnings, error) {
96+
// ValidateDelete implements webhook.CustomValidator so a webhook will be registered for the type.
97+
func (*azureClusterTemplateWebhook) ValidateDelete(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
7598
return nil, nil
7699
}

api/v1beta1/azureclustertemplate_webhook_test.go

Lines changed: 2 additions & 1 deletion
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
"testing"
2122

2223
. "github.com/onsi/gomega"
@@ -57,7 +58,7 @@ func TestValidateUpdate(t *testing.T) {
5758

5859
t.Run("template is immutable", func(t *testing.T) {
5960
g := NewWithT(t)
60-
_, err := newClusterTemplate.ValidateUpdate(oldClusterTemplate)
61+
_, err := (&azureClusterTemplateWebhook{}).ValidateUpdate(context.Background(), oldClusterTemplate, newClusterTemplate)
6162
g.Expect(err).To(HaveOccurred())
6263
})
6364
}

0 commit comments

Comments
 (0)