Skip to content

Commit d6e0682

Browse files
✨ Update controller-gen, envtest_k8s_version and kustomize (#323)
**What is the purpose of this pull request/Why do we need it?** Some stuff is quite outdated. I am trying to update everything to make our lives easier in the future (a.k.a. CAPI 1.11) **Issue #, if available:** To be added **Description of changes:** Updating envtest_k8s_version to 1.34, kustomize to v5.7.1 and controller-gen tools to v0.19.0 **Special notes for your reviewer:** **Checklist:** - [ ] Documentation updated - [ ] Unit Tests added - [ ] E2E Tests added - [x] Includes [emojis](https://github.com/kubernetes-sigs/kubebuilder-release-tools?tab=readme-ov-file#kubebuilder-project-versioning)
1 parent e223488 commit d6e0682

11 files changed

+39
-595
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.25.1 AS builder
2+
FROM golang:1.24.7 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

Makefile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Image URL to use all building/pushing image targets
33
IMG ?= controller:dev
44
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5-
ENVTEST_K8S_VERSION = 1.29.5
5+
ENVTEST_K8S_VERSION = 1.34.1
66

77
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
88
ifeq (,$(shell go env GOBIN))
@@ -60,13 +60,13 @@ cover: ## Print the test coverage.
6060

6161
.PHONY: lint
6262
lint: ## Run lint.
63-
go tool golangci-lint run --timeout 5m -c .golangci.yml
63+
$(GOLANGCI) run --timeout 5m -c .golangci.yml
6464

6565
.PHONY: lint-fix
6666
lint-fix: ## Fix linter problems.
6767
# gci collides with gofumpt. But if we run gci before gofumpt, this will solve the issue.
68-
go tool golangci-lint run --timeout 5m -c .golangci.yml --enable-only gci --fix
69-
go tool golangci-lint run --timeout 5m -c .golangci.yml --fix
68+
$(GOLANGCI) run --timeout 5m -c .golangci.yml --enable-only gci --fix
69+
$(GOLANGCI) run --timeout 5m -c .golangci.yml --fix
7070

7171
.PHONY: vet
7272
vet: ## Run go vet against code.
@@ -175,10 +175,12 @@ KUBECTL ?= kubectl
175175
KUSTOMIZE ?= $(LOCALBIN)/kustomize
176176
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
177177
ENVTEST ?= $(LOCALBIN)/setup-envtest
178+
GOLANGCI ?= go run github.com/golangci/golangci-lint/cmd/[email protected]
179+
MOCKERY ?= go run github.com/vektra/mockery/[email protected]
178180

179181
## Tool Versions
180-
KUSTOMIZE_VERSION ?= v5.1.1
181-
CONTROLLER_TOOLS_VERSION ?= v0.16.1
182+
KUSTOMIZE_VERSION ?= v5.7.1
183+
CONTROLLER_TOOLS_VERSION ?= v0.19.0
182184

183185
.PHONY: kustomize
184186
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
@@ -202,7 +204,7 @@ $(ENVTEST): $(LOCALBIN)
202204

203205
.PHONY: mocks
204206
mocks:
205-
go tool mockery
207+
$(MOCKERY)
206208

207209
# CI
208210

@@ -256,7 +258,7 @@ release-templates: ## Generate release templates
256258
## CRS
257259
## --------------------------------------
258260

259-
CALICO_VERSION ?= v3.28.2
261+
CALICO_VERSION ?= v3.30.3
260262

261263
.PHONY: crs-calico
262264
crs-calico: ## Generates crs manifests for Calico.

api/v1alpha1/ionoscloudmachine_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,13 @@ type Volume struct {
234234
AvailabilityZone AvailabilityZone `json:"availabilityZone,omitempty"`
235235

236236
// Image is the image to use for the VM.
237-
//+kubebuilder:validation:XValidation:rule="self.id != '' || has(self.selector)",message="must provide either id or selector"
238237
Image *ImageSpec `json:"image"`
239238
}
240239

241240
// ImageSpec defines the image to use for the VM.
241+
// +kubebuilder:validation:ExactlyOneOf=id;selector
242242
type ImageSpec struct {
243-
// ID is the ID of the image to use for the VM. Has precedence over selector.
243+
// ID is the ID of the image to use for the VM.
244244
//
245245
//+optional
246246
ID string `json:"id,omitempty"`

api/v1alpha1/ionoscloudmachine_types_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,16 @@ var _ = Describe("IonosCloudMachine Tests", func() {
352352
Expect(m.Spec.Disk.Image.Selector.UseMachineVersion).ToNot(BeNil())
353353
Expect(*m.Spec.Disk.Image.Selector.UseMachineVersion).To(BeTrue())
354354
})
355+
It("should fail if both ID and selector are set", func() {
356+
m := defaultMachine()
357+
m.Spec.Disk.Image.ID = "1eef-48ec-a246-a51a33aa4f3a"
358+
m.Spec.Disk.Image.Selector = &ImageSelector{
359+
MatchLabels: map[string]string{
360+
"foo": "bar",
361+
},
362+
}
363+
Expect(k8sClient.Create(context.Background(), m)).ToNot(Succeed())
364+
})
355365
})
356366
})
357367
Context("Additional Networks", func() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.19.0
77
name: ionoscloudclusters.infrastructure.cluster.x-k8s.io
88
spec:
99
group: infrastructure.cluster.x-k8s.io

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.19.0
77
name: ionoscloudclustertemplates.infrastructure.cluster.x-k8s.io
88
spec:
99
group: infrastructure.cluster.x-k8s.io

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.19.0
77
name: ionoscloudmachines.infrastructure.cluster.x-k8s.io
88
spec:
99
group: infrastructure.cluster.x-k8s.io
@@ -200,7 +200,6 @@ spec:
200200
properties:
201201
id:
202202
description: ID is the ID of the image to use for the VM.
203-
Has precedence over selector.
204203
type: string
205204
selector:
206205
description: |-
@@ -234,8 +233,10 @@ spec:
234233
type: object
235234
type: object
236235
x-kubernetes-validations:
237-
- message: must provide either id or selector
238-
rule: self.id != '' || has(self.selector)
236+
- message: exactly one of the fields in [id selector] must be
237+
set
238+
rule: '[has(self.id),has(self.selector)].filter(x,x==true).size()
239+
== 1'
239240
name:
240241
description: Name is the name of the volume
241242
type: string

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.16.1
6+
controller-gen.kubebuilder.io/version: v0.19.0
77
name: ionoscloudmachinetemplates.infrastructure.cluster.x-k8s.io
88
spec:
99
group: infrastructure.cluster.x-k8s.io
@@ -220,7 +220,7 @@ spec:
220220
properties:
221221
id:
222222
description: ID is the ID of the image to use for
223-
the VM. Has precedence over selector.
223+
the VM.
224224
type: string
225225
selector:
226226
description: |-
@@ -255,8 +255,10 @@ spec:
255255
type: object
256256
type: object
257257
x-kubernetes-validations:
258-
- message: must provide either id or selector
259-
rule: self.id != '' || has(self.selector)
258+
- message: exactly one of the fields in [id selector]
259+
must be set
260+
rule: '[has(self.id),has(self.selector)].filter(x,x==true).size()
261+
== 1'
260262
name:
261263
description: Name is the name of the volume
262264
type: string

0 commit comments

Comments
 (0)