Skip to content
Draft
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 .golangci-kal.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: "2"
run:
go: "1.25"
go: "1.26"
allow-parallel-runners: true
linters:
default: none
Expand Down
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 AS builder
FROM golang:1.26 AS builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
46 changes: 19 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,15 @@ generate: ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject
--output-file=zz_generated.conversion.go \
./api/v1alpha1

.PHONY: fmt
fmt: ## Run go fmt against code.
## Go maintenance
.PHONY: fix fmt tidy vet
fix:
go fix ./...
fmt:
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code.
tidy:
go mod tidy
vet:
go vet ./...

## Linter Binaries
Expand All @@ -73,7 +76,7 @@ WHAT ?= ./...
LOCALBIN ?= $(shell pwd)/bin

.PHONY: test
test: manifests generate fmt vet ## Run tests. Specify packages to test using WHAT.
test: ## Run tests. Specify packages to test using WHAT.
KUBEBUILDER_ASSETS="$(shell go tool setup-envtest use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $(WHAT) -coverprofile cover.out

.PHONY: mockgen
Expand All @@ -85,10 +88,6 @@ yamlfmt: ## Run yamlfmt against yaml.
go tool yamlfmt -dry -quiet
go tool yamlfmt

.PHONY: tidy
tidy: ## Run go mod tidy to ensure modules are up to date
go mod tidy

##@ Build

.PHONY: build
Expand Down Expand Up @@ -135,24 +134,17 @@ docker-buildx: test ## Build and push Docker image for the manager for cross-pla
##@ verify

.PHONY: verify
verify: verify-modules verify-gen ## verify the manifests and the code.

.PHONY: verify-modules
verify-modules: tidy ## Verify go modules are up to date
@if !(git diff --quiet HEAD -- go.sum go.mod); then \
git diff; \
echo "go module files are out of date"; exit 1; \
fi
@if (find . -name 'go.mod' | xargs -n1 grep -q -i 'k8s.io/client-go.*+incompatible'); then \
find . -name "go.mod" -exec grep -i 'k8s.io/client-go.*+incompatible' {} \; -print; \
echo "go module contains an incompatible client-go version"; exit 1; \
fi

.PHONY: verify-gen
verify-gen: generate manifests mockgen ## Verify go generated files and CRDs are up to date
.NOTPARALLEL: verify
verify: fix fmt generate manifests mockgen tidy vet ## verify the manifests and the code.
@if !(git diff --quiet HEAD); then \
git diff; \
echo "generated files are out of date, run make generate and/or make mockgen"; exit 1; \
echo uncommitted changes: ;\
git diff --name-status HEAD ;\
exit 1 ;\
fi
@if (grep -q 'k8s.io/client-go.*+incompatible' go.mod); then \
echo go.mod contains an incompatible client-go version ;\
grep 'k8s.io/client-go.*+incompatible' go.mod ;\
exit 1 ;\
fi

.PHONY: govulncheck
Expand Down
24 changes: 12 additions & 12 deletions api/v1alpha1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,17 @@ func Convert_v1alpha2_NetworkDevice_To_v1alpha1_NetworkDevice(in *v1alpha2.Netwo
// find IPv4 pool ref
i := getIPPoolRefByIPFamily(in.InterfaceConfig.IPPoolRef, "inet")
if i != -1 {
out.IPPoolConfig.IPv4PoolRef = ptr.To(in.InterfaceConfig.IPPoolRef[i])
out.IPPoolConfig.IPv4PoolRef = new(in.InterfaceConfig.IPPoolRef[i])
}

// find IPv6 pool ref
j := getIPPoolRefByIPFamily(in.InterfaceConfig.IPPoolRef, "inet6")
if j != -1 {
out.IPPoolConfig.IPv6PoolRef = ptr.To(in.InterfaceConfig.IPPoolRef[j])
out.IPPoolConfig.IPv6PoolRef = new(in.InterfaceConfig.IPPoolRef[j])
}

if i == -1 && j == -1 && len(in.InterfaceConfig.IPPoolRef) > 0 {
out.IPPoolConfig.IPv4PoolRef = ptr.To(in.InterfaceConfig.IPPoolRef[0])
out.IPPoolConfig.IPv4PoolRef = new(in.InterfaceConfig.IPPoolRef[0])
}
}

Expand Down Expand Up @@ -200,7 +200,7 @@ func Convert_v1alpha1_ProxmoxClusterStatus_To_v1alpha2_ProxmoxClusterStatus(in *

// Manual conversion: Ready bool → Initialization.Provisioned *bool
if in.Ready {
out.Initialization.Provisioned = ptr.To(true)
out.Initialization.Provisioned = new(true)
}
// FailureReason and FailureMessage are dropped during up-conversion

Expand Down Expand Up @@ -330,8 +330,8 @@ func Convert_v1alpha1_NetworkSpec_To_v1alpha2_NetworkSpec(in *NetworkSpec, out *
if in.Default != nil {
net0 := v1alpha2.NetworkDevice{
Name: v1alpha2.NetName(DefaultNetworkDevice),
DefaultIPv4: ptr.To(true),
DefaultIPv6: ptr.To(true),
DefaultIPv4: new(true),
DefaultIPv6: new(true),
InterfaceConfig: v1alpha2.InterfaceConfig{
IPPoolRef: make([]corev1.TypedLocalObjectReference, 0),
},
Expand Down Expand Up @@ -399,11 +399,11 @@ func Convert_v1alpha1_RouteSpec_To_v1alpha2_RouteSpec(in *RouteSpec, out *v1alph
}

if in.Metric > 0 {
out.Metric = ptr.To(int32(in.Metric))
out.Metric = new(int32(in.Metric))
}

if in.Table > 0 {
out.Table = ptr.To(int32(in.Table))
out.Table = new(int32(in.Table))
}
return nil
}
Expand All @@ -414,7 +414,7 @@ func Convert_v1alpha1_RoutingPolicySpec_To_v1alpha2_RoutingPolicySpec(in *Routin
return err
}
if in.Priority > 0 {
out.Priority = ptr.To(int64(in.Priority))
out.Priority = new(int64(in.Priority))
}
return nil
}
Expand All @@ -427,7 +427,7 @@ func Convert_v1alpha1_ProxmoxMachineStatus_To_v1alpha2_ProxmoxMachineStatus(in *

// Manual conversion: Ready bool → Initialization.Provisioned *bool
if in.Ready {
out.Initialization.Provisioned = ptr.To(true)
out.Initialization.Provisioned = new(true)
}

if in.VMStatus != "" {
Expand Down Expand Up @@ -577,15 +577,15 @@ func Convert_string_To_Pointer_string(in string, hasRestored bool, restoredIn *s
// In all the other cases we do not know if the value was intentionally set to "", so convert to nil.
if in == "" {
if hasRestored && restoredIn != nil && *restoredIn == "" {
*out = ptr.To("")
*out = new("")
return
}
*out = nil
return
}

// Otherwise, if the value is not "", convert to *value.
*out = ptr.To(in)
*out = new(in)
}

// Convert_v1beta1_Condition_To_v1_Condition is the conversion stub required by conversion-gen
Expand Down
27 changes: 13 additions & 14 deletions api/v1alpha1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta1"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
"sigs.k8s.io/randfill"
Expand Down Expand Up @@ -70,8 +69,8 @@ func TestFuzzyConversion(t *testing.T) {
}))
}

func ProxmoxMachineFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
return []interface{}{
func ProxmoxMachineFuzzFuncs(_ runtimeserializer.CodecFactory) []any {
return []any{
fuzzObjectMeta,
fuzzV1beta1Condition,
fuzzMetav1Condition,
Expand Down Expand Up @@ -131,7 +130,7 @@ func hubProxmoxMachineSpec(in *v1alpha2.ProxmoxMachineSpec, c randfill.Continue)
if device.Routing.RoutingPolicy[j].Priority != nil {
val := *device.Routing.RoutingPolicy[j].Priority
if val < 0 || val > 4294967295 {
device.Routing.RoutingPolicy[j].Priority = ptr.To(int64(uint32(val)))
device.Routing.RoutingPolicy[j].Priority = new(int64(uint32(val)))
}
}
}
Expand Down Expand Up @@ -179,7 +178,7 @@ func hubProxmoxMachineSpec(in *v1alpha2.ProxmoxMachineSpec, c randfill.Continue)
if in.Network.VRFs[i].Routing.RoutingPolicy[j].Priority != nil {
val := *in.Network.VRFs[i].Routing.RoutingPolicy[j].Priority
if val < 0 || val > 4294967295 {
in.Network.VRFs[i].Routing.RoutingPolicy[j].Priority = ptr.To(int64(uint32(val)))
in.Network.VRFs[i].Routing.RoutingPolicy[j].Priority = new(int64(uint32(val)))
}
}
}
Expand All @@ -200,8 +199,8 @@ func hubProxmoxMachineSpec(in *v1alpha2.ProxmoxMachineSpec, c randfill.Continue)
}
}

func ProxmoxMachineTemplateFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
return []interface{}{
func ProxmoxMachineTemplateFuzzFuncs(_ runtimeserializer.CodecFactory) []any {
return []any{
fuzzObjectMeta,
hubProxmoxMachineSpec,
spokeProxmoxMachineSpec,
Expand All @@ -213,7 +212,7 @@ func hubProxmoxMachineStatus(in *v1alpha2.ProxmoxMachineStatus, c randfill.Conti

// Initialization.Provisioned: nil → false during hub→spoke→hub (Ready bool defaults to false)
if in.Initialization.Provisioned == nil {
in.Initialization.Provisioned = ptr.To(false)
in.Initialization.Provisioned = new(false)
}

if in.VMStatus != nil && *in.VMStatus == "" {
Expand Down Expand Up @@ -261,7 +260,7 @@ func hubProxmoxMachineStatus(in *v1alpha2.ProxmoxMachineStatus, c randfill.Conti
// Network: nil -> empty slice conversion
for i := range in.Network {
if in.Network[i].Connected == nil {
in.Network[i].Connected = ptr.To(false)
in.Network[i].Connected = new(false)
}
if len(in.Network[i].NetworkName) == 0 {
in.Network[i].NetworkName = v1alpha2.DefaultNetworkDevice
Expand All @@ -273,7 +272,7 @@ func spokeProxmoxMachineSpec(in *ProxmoxMachineSpec, c randfill.Continue) {
c.FillNoCustom(in)

if in.ProviderID == nil {
in.ProviderID = ptr.To("")
in.ProviderID = new("")
}

// DefaultDevice is unconditionally added in conversion, since
Expand Down Expand Up @@ -392,8 +391,8 @@ func ensureIPPoolNaming(cfg *IPPoolConfig) {
}
}

func ProxmoxClusterFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
return []interface{}{
func ProxmoxClusterFuzzFuncs(_ runtimeserializer.CodecFactory) []any {
return []any{
fuzzObjectMeta,
fuzzV1beta1Condition,
fuzzMetav1Condition,
Expand Down Expand Up @@ -498,8 +497,8 @@ func fuzzMetav1Condition(in *metav1.Condition, c randfill.Continue) {
}
}

func ProxmoxClusterTemplateFuzzFuncs(_ runtimeserializer.CodecFactory) []interface{} {
return []interface{}{
func ProxmoxClusterTemplateFuzzFuncs(_ runtimeserializer.CodecFactory) []any {
return []any{
fuzzObjectMeta,
fuzzV1beta1Condition,
fuzzMetav1Condition,
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/proxmoxmachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ func restoreProxmoxMachineSpec(src *ProxmoxMachineSpec, dst *v1alpha2.ProxmoxMac
dst.Network = &v1alpha2.NetworkSpec{
NetworkDevices: []v1alpha2.NetworkDevice{{
Name: v1alpha2.DefaultNetworkDevice,
DefaultIPv4: ptr.To(true),
DefaultIPv6: ptr.To(true),
Bridge: ptr.To("vmbr0"),
DefaultIPv4: new(true),
DefaultIPv6: new(true),
Bridge: new("vmbr0"),
}},
}
}
Expand Down
Loading
Loading