Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.25.1 AS builder
FROM golang:1.24.7 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Image URL to use all building/pushing image targets
IMG ?= controller:dev
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.29.5
ENVTEST_K8S_VERSION = 1.34.1

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

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

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

.PHONY: vet
vet: ## Run go vet against code.
Expand Down Expand Up @@ -175,10 +175,12 @@ KUBECTL ?= kubectl
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
GOLANGCI ?= go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
MOCKERY ?= go run github.com/vektra/mockery/v2@v2.53.5

## Tool Versions
KUSTOMIZE_VERSION ?= v5.1.1
CONTROLLER_TOOLS_VERSION ?= v0.16.1
KUSTOMIZE_VERSION ?= v5.7.1
CONTROLLER_TOOLS_VERSION ?= v0.19.0

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

.PHONY: mocks
mocks:
go tool mockery
$(MOCKERY)

# CI

Expand Down Expand Up @@ -256,7 +258,7 @@ release-templates: ## Generate release templates
## CRS
## --------------------------------------

CALICO_VERSION ?= v3.28.2
CALICO_VERSION ?= v3.30.3

.PHONY: crs-calico
crs-calico: ## Generates crs manifests for Calico.
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/ionoscloudmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ type Volume struct {
AvailabilityZone AvailabilityZone `json:"availabilityZone,omitempty"`

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

// ImageSpec defines the image to use for the VM.
// +kubebuilder:validation:ExactlyOneOf=id;selector
type ImageSpec struct {
// ID is the ID of the image to use for the VM. Has precedence over selector.
// ID is the ID of the image to use for the VM.
//
//+optional
ID string `json:"id,omitempty"`
Expand Down
10 changes: 10 additions & 0 deletions api/v1alpha1/ionoscloudmachine_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,16 @@ var _ = Describe("IonosCloudMachine Tests", func() {
Expect(m.Spec.Disk.Image.Selector.UseMachineVersion).ToNot(BeNil())
Expect(*m.Spec.Disk.Image.Selector.UseMachineVersion).To(BeTrue())
})
It("should fail if both ID and selector are set", func() {
m := defaultMachine()
m.Spec.Disk.Image.ID = "1eef-48ec-a246-a51a33aa4f3a"
m.Spec.Disk.Image.Selector = &ImageSelector{
MatchLabels: map[string]string{
"foo": "bar",
},
}
Expect(k8sClient.Create(context.Background(), m)).ToNot(Succeed())
})
})
})
Context("Additional Networks", func() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.1
controller-gen.kubebuilder.io/version: v0.19.0
name: ionoscloudclusters.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.1
controller-gen.kubebuilder.io/version: v0.19.0
name: ionoscloudclustertemplates.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.1
controller-gen.kubebuilder.io/version: v0.19.0
name: ionoscloudmachines.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
Expand Down Expand Up @@ -200,7 +200,6 @@ spec:
properties:
id:
description: ID is the ID of the image to use for the VM.
Has precedence over selector.
type: string
selector:
description: |-
Expand Down Expand Up @@ -234,8 +233,10 @@ spec:
type: object
type: object
x-kubernetes-validations:
- message: must provide either id or selector
rule: self.id != '' || has(self.selector)
- message: exactly one of the fields in [id selector] must be
set
rule: '[has(self.id),has(self.selector)].filter(x,x==true).size()
== 1'
name:
description: Name is the name of the volume
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.1
controller-gen.kubebuilder.io/version: v0.19.0
name: ionoscloudmachinetemplates.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
Expand Down Expand Up @@ -220,7 +220,7 @@ spec:
properties:
id:
description: ID is the ID of the image to use for
the VM. Has precedence over selector.
the VM.
type: string
selector:
description: |-
Expand Down Expand Up @@ -255,8 +255,10 @@ spec:
type: object
type: object
x-kubernetes-validations:
- message: must provide either id or selector
rule: self.id != '' || has(self.selector)
- message: exactly one of the fields in [id selector]
must be set
rule: '[has(self.id),has(self.selector)].filter(x,x==true).size()
== 1'
name:
description: Name is the name of the volume
type: string
Expand Down
Loading