Skip to content

Commit b976cf5

Browse files
committed
bump CAPI to 1.10.6
1 parent 739c6e7 commit b976cf5

26 files changed

+572
-335
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.22.6 as builder
2+
FROM golang:1.24.3 as builder
33

44
WORKDIR /workspace
55
# Copy the Go Modules manifests

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ $(KUSTOMIZE): ## Download kustomize locally if necessary.
386386
GOBIN=$(BIN_DIR)/ $(GO_INSTALL) sigs.k8s.io/kustomize/kustomize/v4 $(KUSTOMIZE_BIN) v4.5.2
387387

388388
$(GINKGO): ## Build ginkgo.
389-
GOBIN=$(BIN_DIR)/ $(GO_INSTALL) github.com/onsi/ginkgo/v2/ginkgo $(GINKGO_BIN) v2.19.1
389+
GOBIN=$(BIN_DIR)/ $(GO_INSTALL) github.com/onsi/ginkgo/v2/ginkgo $(GINKGO_BIN) v2.23.3
390390

391391
$(GOLANGCI_LINT): ## Build golanci-lint.
392392
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN_DIR) $(GOLANGCI_LINT_VERSION)

Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ settings = {
1919
"deploy_cert_manager": True,
2020
"preload_images_for_kind": True,
2121
"kind_cluster_name": "capoci",
22-
"capi_version": "v1.9.7",
22+
"capi_version": "v1.10.7",
2323
"cert_manager_version": "v1.16.2",
2424
"kubernetes_version": "v1.30.0",
2525
}

api/v1beta2/ocicluster_webhook.go

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package v1beta2
2121

2222
import (
23+
"context"
2324
"fmt"
2425

2526
"github.com/oracle/oci-go-sdk/v65/common"
@@ -34,32 +35,49 @@ import (
3435

3536
var clusterlogger = ctrl.Log.WithName("ocicluster-resource")
3637

38+
type OCIClusterWebhook struct{}
39+
3740
var (
38-
_ webhook.Defaulter = &OCICluster{}
39-
_ webhook.Validator = &OCICluster{}
41+
_ webhook.CustomDefaulter = &OCIClusterWebhook{}
42+
_ webhook.CustomValidator = &OCIClusterWebhook{}
4043
)
4144

4245
// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta2-ocicluster,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=ociclusters,versions=v1beta2,name=validation.ocicluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1
4346
// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta2-ocicluster,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=ociclusters,versions=v1beta2,name=default.ocicluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1
4447

45-
func (c *OCICluster) Default() {
48+
func (*OCIClusterWebhook) Default(_ context.Context, obj runtime.Object) error {
49+
c, ok := obj.(*OCICluster)
50+
if !ok {
51+
return fmt.Errorf("expected an OCICluster object but got %T", c)
52+
}
53+
4654
if c.Spec.OCIResourceIdentifier == "" {
4755
c.Spec.OCIResourceIdentifier = string(uuid.NewUUID())
4856
}
4957
if !c.Spec.NetworkSpec.SkipNetworkManagement {
5058
c.Spec.NetworkSpec.Vcn.Subnets = c.SubnetSpec()
5159
c.Spec.NetworkSpec.Vcn.NetworkSecurityGroup.List = c.NSGSpec()
5260
}
61+
62+
return nil
5363
}
5464

5565
func (c *OCICluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
66+
w := new(OCIClusterWebhook)
5667
return ctrl.NewWebhookManagedBy(mgr).
5768
For(c).
69+
WithDefaulter(w).
70+
WithValidator(w).
5871
Complete()
5972
}
6073

6174
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
62-
func (c *OCICluster) ValidateCreate() (admission.Warnings, error) {
75+
func (*OCIClusterWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
76+
c, ok := obj.(*OCICluster)
77+
if !ok {
78+
return nil, fmt.Errorf("expected an OCICluster object but got %T", c)
79+
}
80+
6381
clusterlogger.Info("validate update cluster", "name", c.Name)
6482

6583
var allErrs field.ErrorList
@@ -155,21 +173,30 @@ func (c *OCICluster) ValidateCreate() (admission.Warnings, error) {
155173
}
156174

157175
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
158-
func (c *OCICluster) ValidateDelete() (admission.Warnings, error) {
176+
func (*OCIClusterWebhook) ValidateDelete(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
177+
c, ok := obj.(*OCICluster)
178+
if !ok {
179+
return nil, fmt.Errorf("expected an OCICluster object but got %T", c)
180+
}
159181
clusterlogger.Info("validate delete cluster", "name", c.Name)
160182

161183
return nil, nil
162184
}
163185

164186
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
165-
func (c *OCICluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
187+
func (*OCIClusterWebhook) ValidateUpdate(_ context.Context, oldRaw, newObj runtime.Object) (admission.Warnings, error) {
188+
c, ok := newObj.(*OCICluster)
189+
if !ok {
190+
return nil, fmt.Errorf("expected an OCICluster object but got %T", c)
191+
}
192+
166193
clusterlogger.Info("validate update cluster", "name", c.Name)
167194

168195
var allErrs field.ErrorList
169196

170-
oldCluster, ok := old.(*OCICluster)
197+
oldCluster, ok := oldRaw.(*OCICluster)
171198
if !ok {
172-
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected an OCICluster but got a %T", old))
199+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected an OCICluster but got a %T", oldRaw))
173200
}
174201

175202
if c.Spec.Region != oldCluster.Spec.Region {

api/v1beta2/ocicluster_webhook_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package v1beta2
2121

2222
import (
23+
"context"
2324
"strings"
2425
"testing"
2526

@@ -482,11 +483,11 @@ func TestOCICluster_ValidateCreate(t *testing.T) {
482483
g := gomega.NewWithT(t)
483484

484485
if test.expectErr {
485-
_, err := test.c.ValidateCreate()
486+
_, err := (&OCIClusterWebhook{}).ValidateCreate(context.Background(), test.c)
486487
g.Expect(err).NotTo(gomega.Succeed())
487488
g.Expect(strings.Contains(err.Error(), test.errorMgsShouldContain)).To(gomega.BeTrue())
488489
} else {
489-
_, err := test.c.ValidateCreate()
490+
_, err := (&OCIClusterWebhook{}).ValidateCreate(context.Background(), test.c)
490491
g.Expect(err).To(gomega.Succeed())
491492
}
492493
})
@@ -606,11 +607,11 @@ func TestOCICluster_ValidateUpdate(t *testing.T) {
606607
g := gomega.NewWithT(t)
607608

608609
if test.expectErr {
609-
_, err := test.c.ValidateUpdate(test.old)
610+
_, err := (&OCIClusterWebhook{}).ValidateUpdate(context.Background(), test.old, test.c)
610611
g.Expect(err).NotTo(gomega.Succeed())
611612
g.Expect(strings.Contains(err.Error(), test.errorMgsShouldContain)).To(gomega.BeTrue())
612613
} else {
613-
_, err := test.c.ValidateUpdate(test.old)
614+
_, err := (&OCIClusterWebhook{}).ValidateUpdate(context.Background(), test.old, test.c)
614615
g.Expect(err).To(gomega.Succeed())
615616
}
616617
})
@@ -783,7 +784,7 @@ func TestOCICluster_CreateDefault(t *testing.T) {
783784
for _, test := range tests {
784785
t.Run(test.name, func(t *testing.T) {
785786
g := gomega.NewWithT(t)
786-
test.c.Default()
787+
(&OCIClusterWebhook{}).Default(context.Background(), test.c)
787788
test.expect(g, test.c)
788789
})
789790
}

api/v1beta2/ocimachinetemplate_webhook.go

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

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

2223
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -27,20 +28,29 @@ import (
2728
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
2829
)
2930

31+
type OCIMachineTemplateWebhook struct{}
32+
3033
var (
31-
_ webhook.Validator = &OCIMachineTemplate{}
34+
_ webhook.CustomValidator = &OCIMachineTemplateWebhook{}
3235
)
3336

3437
// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta2-ocimachinetemplate,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=ocimachinetemplates,versions=v1beta2,name=validation.ocimachinetemplate.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1
3538

3639
func (m *OCIMachineTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
40+
w := new(OCIMachineTemplateWebhook)
3741
return ctrl.NewWebhookManagedBy(mgr).
3842
For(m).
43+
WithValidator(w).
3944
Complete()
4045
}
4146

4247
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
43-
func (m *OCIMachineTemplate) ValidateCreate() (admission.Warnings, error) {
48+
func (*OCIMachineTemplateWebhook) ValidateCreate(_ context.Context, raw runtime.Object) (admission.Warnings, error) {
49+
m, ok := raw.(*OCIMachineTemplate)
50+
if !ok {
51+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a OCIMachineTemplate but got a %T", raw))
52+
}
53+
4454
clusterlogger.Info("validate create machinetemplate", "name", m.Name)
4555

4656
var allErrs field.ErrorList
@@ -55,14 +65,22 @@ func (m *OCIMachineTemplate) ValidateCreate() (admission.Warnings, error) {
5565
}
5666

5767
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
58-
func (m *OCIMachineTemplate) ValidateDelete() (admission.Warnings, error) {
68+
func (*OCIMachineTemplateWebhook) ValidateDelete(_ context.Context, raw runtime.Object) (admission.Warnings, error) {
69+
m, ok := raw.(*OCIMachineTemplate)
70+
if !ok {
71+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a OCIMachineTemplate but got a %T", raw))
72+
}
5973
clusterlogger.Info("validate delete machinetemplate", "name", m.Name)
6074

6175
return nil, nil
6276
}
6377

6478
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
65-
func (m *OCIMachineTemplate) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
79+
func (*OCIMachineTemplateWebhook) ValidateUpdate(ctx context.Context, oldRaw runtime.Object, newRaw runtime.Object) (admission.Warnings, error) {
80+
m, ok := newRaw.(*OCIMachineTemplate)
81+
if !ok {
82+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a OCIMachineTemplate but got a %T", newRaw))
83+
}
6684
clusterlogger.Info("validate update machinetemplate", "name", m.Name)
6785

6886
var allErrs field.ErrorList

api/v1beta2/ocimachinetemplate_webhook_test.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 v1beta2
1818

1919
import (
20+
"context"
2021
"strings"
2122
"testing"
2223

@@ -99,11 +100,11 @@ func TestOCIMachineTemplate_ValidateCreate(t *testing.T) {
99100
g := gomega.NewWithT(t)
100101

101102
if test.expectErr {
102-
_, err := test.inputTemplate.ValidateCreate()
103+
_, err := (&OCIMachineTemplateWebhook{}).ValidateCreate(context.Background(), test.inputTemplate)
103104
g.Expect(err).NotTo(gomega.Succeed())
104105
g.Expect(strings.Contains(err.Error(), test.errorField)).To(gomega.BeTrue())
105106
} else {
106-
_, err := test.inputTemplate.ValidateCreate()
107+
_, err := (&OCIMachineTemplateWebhook{}).ValidateCreate(context.Background(), test.inputTemplate)
107108
g.Expect(err).To(gomega.Succeed())
108109
}
109110
})
@@ -116,11 +117,11 @@ func TestOCIMachineTemplate_ValidateUpdate(t *testing.T) {
116117
g := gomega.NewWithT(t)
117118

118119
if test.expectErr {
119-
_, err := test.inputTemplate.ValidateUpdate(nil)
120+
_, err := (&OCIMachineTemplateWebhook{}).ValidateUpdate(context.Background(), nil, test.inputTemplate)
120121
g.Expect(err).NotTo(gomega.Succeed())
121122
g.Expect(strings.Contains(err.Error(), test.errorField)).To(gomega.BeTrue())
122123
} else {
123-
_, err := test.inputTemplate.ValidateUpdate(nil)
124+
_, err := (&OCIMachineTemplateWebhook{}).ValidateUpdate(context.Background(), nil, test.inputTemplate)
124125
g.Expect(err).To(gomega.Succeed())
125126
}
126127
})

api/v1beta2/ocimanagedcluster_webhook.go

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

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

@@ -32,15 +33,22 @@ import (
3233

3334
var managedclusterlogger = ctrl.Log.WithName("ocimanagedcluster-resource")
3435

36+
type OCIManagedClusterWebhook struct{}
37+
3538
var (
36-
_ webhook.Defaulter = &OCIManagedCluster{}
37-
_ webhook.Validator = &OCIManagedCluster{}
39+
_ webhook.CustomDefaulter = &OCIManagedClusterWebhook{}
40+
_ webhook.CustomValidator = &OCIManagedClusterWebhook{}
3841
)
3942

4043
// +kubebuilder:webhook:verbs=create;update,path=/validate-infrastructure-cluster-x-k8s-io-v1beta2-ocimanagedcluster,mutating=false,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=ocimanagedclusters,versions=v1beta2,name=validation.ocimanagedcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1
4144
// +kubebuilder:webhook:verbs=create;update,path=/mutate-infrastructure-cluster-x-k8s-io-v1beta2-ocimanagedcluster,mutating=true,failurePolicy=fail,matchPolicy=Equivalent,groups=infrastructure.cluster.x-k8s.io,resources=ocimanagedclusters,versions=v1beta2,name=default.ocimanagedcluster.infrastructure.cluster.x-k8s.io,sideEffects=None,admissionReviewVersions=v1beta1
4245

43-
func (c *OCIManagedCluster) Default() {
46+
func (*OCIManagedClusterWebhook) Default(_ context.Context, obj runtime.Object) error {
47+
c, ok := obj.(*OCIManagedCluster)
48+
if !ok {
49+
return fmt.Errorf("expected an OCIManagedCluster object but got %T", c)
50+
}
51+
4452
if c.Spec.OCIResourceIdentifier == "" {
4553
c.Spec.OCIResourceIdentifier = string(uuid.NewUUID())
4654
}
@@ -106,16 +114,25 @@ func (c *OCIManagedCluster) Default() {
106114
c.Spec.NetworkSpec.Vcn.CIDR = VcnDefaultCidr
107115
}
108116
}
117+
118+
return nil
109119
}
110120

111121
func (c *OCIManagedCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
122+
w := new(OCIManagedClusterWebhook)
112123
return ctrl.NewWebhookManagedBy(mgr).
113124
For(c).
125+
WithDefaulter(w).
126+
WithValidator(w).
114127
Complete()
115128
}
116129

117130
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
118-
func (c *OCIManagedCluster) ValidateCreate() (admission.Warnings, error) {
131+
func (*OCIManagedClusterWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
132+
c, ok := obj.(*OCIManagedCluster)
133+
if !ok {
134+
return nil, fmt.Errorf("expected an OCIManagedCluster object but got %T", c)
135+
}
119136
managedclusterlogger.Info("validate create cluster", "name", c.Name)
120137

121138
var allErrs field.ErrorList
@@ -130,21 +147,31 @@ func (c *OCIManagedCluster) ValidateCreate() (admission.Warnings, error) {
130147
}
131148

132149
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
133-
func (c *OCIManagedCluster) ValidateDelete() (admission.Warnings, error) {
150+
func (*OCIManagedClusterWebhook) ValidateDelete(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
151+
c, ok := obj.(*OCIManagedCluster)
152+
if !ok {
153+
return nil, fmt.Errorf("expected an OCIManagedCluster object but got %T", c)
154+
}
155+
134156
managedclusterlogger.Info("validate delete cluster", "name", c.Name)
135157

136158
return nil, nil
137159
}
138160

139161
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
140-
func (c *OCIManagedCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
162+
func (*OCIManagedClusterWebhook) ValidateUpdate(_ context.Context, oldRaw, newObj runtime.Object) (admission.Warnings, error) {
163+
c, ok := newObj.(*OCIManagedCluster)
164+
if !ok {
165+
return nil, fmt.Errorf("expected an OCIManagedCluster object but got %T", c)
166+
}
167+
141168
managedclusterlogger.Info("validate update cluster", "name", c.Name)
142169

143170
var allErrs field.ErrorList
144171

145-
oldCluster, ok := old.(*OCIManagedCluster)
172+
oldCluster, ok := oldRaw.(*OCIManagedCluster)
146173
if !ok {
147-
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected an OCIManagedCluster but got a %T", old))
174+
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected an OCIManagedCluster but got a %T", oldRaw))
148175
}
149176

150177
if c.Spec.Region != oldCluster.Spec.Region {

0 commit comments

Comments
 (0)