Skip to content

Commit 0e3b0b9

Browse files
committed
Upgrade CAPI to 1.5
1 parent 505e11b commit 0e3b0b9

25 files changed

+298
-356
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ managers:
9191
manager-cloudstack-infrastructure: ## Build manager binary.
9292
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -ldflags "${LDFLAGS} -extldflags '-static'" -o $(BIN_DIR)/manager .
9393

94-
export K8S_VERSION=1.26.1
94+
export K8S_VERSION=1.28.15
9595
$(KUBECTL) $(API_SERVER) $(ETCD) &:
9696
cd $(TOOLS_DIR) && curl --silent -L "https://go.kubebuilder.io/test-tools/${K8S_VERSION}/$(shell go env GOOS)/$(shell go env GOARCH)" --output - | \
9797
tar -C ./ --strip-components=1 -zvxf -
@@ -244,7 +244,7 @@ delete-kind-cluster:
244244
kind delete cluster --name $(KIND_CLUSTER_NAME)
245245

246246
cluster-api: ## Clone cluster-api repository for tilt use.
247-
git clone --branch v1.4.8 --depth 1 https://github.com/kubernetes-sigs/cluster-api.git
247+
git clone --branch v1.5.8 --depth 1 https://github.com/kubernetes-sigs/cluster-api.git
248248

249249
cluster-api/tilt-settings.json: hack/tilt-settings.json cluster-api
250250
cp ./hack/tilt-settings.json cluster-api

api/v1beta3/cloudstackcluster_webhook.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
ctrl "sigs.k8s.io/controller-runtime"
2828
logf "sigs.k8s.io/controller-runtime/pkg/log"
2929
"sigs.k8s.io/controller-runtime/pkg/webhook"
30+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3031
)
3132

3233
// log is for logging in this package.
@@ -53,7 +54,7 @@ func (r *CloudStackCluster) Default() {
5354
var _ webhook.Validator = &CloudStackCluster{}
5455

5556
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
56-
func (r *CloudStackCluster) ValidateCreate() error {
57+
func (r *CloudStackCluster) ValidateCreate() (admission.Warnings, error) {
5758
cloudstackclusterlog.V(1).Info("entered validate create webhook", "api resource name", r.Name)
5859

5960
var errorList field.ErrorList
@@ -80,18 +81,18 @@ func (r *CloudStackCluster) ValidateCreate() error {
8081
}
8182
}
8283

83-
return webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
84+
return nil, webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
8485
}
8586

8687
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
87-
func (r *CloudStackCluster) ValidateUpdate(old runtime.Object) error {
88+
func (r *CloudStackCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
8889
cloudstackclusterlog.V(1).Info("entered validate update webhook", "api resource name", r.Name)
8990

9091
spec := r.Spec
9192

9293
oldCluster, ok := old.(*CloudStackCluster)
9394
if !ok {
94-
return errors.NewBadRequest(fmt.Sprintf("expected a CloudStackCluster but got a %T", old))
95+
return nil, errors.NewBadRequest(fmt.Sprintf("expected a CloudStackCluster but got a %T", old))
9596
}
9697
oldSpec := oldCluster.Spec
9798

@@ -109,7 +110,7 @@ func (r *CloudStackCluster) ValidateUpdate(old runtime.Object) error {
109110
"controlplaneendpoint.port", errorList)
110111
}
111112

112-
return webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
113+
return nil, webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
113114
}
114115

115116
// ValidateFailureDomainUpdates verifies that at least one failure domain has not been deleted, and
@@ -150,8 +151,8 @@ func FailureDomainsEqual(fd1, fd2 CloudStackFailureDomainSpec) bool {
150151
}
151152

152153
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
153-
func (r *CloudStackCluster) ValidateDelete() error {
154+
func (r *CloudStackCluster) ValidateDelete() (admission.Warnings, error) {
154155
cloudstackclusterlog.V(1).Info("entered validate delete webhook", "api resource name", r.Name)
155156
// No deletion validations. Deletion webhook not enabled.
156-
return nil
157+
return nil, nil
157158
}

api/v1beta3/cloudstackmachine_webhook.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
ctrl "sigs.k8s.io/controller-runtime"
2828
logf "sigs.k8s.io/controller-runtime/pkg/log"
2929
"sigs.k8s.io/controller-runtime/pkg/webhook"
30+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3031
)
3132

3233
// log is for logging in this package.
@@ -53,7 +54,7 @@ func (r *CloudStackMachine) Default() {
5354
var _ webhook.Validator = &CloudStackMachine{}
5455

5556
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
56-
func (r *CloudStackMachine) ValidateCreate() error {
57+
func (r *CloudStackMachine) ValidateCreate() (admission.Warnings, error) {
5758
cloudstackmachinelog.V(1).Info("entered validate create webhook", "api resource name", r.Name)
5859

5960
var errorList field.ErrorList
@@ -64,18 +65,18 @@ func (r *CloudStackMachine) ValidateCreate() error {
6465
errorList = webhookutil.EnsureIntFieldsAreNotNegative(r.Spec.DiskOffering.CustomSize, "customSizeInGB", errorList)
6566
}
6667

67-
return webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
68+
return nil, webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
6869
}
6970

7071
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
71-
func (r *CloudStackMachine) ValidateUpdate(old runtime.Object) error {
72+
func (r *CloudStackMachine) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
7273
cloudstackmachinelog.V(1).Info("entered validate update webhook", "api resource name", r.Name)
7374

7475
var errorList field.ErrorList
7576

7677
oldMachine, ok := old.(*CloudStackMachine)
7778
if !ok {
78-
return errors.NewBadRequest(fmt.Sprintf("expected a CloudStackMachine but got a %T", old))
79+
return nil, errors.NewBadRequest(fmt.Sprintf("expected a CloudStackMachine but got a %T", old))
7980
}
8081
oldSpec := oldMachine.Spec
8182

@@ -98,12 +99,12 @@ func (r *CloudStackMachine) ValidateUpdate(old runtime.Object) error {
9899
errorList = append(errorList, field.Forbidden(field.NewPath("spec", "AffinityGroupIDs"), "AffinityGroupIDs"))
99100
}
100101

101-
return webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
102+
return nil, webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
102103
}
103104

104105
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
105-
func (r *CloudStackMachine) ValidateDelete() error {
106+
func (r *CloudStackMachine) ValidateDelete() (admission.Warnings, error) {
106107
cloudstackmachinelog.V(1).Info("entered validate delete webhook", "api resource name", r.Name)
107108
// No deletion validations. Deletion webhook not enabled.
108-
return nil
109+
return nil, nil
109110
}

api/v1beta3/cloudstackmachinetemplate_webhook.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
ctrl "sigs.k8s.io/controller-runtime"
2929
logf "sigs.k8s.io/controller-runtime/pkg/log"
3030
"sigs.k8s.io/controller-runtime/pkg/webhook"
31+
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3132
)
3233

3334
// log is for logging in this package.
@@ -54,7 +55,7 @@ func (r *CloudStackMachineTemplate) Default() {
5455
var _ webhook.Validator = &CloudStackMachineTemplate{}
5556

5657
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
57-
func (r *CloudStackMachineTemplate) ValidateCreate() error {
58+
func (r *CloudStackMachineTemplate) ValidateCreate() (admission.Warnings, error) {
5859
cloudstackmachinetemplatelog.V(1).Info("entered validate create webhook", "api resource name", r.Name)
5960

6061
var errorList field.ErrorList
@@ -75,16 +76,16 @@ func (r *CloudStackMachineTemplate) ValidateCreate() error {
7576
errorList = webhookutil.EnsureAtLeastOneFieldExists(spec.Offering.ID, spec.Offering.Name, "Offering", errorList)
7677
errorList = webhookutil.EnsureAtLeastOneFieldExists(spec.Template.ID, spec.Template.Name, "Template", errorList)
7778

78-
return webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
79+
return nil, webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
7980
}
8081

8182
// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
82-
func (r *CloudStackMachineTemplate) ValidateUpdate(old runtime.Object) error {
83+
func (r *CloudStackMachineTemplate) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
8384
cloudstackmachinetemplatelog.V(1).Info("entered validate update webhook", "api resource name", r.Name)
8485

8586
oldMachineTemplate, ok := old.(*CloudStackMachineTemplate)
8687
if !ok {
87-
return errors.NewBadRequest(fmt.Sprintf("expected a CloudStackMachineTemplate but got a %T", old))
88+
return nil, errors.NewBadRequest(fmt.Sprintf("expected a CloudStackMachineTemplate but got a %T", old))
8889
}
8990

9091
// CloudStackMachineTemplateSpec.CloudStackMachineTemplateResource.CloudStackMachineSpec
@@ -106,12 +107,12 @@ func (r *CloudStackMachineTemplate) ValidateUpdate(old runtime.Object) error {
106107
errorList = append(errorList, field.Forbidden(field.NewPath("spec", "AffinityGroupIDs"), "AffinityGroupIDs"))
107108
}
108109

109-
return webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
110+
return nil, webhookutil.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
110111
}
111112

112113
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
113-
func (r *CloudStackMachineTemplate) ValidateDelete() error {
114+
func (r *CloudStackMachineTemplate) ValidateDelete() (admission.Warnings, error) {
114115
cloudstackmachinetemplatelog.V(1).Info("entered validate delete webhook", "api resource name", r.Name)
115116
// No deletion validations. Deletion webhook not enabled.
116-
return nil
117+
return nil, nil
117118
}

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackaffinitygroups.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.11.3
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.12.1
87
name: cloudstackaffinitygroups.infrastructure.cluster.x-k8s.io
98
spec:
109
group: infrastructure.cluster.x-k8s.io

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackclusters.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.11.3
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.12.1
87
name: cloudstackclusters.infrastructure.cluster.x-k8s.io
98
spec:
109
group: infrastructure.cluster.x-k8s.io

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackfailuredomains.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.11.3
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.12.1
87
name: cloudstackfailuredomains.infrastructure.cluster.x-k8s.io
98
spec:
109
group: infrastructure.cluster.x-k8s.io

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackisolatednetworks.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.11.3
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.12.1
87
name: cloudstackisolatednetworks.infrastructure.cluster.x-k8s.io
98
spec:
109
group: infrastructure.cluster.x-k8s.io

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackmachines.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.11.3
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.12.1
87
name: cloudstackmachines.infrastructure.cluster.x-k8s.io
98
spec:
109
group: infrastructure.cluster.x-k8s.io

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackmachinestatecheckers.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.11.3
7-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.12.1
87
name: cloudstackmachinestatecheckers.infrastructure.cluster.x-k8s.io
98
spec:
109
group: infrastructure.cluster.x-k8s.io

0 commit comments

Comments
 (0)