From f9b7d3753374d5e616cb3c3ac4e1c7e47bd2bed5 Mon Sep 17 00:00:00 2001 From: Vic Kerr Date: Thu, 9 Apr 2026 14:33:50 +0000 Subject: [PATCH 1/5] build(toolchain): bump go from 1.25 to 1.26 --- .golangci-kal.yml | 2 +- Dockerfile | 2 +- docs/Development.md | 2 +- go.mod | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.golangci-kal.yml b/.golangci-kal.yml index 8570d4201..6210f3fbd 100644 --- a/.golangci-kal.yml +++ b/.golangci-kal.yml @@ -1,6 +1,6 @@ version: "2" run: - go: "1.25" + go: "1.26" allow-parallel-runners: true linters: default: none diff --git a/Dockerfile b/Dockerfile index 843d0fd16..e5efd7782 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.25 AS builder +FROM golang:1.26 AS builder ARG TARGETOS ARG TARGETARCH diff --git a/docs/Development.md b/docs/Development.md index 1c6923784..82f73b262 100644 --- a/docs/Development.md +++ b/docs/Development.md @@ -33,7 +33,7 @@ The following dependencies are required to setup a development environment: - git - make -- Go v1.23 +- Go v1.26 - Kubebuilder (only required for making new controllers) - Docker (required for Kind) - Tilt diff --git a/go.mod b/go.mod index 9686f236c..d38fc0396 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ionos-cloud/cluster-api-provider-proxmox -go 1.25.10 +go 1.26.0 replace ( github.com/golangci/golangci-lint/v2 => github.com/golangci/golangci-lint/v2 v2.9.0 From d9fe7226df4ed83a6704de032812d34b1890bbbd Mon Sep 17 00:00:00 2001 From: Vic Kerr Date: Mon, 20 Apr 2026 15:00:52 +0000 Subject: [PATCH 2/5] go fix ./... Partly fixes #632 --- api/v1alpha1/conversion.go | 24 +-- api/v1alpha1/conversion_test.go | 27 ++- api/v1alpha1/proxmoxmachine_conversion.go | 6 +- api/v1alpha1/proxmoxmachine_types_test.go | 35 ++-- api/v1alpha2/proxmoxcluster_types_test.go | 3 +- api/v1alpha2/proxmoxmachine_types_test.go | 65 ++++---- .../proxmoxcluster_controller_test.go | 6 +- .../service/scheduler/vmscheduler_test.go | 3 +- internal/service/taskservice/task_test.go | 25 ++- internal/service/vmservice/bootstrap.go | 10 +- internal/service/vmservice/bootstrap_test.go | 52 +++--- internal/service/vmservice/delete_test.go | 3 +- internal/service/vmservice/find.go | 3 +- internal/service/vmservice/find_test.go | 27 ++- internal/service/vmservice/helpers_test.go | 14 +- internal/service/vmservice/ip.go | 6 +- internal/service/vmservice/ip_test.go | 53 +++--- internal/service/vmservice/power.go | 3 +- internal/service/vmservice/utils_test.go | 35 ++-- internal/service/vmservice/vm.go | 6 +- internal/service/vmservice/vm_test.go | 155 +++++++++--------- internal/webhook/proxmoxmachine_webhook.go | 5 +- .../webhook/proxmoxmachine_webhook_test.go | 77 +++++---- pkg/cloudinit/network.go | 2 +- pkg/cloudinit/network_test.go | 131 ++++++++------- pkg/consts/consts.go | 3 +- pkg/convert/convert.go | 4 +- pkg/convert/convert_test.go | 9 +- pkg/convert/sentinel.go | 16 +- pkg/convert/status.go | 13 +- pkg/ignition/enrich.go | 19 ++- pkg/ignition/enrich_test.go | 8 +- pkg/ignition/network_test.go | 33 ++-- pkg/kubernetes/ipam/ipam.go | 12 +- pkg/kubernetes/ipam/ipam_test.go | 17 +- pkg/proxmox/goproxmox/api_client.go | 2 +- pkg/proxmox/goproxmox/api_client_test.go | 8 +- pkg/proxmox/logger.go | 8 +- pkg/scope/cluster.go | 3 +- pkg/scope/machine.go | 6 +- pkg/scope/machine_test.go | 9 +- 41 files changed, 461 insertions(+), 485 deletions(-) diff --git a/api/v1alpha1/conversion.go b/api/v1alpha1/conversion.go index 93556e66d..6a38946cd 100644 --- a/api/v1alpha1/conversion.go +++ b/api/v1alpha1/conversion.go @@ -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]) } } @@ -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 @@ -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), }, @@ -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 } @@ -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 } @@ -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 != "" { @@ -577,7 +577,7 @@ 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 @@ -585,7 +585,7 @@ func Convert_string_To_Pointer_string(in string, hasRestored bool, restoredIn *s } // 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 diff --git a/api/v1alpha1/conversion_test.go b/api/v1alpha1/conversion_test.go index 58e7404d1..c9d4eabc4 100644 --- a/api/v1alpha1/conversion_test.go +++ b/api/v1alpha1/conversion_test.go @@ -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" @@ -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, @@ -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))) } } } @@ -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))) } } } @@ -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, @@ -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 == "" { @@ -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 @@ -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 @@ -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, @@ -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, diff --git a/api/v1alpha1/proxmoxmachine_conversion.go b/api/v1alpha1/proxmoxmachine_conversion.go index 381568593..cef5be30c 100644 --- a/api/v1alpha1/proxmoxmachine_conversion.go +++ b/api/v1alpha1/proxmoxmachine_conversion.go @@ -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"), }}, } } diff --git a/api/v1alpha1/proxmoxmachine_types_test.go b/api/v1alpha1/proxmoxmachine_types_test.go index e4286901a..1a4be0086 100644 --- a/api/v1alpha1/proxmoxmachine_types_test.go +++ b/api/v1alpha1/proxmoxmachine_types_test.go @@ -24,7 +24,6 @@ import ( . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" . "github.com/ionos-cloud/cluster-api-provider-proxmox/pkg/consts" @@ -37,12 +36,12 @@ func defaultMachine() *ProxmoxMachine { Namespace: metav1.NamespaceDefault, }, Spec: ProxmoxMachineSpec{ - ProviderID: ptr.To("proxmox://abcdef"), - VirtualMachineID: ptr.To[int64](100), + ProviderID: new("proxmox://abcdef"), + VirtualMachineID: new(int64(100)), VirtualMachineCloneSpec: VirtualMachineCloneSpec{ TemplateSource: TemplateSource{ SourceNode: "pve1", - TemplateID: ptr.To[int32](100), + TemplateID: new(int32(100)), }, }, Disks: &Storage{ @@ -64,16 +63,16 @@ var _ = Describe("ProxmoxMachine Test", func() { Context("VirtualMachineCloneSpec", func() { It("Should not allow specifying format if full clone is disabled", func() { dm := defaultMachine() - dm.Spec.Format = ptr.To(TargetStorageFormatRaw) - dm.Spec.Full = ptr.To(false) + dm.Spec.Format = new(TargetStorageFormatRaw) + dm.Spec.Full = new(false) Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("Must set full=true when specifying format"))) }) It("Should not allow specifying storage if full clone is disabled", func() { dm := defaultMachine() - dm.Spec.Storage = ptr.To("local") - dm.Spec.Full = ptr.To(false) + dm.Spec.Storage = new("local") + dm.Spec.Full = new(false) Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("Must set full=true when specifying storage"))) }) @@ -82,7 +81,7 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Format = nil dm.Spec.Storage = nil - dm.Spec.Full = ptr.To(false) + dm.Spec.Full = new(false) Expect(k8sClient.Create(context.Background(), dm)).Should(Succeed()) }) @@ -202,7 +201,7 @@ var _ = Describe("ProxmoxMachine Test", func() { NetworkDevice: NetworkDevice{ IPPoolConfig: IPPoolConfig{ IPv4PoolRef: &corev1.TypedLocalObjectReference{ - APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + APIGroup: new("ipam.cluster.x-k8s.io"), Kind: InClusterIPPool, Name: "some-pool", }, @@ -225,7 +224,7 @@ var _ = Describe("ProxmoxMachine Test", func() { NetworkDevice: NetworkDevice{ IPPoolConfig: IPPoolConfig{ IPv4PoolRef: &corev1.TypedLocalObjectReference{ - APIGroup: ptr.To("apps"), + APIGroup: new("apps"), Name: "some-app", }, }, @@ -245,7 +244,7 @@ var _ = Describe("ProxmoxMachine Test", func() { NetworkDevice: NetworkDevice{ IPPoolConfig: IPPoolConfig{ IPv4PoolRef: &corev1.TypedLocalObjectReference{ - APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + APIGroup: new("ipam.cluster.x-k8s.io"), Kind: "ConfigMap", Name: "some-app", }, @@ -267,7 +266,7 @@ var _ = Describe("ProxmoxMachine Test", func() { NetworkDevice: NetworkDevice{ IPPoolConfig: IPPoolConfig{ IPv6PoolRef: &corev1.TypedLocalObjectReference{ - APIGroup: ptr.To("apps"), + APIGroup: new("apps"), Name: "some-app", }, }, @@ -288,7 +287,7 @@ var _ = Describe("ProxmoxMachine Test", func() { NetworkDevice: NetworkDevice{ IPPoolConfig: IPPoolConfig{ IPv6PoolRef: &corev1.TypedLocalObjectReference{ - APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + APIGroup: new("ipam.cluster.x-k8s.io"), Kind: "ConfigMap", Name: "some-app", }, @@ -320,7 +319,7 @@ var _ = Describe("ProxmoxMachine Test", func() { dm.Spec.Network = &NetworkSpec{ Default: &NetworkDevice{ Bridge: "vmbr0", - MTU: ptr.To(uint16(0)), + MTU: new(uint16(0)), }, } @@ -332,7 +331,7 @@ var _ = Describe("ProxmoxMachine Test", func() { dm.Spec.Network = &NetworkSpec{ Default: &NetworkDevice{ Bridge: "vmbr0", - MTU: ptr.To(uint16(65521)), + MTU: new(uint16(65521)), }, } @@ -377,7 +376,7 @@ var _ = Describe("ProxmoxMachine Test", func() { dm.Spec.Network = &NetworkSpec{ Default: &NetworkDevice{ Bridge: "vmbr0", - VLAN: ptr.To(uint16(0)), + VLAN: new(uint16(0)), }, } @@ -389,7 +388,7 @@ var _ = Describe("ProxmoxMachine Test", func() { dm.Spec.Network = &NetworkSpec{ Default: &NetworkDevice{ Bridge: "vmbr0", - VLAN: ptr.To(uint16(4095)), + VLAN: new(uint16(4095)), }, } diff --git a/api/v1alpha2/proxmoxcluster_types_test.go b/api/v1alpha2/proxmoxcluster_types_test.go index a87f43fad..01404f34d 100644 --- a/api/v1alpha2/proxmoxcluster_types_test.go +++ b/api/v1alpha2/proxmoxcluster_types_test.go @@ -25,7 +25,6 @@ import ( "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" ipamicv1 "sigs.k8s.io/cluster-api-ipam-provider-in-cluster/api/v1alpha2" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -85,7 +84,7 @@ func defaultCluster() *ProxmoxCluster { Addresses: []string{"10.0.0.0/24"}, Prefix: 24, Gateway: "10.0.0.254", - Metric: ptr.To(int32(123)), + Metric: new(int32(123)), }, DNSServers: []string{"1.2.3.4"}, }, diff --git a/api/v1alpha2/proxmoxmachine_types_test.go b/api/v1alpha2/proxmoxmachine_types_test.go index bfd381845..890a0e3e8 100644 --- a/api/v1alpha2/proxmoxmachine_types_test.go +++ b/api/v1alpha2/proxmoxmachine_types_test.go @@ -24,7 +24,6 @@ import ( . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" . "github.com/ionos-cloud/cluster-api-provider-proxmox/pkg/consts" @@ -38,11 +37,11 @@ func defaultMachine() *ProxmoxMachine { }, Spec: ProxmoxMachineSpec{ ProviderID: "proxmox://a1b2c3d4-e5f6-7890-abcd-ef1234567890", - VirtualMachineID: ptr.To[int64](100), + VirtualMachineID: new(int64(100)), VirtualMachineCloneSpec: VirtualMachineCloneSpec{ TemplateSource: TemplateSource{ - SourceNode: ptr.To("pve1"), - TemplateID: ptr.To[int32](100), + SourceNode: new("pve1"), + TemplateID: new(int32(100)), }, }, Disks: &Storage{ @@ -69,16 +68,16 @@ var _ = Describe("ProxmoxMachine Test", func() { Context("VirtualMachineCloneSpec", func() { It("Should not allow specifying format if full clone is disabled", func() { dm := defaultMachine() - dm.Spec.Format = ptr.To(TargetStorageFormatRaw) - dm.Spec.Full = ptr.To(false) + dm.Spec.Format = new(TargetStorageFormatRaw) + dm.Spec.Full = new(false) Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("Must set full=true when specifying format"))) }) It("Should not allow specifying storage if full clone is disabled", func() { dm := defaultMachine() - dm.Spec.Storage = ptr.To("local") - dm.Spec.Full = ptr.To(false) + dm.Spec.Storage = new("local") + dm.Spec.Full = new(false) Expect(k8sClient.Create(context.Background(), dm)).Should(MatchError(ContainSubstring("Must set full=true when specifying storage"))) }) @@ -87,7 +86,7 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Format = nil dm.Spec.Storage = nil - dm.Spec.Full = ptr.To(false) + dm.Spec.Full = new(false) Expect(k8sClient.Create(context.Background(), dm)).Should(Succeed()) }) @@ -209,7 +208,7 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To(""), + Bridge: new(""), }}, } @@ -221,7 +220,7 @@ var _ = Describe("ProxmoxMachine Test", func() { dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ Name: "asdf", - Bridge: ptr.To("vmbr0"), + Bridge: new("vmbr0"), }}, } @@ -232,12 +231,12 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To("vmbr0"), + Bridge: new("vmbr0"), }, { Name: DefaultNetworkDevice, InterfaceConfig: InterfaceConfig{ IPPoolRef: []corev1.TypedLocalObjectReference{{ - APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + APIGroup: new("ipam.cluster.x-k8s.io"), Kind: InClusterIPPool, Name: "some-pool", }}, @@ -252,11 +251,11 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To("vmbr0"), + Bridge: new("vmbr0"), Name: "net1", InterfaceConfig: InterfaceConfig{ IPPoolRef: []corev1.TypedLocalObjectReference{{ - APIGroup: ptr.To("apps"), + APIGroup: new("apps"), Name: "some-app", }}, }, @@ -269,11 +268,11 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To("vmbr0"), + Bridge: new("vmbr0"), Name: "net1", InterfaceConfig: InterfaceConfig{ IPPoolRef: []corev1.TypedLocalObjectReference{{ - APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + APIGroup: new("ipam.cluster.x-k8s.io"), Kind: "ConfigMap", Name: "some-app", }}, @@ -287,8 +286,8 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To("vmbr0"), - MTU: ptr.To(int32(0)), + Bridge: new("vmbr0"), + MTU: new(int32(0)), }}, } @@ -299,8 +298,8 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To("vmbr0"), - MTU: ptr.To(int32(65521)), + Bridge: new("vmbr0"), + MTU: new(int32(65521)), }}, } @@ -332,7 +331,7 @@ var _ = Describe("ProxmoxMachine Test", func() { Table: 100, Routing: Routing{ RoutingPolicy: []RoutingPolicySpec{{ - Priority: ptr.To(int64(32766)), + Priority: new(int64(32766)), }}, }, }}, @@ -346,8 +345,8 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To("vmbr0"), - VLAN: ptr.To(int32(0)), + Bridge: new("vmbr0"), + VLAN: new(int32(0)), }}, } @@ -358,8 +357,8 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To("vmbr0"), - VLAN: ptr.To(int32(4095)), + Bridge: new("vmbr0"), + VLAN: new(int32(4095)), }}, } @@ -372,8 +371,8 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To("vmbr0"), - Queues: ptr.To(int32(0)), + Bridge: new("vmbr0"), + Queues: new(int32(0)), }}, } @@ -384,8 +383,8 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To("vmbr0"), - Queues: ptr.To(int32(65536)), + Bridge: new("vmbr0"), + Queues: new(int32(65536)), }}, } @@ -396,8 +395,8 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To("vmbr0"), - Queues: ptr.To(int32(4)), + Bridge: new("vmbr0"), + Queues: new(int32(4)), }}, } @@ -408,7 +407,7 @@ var _ = Describe("ProxmoxMachine Test", func() { dm := defaultMachine() dm.Spec.Network = &NetworkSpec{ NetworkDevices: []NetworkDevice{{ - Bridge: ptr.To("vmbr0"), + Bridge: new("vmbr0"), }}, } diff --git a/internal/controller/proxmoxcluster_controller_test.go b/internal/controller/proxmoxcluster_controller_test.go index 0ec18d910..2a960945c 100644 --- a/internal/controller/proxmoxcluster_controller_test.go +++ b/internal/controller/proxmoxcluster_controller_test.go @@ -52,7 +52,7 @@ var _ = Describe("Controller Test", func() { g := NewWithT(GinkgoT()) BeforeEach(func() { - gvk := infrav1.GroupVersion.WithKind(reflect.TypeOf(infrav1.ProxmoxCluster{}).Name()) + gvk := infrav1.GroupVersion.WithKind(reflect.TypeFor[infrav1.ProxmoxCluster]().Name()) cl := &clusterv1.Cluster{ ObjectMeta: metav1.ObjectMeta{ @@ -61,7 +61,7 @@ var _ = Describe("Controller Test", func() { UID: "1000", }, Spec: clusterv1.ClusterSpec{ - Paused: ptr.To(false), + Paused: new(false), InfrastructureRef: clusterv1.ContractVersionedObjectReference{ Kind: gvk.Kind, Name: clusterName, @@ -394,7 +394,7 @@ func dummyIPAddress(client client.Client, owner client.Object, poolName string) Name: poolName, }, Address: "10.10.10.11", - Prefix: ptr.To[int32](24), + Prefix: new(int32(24)), Gateway: "10.10.10.1", }, } diff --git a/internal/service/scheduler/vmscheduler_test.go b/internal/service/scheduler/vmscheduler_test.go index af806dc69..8293b5ab2 100644 --- a/internal/service/scheduler/vmscheduler_test.go +++ b/internal/service/scheduler/vmscheduler_test.go @@ -27,7 +27,6 @@ import ( "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" - "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -210,7 +209,7 @@ func TestScheduleVM(t *testing.T) { }, }, Spec: infrav1.ProxmoxMachineSpec{ - MemoryMiB: ptr.To(int32(10)), + MemoryMiB: new(int32(10)), }, } diff --git a/internal/service/taskservice/task_test.go b/internal/service/taskservice/task_test.go index fd6185ac9..5eecae774 100644 --- a/internal/service/taskservice/task_test.go +++ b/internal/service/taskservice/task_test.go @@ -28,7 +28,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/controller-runtime/pkg/client/fake" @@ -79,7 +78,7 @@ func setupTaskTest(t *testing.T) (*scope.MachineScope, *proxmoxtest.MockClient) Namespace: metav1.NamespaceDefault, }, Spec: infrav1.ProxmoxMachineSpec{ - Network: ptr.To(infrav1.NetworkSpec{}), + Network: new(infrav1.NetworkSpec{}), }, } @@ -135,7 +134,7 @@ func TestGetTask_NoTaskRef(t *testing.T) { // Test missing task erroring. func TestGetTask_ErrorNotFound(t *testing.T) { machineScope, mockClient := setupTaskTest(t) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("UPID:node1:001") + machineScope.ProxmoxMachine.Status.TaskRef = new("UPID:node1:001") mockClient.EXPECT().GetTask(context.Background(), "UPID:node1:001").Return(nil, errors.New("not found")).Once() @@ -147,7 +146,7 @@ func TestGetTask_ErrorNotFound(t *testing.T) { // Test successful task returning. func TestGetTask_Success(t *testing.T) { machineScope, mockClient := setupTaskTest(t) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("UPID:node1:001") + machineScope.ProxmoxMachine.Status.TaskRef = new("UPID:node1:001") expected := &proxmox.Task{UPID: "UPID:node1:001", IsCompleted: true, IsSuccessful: true} mockClient.EXPECT().GetTask(context.Background(), "UPID:node1:001").Return(expected, nil).Once() @@ -170,7 +169,7 @@ func TestReconcileInFlightTask_NoTaskRef(t *testing.T) { // Test ReconcileInFlightTask on empty task but existing TaskRef. func TestReconcileInFlightTask_NilTaskReturned(t *testing.T) { machineScope, mockClient := setupTaskTest(t) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("UPID:node1:001") + machineScope.ProxmoxMachine.Status.TaskRef = new("UPID:node1:001") mockClient.EXPECT().GetTask(context.Background(), "UPID:node1:001").Return(nil, nil).Once() @@ -182,7 +181,7 @@ func TestReconcileInFlightTask_NilTaskReturned(t *testing.T) { // Test ReconcileInflightTask on running task switch case. func TestReconcileInFlightTask_TaskRunning(t *testing.T) { machineScope, mockClient := setupTaskTest(t) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("UPID:node1:001") + machineScope.ProxmoxMachine.Status.TaskRef = new("UPID:node1:001") task := &proxmox.Task{UPID: "UPID:node1:001", IsRunning: true, Status: "running", Type: "qmclone"} mockClient.EXPECT().GetTask(context.Background(), "UPID:node1:001").Return(task, nil).Once() @@ -195,7 +194,7 @@ func TestReconcileInFlightTask_TaskRunning(t *testing.T) { // Test ReconcileInflightTask on successful task switch case. func TestReconcileInFlightTask_TaskSuccessful(t *testing.T) { machineScope, mockClient := setupTaskTest(t) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("UPID:node1:001") + machineScope.ProxmoxMachine.Status.TaskRef = new("UPID:node1:001") task := &proxmox.Task{UPID: "UPID:node1:001", IsCompleted: true, IsSuccessful: true, Status: "stopped", ExitStatus: "OK", Type: "qmclone"} mockClient.EXPECT().GetTask(context.Background(), "UPID:node1:001").Return(task, nil).Once() @@ -209,7 +208,7 @@ func TestReconcileInFlightTask_TaskSuccessful(t *testing.T) { // Test ReconcileInflightTask on task failure switch case if not qmstart. func TestReconcileInFlightTask_CloneTaskFailed(t *testing.T) { machineScope, mockClient := setupTaskTest(t) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("UPID:node1:001") + machineScope.ProxmoxMachine.Status.TaskRef = new("UPID:node1:001") // Set an initial condition to verify it gets overwritten. conditions.Set(machineScope.ProxmoxMachine, metav1.Condition{ @@ -239,7 +238,7 @@ func TestReconcileInFlightTask_CloneTaskFailed(t *testing.T) { // Test ReconcileInflightTask on task failure switch case if qmstart (special case failure). func TestReconcileInFlightTask_TaskFailed_QMStart(t *testing.T) { machineScope, mockClient := setupTaskTest(t) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("UPID:node1:001") + machineScope.ProxmoxMachine.Status.TaskRef = new("UPID:node1:001") // Set a pre-existing condition that should be preserved for qmstart. conditions.Set(machineScope.ProxmoxMachine, metav1.Condition{ @@ -264,7 +263,7 @@ func TestReconcileInFlightTask_TaskFailed_QMStart(t *testing.T) { // Test ReconcileInflightTask on task failure switch case clears timed out task. func TestReconcileInFlightTask_TaskFailed_SecondPass_ClearsTaskRef(t *testing.T) { machineScope, mockClient := setupTaskTest(t) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("UPID:node1:001") + machineScope.ProxmoxMachine.Status.TaskRef = new("UPID:node1:001") // Simulate second reconciliation pass: RetryAfter is already set and expired. machineScope.ProxmoxMachine.Status.RetryAfter = &metav1.Time{Time: time.Now().Add(-1 * time.Minute)} @@ -284,7 +283,7 @@ func TestReconcileInFlightTask_TaskFailed_SecondPass_ClearsTaskRef(t *testing.T) // Test ReconcileInflightTask on invalid task state in go-proxmox. func TestReconcileInFlightTask_TaskFailed_ExitStatusOK(t *testing.T) { machineScope, mockClient := setupTaskTest(t) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("UPID:node1:001") + machineScope.ProxmoxMachine.Status.TaskRef = new("UPID:node1:001") task := &proxmox.Task{UPID: "UPID:node1:001", IsFailed: true, IsCompleted: true, Status: "stopped", ExitStatus: "OK", Type: "qmclone"} mockClient.EXPECT().GetTask(context.Background(), "UPID:node1:001").Return(task, nil).Once() @@ -301,7 +300,7 @@ func TestReconcileInFlightTask_TaskFailed_ExitStatusOK(t *testing.T) { // Test ReconcileInflightTask failed task time-out. func TestReconcileInFlightTask_RetryAfterNotExpired(t *testing.T) { machineScope, mockClient := setupTaskTest(t) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("UPID:node1:001") + machineScope.ProxmoxMachine.Status.TaskRef = new("UPID:node1:001") machineScope.ProxmoxMachine.Status.RetryAfter = &metav1.Time{Time: time.Now().Add(5 * time.Minute)} task := &proxmox.Task{UPID: "UPID:node1:001", IsFailed: true, IsCompleted: true, Status: "stopped", ExitStatus: "ERROR", Type: "qmclone"} @@ -318,7 +317,7 @@ func TestReconcileInFlightTask_RetryAfterNotExpired(t *testing.T) { // Test ReconcileInflightTask unknown state switch case. func TestReconcileInFlightTask_UnknownState(t *testing.T) { machineScope, mockClient := setupTaskTest(t) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("UPID:node1:001") + machineScope.ProxmoxMachine.Status.TaskRef = new("UPID:node1:001") // Task with no state flags set falls through to default case. task := &proxmox.Task{UPID: "UPID:node1:001", ExitStatus: "weird-state", Type: "qmclone"} diff --git a/internal/service/vmservice/bootstrap.go b/internal/service/vmservice/bootstrap.go index c50f690c9..e45c3c508 100644 --- a/internal/service/vmservice/bootstrap.go +++ b/internal/service/vmservice/bootstrap.go @@ -105,7 +105,7 @@ func reconcileBootstrapData(ctx context.Context, machineScope *scope.MachineScop } // Todo: This status field is now superfluous - machineScope.ProxmoxMachine.Status.BootstrapDataProvided = ptr.To(true) + machineScope.ProxmoxMachine.Status.BootstrapDataProvided = new(true) conditions.Set(machineScope.ProxmoxMachine, metav1.Condition{ Type: infrav1.ProxmoxMachineVirtualMachineProvisionedCondition, Status: metav1.ConditionFalse, @@ -120,7 +120,7 @@ func injectCloudInit(ctx context.Context, machineScope *scope.MachineScope, boot network := cloudinit.NewNetworkConfig(nicData) // create metadata renderer - metadata := cloudinit.NewMetadata(biosUUID, machineScope.Name(), kubernetesVersion, *ptr.Deref(machineScope.ProxmoxMachine.Spec.MetadataSettings, infrav1.MetadataSettings{ProviderIDInjection: ptr.To(false)}).ProviderIDInjection) + metadata := cloudinit.NewMetadata(biosUUID, machineScope.Name(), kubernetesVersion, *ptr.Deref(machineScope.ProxmoxMachine.Spec.MetadataSettings, infrav1.MetadataSettings{ProviderIDInjection: new(false)}).ProviderIDInjection) injector := getISOInjector(machineScope.VirtualMachine, bootstrapData, metadata, network) return injector.Inject(ctx, inject.CloudConfigFormat) @@ -128,7 +128,7 @@ func injectCloudInit(ctx context.Context, machineScope *scope.MachineScope, boot func injectIgnition(ctx context.Context, machineScope *scope.MachineScope, bootstrapData []byte, biosUUID string, nicData []types.NetworkConfigData, kubernetesVersion string) error { // create metadata renderer - metadata := cloudinit.NewMetadata(biosUUID, machineScope.Name(), kubernetesVersion, *ptr.Deref(machineScope.ProxmoxMachine.Spec.MetadataSettings, infrav1.MetadataSettings{ProviderIDInjection: ptr.To(false)}).ProviderIDInjection) + metadata := cloudinit.NewMetadata(biosUUID, machineScope.Name(), kubernetesVersion, *ptr.Deref(machineScope.ProxmoxMachine.Spec.MetadataSettings, infrav1.MetadataSettings{ProviderIDInjection: new(false)}).ProviderIDInjection) // create an enricher enricher := &ignition.Enricher{ @@ -294,7 +294,7 @@ func getNetworkDevices(ctx context.Context, machineScope *scope.MachineScope, ne // network devices. for i, nic := range network.NetworkDevices { - var config = ptr.To(types.NetworkConfigData{}) + var config = new(types.NetworkConfigData{}) ipPoolRefs := ipAddressMap[nic.Name] @@ -328,7 +328,7 @@ func getVirtualNetworkDevices(_ context.Context, _ *scope.MachineScope, network networkConfigData := make([]types.NetworkConfigData, 0, len(network.VRFs)) for _, device := range network.VRFs { - var config = ptr.To(types.NetworkConfigData{}) + var config = new(types.NetworkConfigData{}) config.Type = "vrf" config.Name = device.Name config.Table = device.Table diff --git a/internal/service/vmservice/bootstrap_test.go b/internal/service/vmservice/bootstrap_test.go index 998882065..a05662394 100644 --- a/internal/service/vmservice/bootstrap_test.go +++ b/internal/service/vmservice/bootstrap_test.go @@ -47,8 +47,8 @@ const ( ) var defaultNic = infrav1.NetworkDevice{ - Bridge: ptr.To("vmbr0"), - Model: ptr.To("virtio"), + Bridge: new("vmbr0"), + Model: new("virtio"), Name: infrav1.DefaultNetworkDevice, } @@ -94,7 +94,7 @@ func addDefaultIPPool(machineScope *scope.MachineScope, offset ...int) corev1.Ty } // call to add defaultNic addIPPool(machineScope, defaultPool, infrav1.NetName(fmt.Sprintf("net%d", offset[0]))) - machineScope.ProxmoxMachine.Spec.Network.NetworkDevices[offset[0]].DefaultIPv4 = ptr.To(true) + machineScope.ProxmoxMachine.Spec.Network.NetworkDevices[offset[0]].DefaultIPv4 = new(true) setInClusterIPPoolStatus(machineScope, "test-v4-icip", infrav1.IPv4Type, nil) return defaultPool @@ -111,7 +111,7 @@ func addDefaultIPPoolV6(machineScope *scope.MachineScope, offset ...int) corev1. } // call to add defaultNic addIPPool(machineScope, defaultPoolV6, infrav1.NetName(fmt.Sprintf("net%d", offset[0]))) - machineScope.ProxmoxMachine.Spec.Network.NetworkDevices[offset[0]].DefaultIPv6 = ptr.To(true) + machineScope.ProxmoxMachine.Spec.Network.NetworkDevices[offset[0]].DefaultIPv6 = new(true) setInClusterIPPoolStatus(machineScope, "test-v6-icip", infrav1.IPv6Type, nil) return defaultPoolV6 @@ -148,8 +148,8 @@ func addIPPool(machineScope *scope.MachineScope, poolRef corev1.TypedLocalObject if index = slices.IndexFunc(networkDevices, func(e infrav1.NetworkDevice) bool { return reflect.DeepEqual(e.Name, netName) }); index < 0 { index = len(networkDevices) nic := infrav1.NetworkDevice{ - Bridge: ptr.To(fmt.Sprintf("vmbr%d", index)), - Model: ptr.To("virtio"), + Bridge: new(fmt.Sprintf("vmbr%d", index)), + Model: new("virtio"), Name: netName, InterfaceConfig: infrav1.InterfaceConfig{ IPPoolRef: []corev1.TypedLocalObjectReference{}, @@ -293,7 +293,7 @@ func TestGetBootstrapData_MissingSecretName(t *testing.T) { func TestGetBootstrapData_MissingSecretNotName(t *testing.T) { machineScope, _, _ := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedWaitingForBootstrapDataReconciliationReason) - machineScope.Machine.Spec.Bootstrap.DataSecretName = ptr.To("foo") + machineScope.Machine.Spec.Bootstrap.DataSecretName = new("foo") data, _, err := getBootstrapData(context.Background(), machineScope) require.Error(t, err) @@ -304,7 +304,7 @@ func TestGetBootstrapData_MissingSecretNotName(t *testing.T) { func TestGetBootstrapData_MissingSecretValue(t *testing.T) { machineScope, _, client := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedWaitingForBootstrapDataReconciliationReason) - machineScope.Machine.Spec.Bootstrap.DataSecretName = ptr.To(machineScope.Name()) + machineScope.Machine.Spec.Bootstrap.DataSecretName = new(machineScope.Name()) // missing format secret := &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ @@ -358,12 +358,12 @@ func TestGetCommonInterfaceConfig_MissingIPPool(t *testing.T) { NetworkDevices: []infrav1.NetworkDevice{ defaultNic, { - Bridge: ptr.To("vmbr1"), - Model: ptr.To("virtio"), + Bridge: new("vmbr1"), + Model: new("virtio"), Name: "net1", InterfaceConfig: infrav1.InterfaceConfig{ IPPoolRef: []corev1.TypedLocalObjectReference{{ - APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool, Name: "net1-inet", }}, @@ -385,20 +385,20 @@ func TestGetCommonInterfaceConfig(t *testing.T) { machineScope.ProxmoxMachine.Spec.Network = &infrav1.NetworkSpec{ NetworkDevices: []infrav1.NetworkDevice{ { - Bridge: ptr.To("vmbr1"), - Model: ptr.To("virtio"), + Bridge: new("vmbr1"), + Model: new("virtio"), Name: "net1", InterfaceConfig: infrav1.InterfaceConfig{ DNSServers: []string{"1.2.3.4"}, LinkMTU: &MTU, Routing: infrav1.Routing{ Routes: []infrav1.RouteSpec{ - {To: ptr.To("default"), Via: ptr.To("192.168.178.1")}, - {To: ptr.To("172.24.16.0/24"), Via: ptr.To("192.168.178.1"), Table: ptr.To(int32(100))}, + {To: new("default"), Via: new("192.168.178.1")}, + {To: new("172.24.16.0/24"), Via: new("192.168.178.1"), Table: new(int32(100))}, }, RoutingPolicy: []infrav1.RoutingPolicySpec{ - {To: ptr.To("10.10.10.0/24"), Table: ptr.To(int32(100))}, - {From: ptr.To("172.24.16.0/24"), Table: ptr.To(int32(100))}, + {To: new("10.10.10.0/24"), Table: new(int32(100))}, + {From: new("172.24.16.0/24"), Table: new(int32(100))}, }, }, }, @@ -455,9 +455,9 @@ func TestReconcileBootstrapData_DualStack(t *testing.T) { {Name: "test-v6-icip"}, } proxmoxCluster.Status.InClusterZoneRef = []infrav1.InClusterZoneRef{{ - Zone: ptr.To("default"), - InClusterIPPoolRefV4: ptr.To(corev1.LocalObjectReference{Name: "test-v4-icip"}), - InClusterIPPoolRefV6: ptr.To(corev1.LocalObjectReference{Name: "test-v6-icip"}), + Zone: new("default"), + InClusterIPPoolRefV4: new(corev1.LocalObjectReference{Name: "test-v4-icip"}), + InClusterIPPoolRefV6: new(corev1.LocalObjectReference{Name: "test-v6-icip"}), }} require.NoError(t, kubeClient.Status().Update(context.Background(), proxmoxCluster)) @@ -506,9 +506,9 @@ func TestReconcileBootstrapData_DualStack_AdditionalDevices(t *testing.T) { {Name: "test-v6-icip"}, } proxmoxCluster.Status.InClusterZoneRef = []infrav1.InClusterZoneRef{{ - Zone: ptr.To("default"), - InClusterIPPoolRefV4: ptr.To(corev1.LocalObjectReference{Name: "test-v4-icip"}), - InClusterIPPoolRefV6: ptr.To(corev1.LocalObjectReference{Name: "test-v6-icip"}), + Zone: new("default"), + InClusterIPPoolRefV4: new(corev1.LocalObjectReference{Name: "test-v4-icip"}), + InClusterIPPoolRefV6: new(corev1.LocalObjectReference{Name: "test-v6-icip"}), }} require.NoError(t, kubeClient.Status().Update(context.Background(), proxmoxCluster)) @@ -568,9 +568,9 @@ func TestReconcileBootstrapData_DualStack_SplitDefaultGateway(t *testing.T) { {Name: "test-v6-icip"}, } proxmoxCluster.Status.InClusterZoneRef = []infrav1.InClusterZoneRef{{ - Zone: ptr.To("default"), - InClusterIPPoolRefV4: ptr.To(corev1.LocalObjectReference{Name: "test-v4-icip"}), - InClusterIPPoolRefV6: ptr.To(corev1.LocalObjectReference{Name: "test-v6-icip"}), + Zone: new("default"), + InClusterIPPoolRefV4: new(corev1.LocalObjectReference{Name: "test-v4-icip"}), + InClusterIPPoolRefV6: new(corev1.LocalObjectReference{Name: "test-v6-icip"}), }} require.NoError(t, kubeClient.Status().Update(context.Background(), proxmoxCluster)) diff --git a/internal/service/vmservice/delete_test.go b/internal/service/vmservice/delete_test.go index 1b1993ea2..62fb19ba5 100644 --- a/internal/service/vmservice/delete_test.go +++ b/internal/service/vmservice/delete_test.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/ptr" infrav1 "github.com/ionos-cloud/cluster-api-provider-proxmox/api/v1alpha2" ) @@ -31,7 +30,7 @@ import ( func TestDeleteVM_SuccessNotFound(t *testing.T) { machineScope, proxmoxClient, _ := setupReconcilerTest(t) vm := newRunningVM() - machineScope.ProxmoxMachine.Spec.VirtualMachineID = ptr.To(int64(vm.VMID)) + machineScope.ProxmoxMachine.Spec.VirtualMachineID = new(int64(vm.VMID)) machineScope.InfraCluster.ProxmoxCluster.AddNodeLocation(infrav1.NodeLocation{ Machine: corev1.LocalObjectReference{Name: machineScope.Name()}, Node: "node1", diff --git a/internal/service/vmservice/find.go b/internal/service/vmservice/find.go index 2413db000..c8e06cbb2 100644 --- a/internal/service/vmservice/find.go +++ b/internal/service/vmservice/find.go @@ -23,7 +23,6 @@ import ( "github.com/luthermonson/go-proxmox" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/cluster-api/util/conditions" @@ -117,7 +116,7 @@ func updateVMLocation(ctx context.Context, s *scope.MachineScope) error { } // Update the Proxmox node in the status. - s.ProxmoxMachine.Status.ProxmoxNode = ptr.To(vm.Node) + s.ProxmoxMachine.Status.ProxmoxNode = new(vm.Node) // Attempt to update the cluster status updated := s.InfraCluster.ProxmoxCluster.UpdateNodeLocation( diff --git a/internal/service/vmservice/find_test.go b/internal/service/vmservice/find_test.go index 75a664a02..622f6338c 100644 --- a/internal/service/vmservice/find_test.go +++ b/internal/service/vmservice/find_test.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/ptr" infrav1 "github.com/ionos-cloud/cluster-api-provider-proxmox/api/v1alpha2" ) @@ -32,7 +31,7 @@ func TestFindVM_FindByNodeAndID(t *testing.T) { ctx := context.TODO() machineScope, proxmoxClient, _ := setupReconcilerTest(t) vm := newRunningVM() - machineScope.ProxmoxMachine.Spec.VirtualMachineID = ptr.To(int64(vm.VMID)) + machineScope.ProxmoxMachine.Spec.VirtualMachineID = new(int64(vm.VMID)) proxmoxClient.EXPECT().GetVM(ctx, "node1", int64(123)).Return(vm, nil).Once() @@ -44,7 +43,7 @@ func TestFindVM_FindByNodeLocationsAndID(t *testing.T) { ctx := context.TODO() machineScope, proxmoxClient, _ := setupReconcilerTest(t) vm := newRunningVM() - machineScope.ProxmoxMachine.Spec.VirtualMachineID = ptr.To(int64(vm.VMID)) + machineScope.ProxmoxMachine.Spec.VirtualMachineID = new(int64(vm.VMID)) machineScope.InfraCluster.ProxmoxCluster.AddNodeLocation(infrav1.NodeLocation{ Machine: corev1.LocalObjectReference{Name: machineScope.ProxmoxMachine.GetName()}, Node: "node3", @@ -60,8 +59,8 @@ func TestFindVM_NotFound(t *testing.T) { ctx := context.TODO() machineScope, proxmoxClient, _ := setupReconcilerTest(t) vm := newRunningVM() - machineScope.ProxmoxMachine.Spec.VirtualMachineID = ptr.To(int64(vm.VMID)) - machineScope.ProxmoxMachine.Status.ProxmoxNode = ptr.To("node2") + machineScope.ProxmoxMachine.Spec.VirtualMachineID = new(int64(vm.VMID)) + machineScope.ProxmoxMachine.Status.ProxmoxNode = new("node2") proxmoxClient.EXPECT().GetVM(ctx, "node2", int64(123)).Return(nil, errors.New("error")).Once() @@ -81,8 +80,8 @@ func TestFindVM_NotInitialized(t *testing.T) { machineScope, proxmoxClient, _ := setupReconcilerTest(t) vm := newRunningVM() vm.Name = "bar" - machineScope.ProxmoxMachine.Spec.VirtualMachineID = ptr.To(int64(vm.VMID)) - machineScope.ProxmoxMachine.Status.ProxmoxNode = ptr.To("node2") + machineScope.ProxmoxMachine.Spec.VirtualMachineID = new(int64(vm.VMID)) + machineScope.ProxmoxMachine.Status.ProxmoxNode = new("node2") proxmoxClient.EXPECT().GetVM(ctx, "node2", int64(123)).Return(vm, nil).Once() @@ -97,7 +96,7 @@ func TestUpdateVMLocation_MissingName(t *testing.T) { vmr := newVMResource() vmr.Name = "" vm.VirtualMachineConfig.Name = "" - machineScope.ProxmoxMachine.Spec.VirtualMachineID = ptr.To(int64(vm.VMID)) + machineScope.ProxmoxMachine.Spec.VirtualMachineID = new(int64(vm.VMID)) proxmoxClient.EXPECT().FindVMResource(ctx, uint64(123)).Return(vmr, nil).Once() proxmoxClient.EXPECT().GetVM(ctx, "node1", int64(123)).Return(vm, nil).Once() @@ -113,7 +112,7 @@ func TestUpdateVMLocation_NameMismatch(t *testing.T) { name := "foo" vmr.Name = name vm.VirtualMachineConfig.Name = name - machineScope.ProxmoxMachine.Spec.VirtualMachineID = ptr.To(int64(vm.VMID)) + machineScope.ProxmoxMachine.Spec.VirtualMachineID = new(int64(vm.VMID)) proxmoxClient.EXPECT().FindVMResource(ctx, uint64(123)).Return(vmr, nil).Once() proxmoxClient.EXPECT().GetVM(ctx, "node1", int64(123)).Return(vm, nil).Once() @@ -128,8 +127,8 @@ func TestUpdateVMLocation_UpdateNode(t *testing.T) { machineScope, proxmoxClient, _ := setupReconcilerTest(t) vm := newRunningVM() vmr := newVMResource() - machineScope.ProxmoxMachine.Spec.VirtualMachineID = ptr.To(int64(vm.VMID)) - machineScope.ProxmoxMachine.Status.ProxmoxNode = ptr.To("node3") + machineScope.ProxmoxMachine.Spec.VirtualMachineID = new(int64(vm.VMID)) + machineScope.ProxmoxMachine.Status.ProxmoxNode = new("node3") machineScope.InfraCluster.ProxmoxCluster.AddNodeLocation(infrav1.NodeLocation{ Machine: corev1.LocalObjectReference{Name: machineScope.Name()}, Node: "node3", @@ -147,8 +146,8 @@ func TestUpdateVMLocation_WithTask(t *testing.T) { machineScope, _, _ := setupReconcilerTest(t) vm := newRunningVM() - machineScope.ProxmoxMachine.Spec.VirtualMachineID = ptr.To(int64(vm.VMID)) - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To("test-task-uupid") + machineScope.ProxmoxMachine.Spec.VirtualMachineID = new(int64(vm.VMID)) + machineScope.ProxmoxMachine.Status.TaskRef = new("test-task-uupid") require.Error(t, updateVMLocation(context.TODO(), machineScope)) } @@ -161,7 +160,7 @@ func TestUpdateVMLocation_WithoutTaskNameMismatch(t *testing.T) { name := "foo" vmr.Name = name vm.VirtualMachineConfig.Name = name - machineScope.ProxmoxMachine.Spec.VirtualMachineID = ptr.To(int64(vm.VMID)) + machineScope.ProxmoxMachine.Spec.VirtualMachineID = new(int64(vm.VMID)) machineScope.ProxmoxMachine.Status.TaskRef = nil proxmoxClient.EXPECT().FindVMResource(ctx, uint64(123)).Return(vmr, nil).Once() diff --git a/internal/service/vmservice/helpers_test.go b/internal/service/vmservice/helpers_test.go index 12318b892..ab271dffd 100644 --- a/internal/service/vmservice/helpers_test.go +++ b/internal/service/vmservice/helpers_test.go @@ -134,7 +134,7 @@ func setupReconcilerTest(t *testing.T) (*scope.MachineScope, *proxmoxtest.MockCl } infraCluster.Status.InClusterIPPoolRef = []corev1.LocalObjectReference{{Name: ipam.InClusterPoolFormat(infraCluster, nil, infrav1.IPv4Format)}} infraCluster.Status.InClusterZoneRef = []infrav1.InClusterZoneRef{{ - Zone: ptr.To("default"), + Zone: new("default"), InClusterIPPoolRefV4: &corev1.LocalObjectReference{Name: ipam.InClusterPoolFormat(infraCluster, nil, infrav1.IPv4Format)}, }} @@ -154,11 +154,11 @@ func setupReconcilerTest(t *testing.T) (*scope.MachineScope, *proxmoxtest.MockCl }, }, Spec: infrav1.ProxmoxMachineSpec{ - Network: ptr.To(infrav1.NetworkSpec{}), + Network: new(infrav1.NetworkSpec{}), VirtualMachineCloneSpec: infrav1.VirtualMachineCloneSpec{ TemplateSource: infrav1.TemplateSource{ - SourceNode: ptr.To("node1"), - TemplateID: ptr.To[int32](123), + SourceNode: new("node1"), + TemplateID: new(int32(123)), }, }, }, @@ -285,7 +285,7 @@ func createIPAddressResource(t *testing.T, c client.Client, name string, machine }, Spec: ipamv1.IPAddressSpec{ Address: ip.Addr().String(), - Prefix: ptr.To(prefix), + Prefix: new(prefix), Gateway: gateway, PoolRef: poolRef, }, @@ -383,7 +383,7 @@ func createOrUpdateIPPool(t *testing.T, c client.Client, machineScope *scope.Mac poolRef = &corev1.TypedLocalObjectReference{ Name: pool.GetName(), Kind: pool.GetObjectKind().GroupVersionKind().Kind, - APIGroup: ptr.To(pool.GetObjectKind().GroupVersionKind().Group), + APIGroup: new(pool.GetObjectKind().GroupVersionKind().Group), } } @@ -519,7 +519,7 @@ func setInClusterIPPoolStatus(scope *scope.MachineScope, poolName string, ipFami } func createBootstrapSecret(t *testing.T, c client.Client, machineScope *scope.MachineScope, format string) { - machineScope.Machine.Spec.Bootstrap.DataSecretName = ptr.To(machineScope.Name()) + machineScope.Machine.Spec.Bootstrap.DataSecretName = new(machineScope.Name()) data := map[string][]byte{} switch format { case cloudinit.FormatCloudConfig: diff --git a/internal/service/vmservice/ip.go b/internal/service/vmservice/ip.go index 1d8dc2d7b..94414c82d 100644 --- a/internal/service/vmservice/ip.go +++ b/internal/service/vmservice/ip.go @@ -113,7 +113,7 @@ func setVMIPAddressTag(ctx context.Context, machineScope *scope.MachineScope, ip if err != nil { return false, errors.Wrapf(err, "unable to add IP tag to VirtualMachine %s", machineScope.Name()) } - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To(string(t.UPID)) + machineScope.ProxmoxMachine.Status.TaskRef = new(string(t.UPID)) requeue = true } @@ -138,7 +138,7 @@ func findIPAddressGatewayMetric(ctx context.Context, machineScope *scope.Machine if err != nil { return nil, err } - rv = ptr.To(int32(metric)) + rv = new(int32(metric)) } if s, exists := annotations[infrav1.ProxmoxGatewayMetricAnnotation]; exists && len(s) > 0 { @@ -146,7 +146,7 @@ func findIPAddressGatewayMetric(ctx context.Context, machineScope *scope.Machine if err != nil { return nil, err } - rv = ptr.To(int32(metric)) + rv = new(int32(metric)) } return rv, nil diff --git a/internal/service/vmservice/ip_test.go b/internal/service/vmservice/ip_test.go index 194200543..844d1f707 100644 --- a/internal/service/vmservice/ip_test.go +++ b/internal/service/vmservice/ip_test.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/ptr" ipamicv1 "sigs.k8s.io/cluster-api-ipam-provider-in-cluster/api/v1alpha2" "sigs.k8s.io/controller-runtime/pkg/client" @@ -41,7 +40,7 @@ func TestReconcileIPAddresses_CreateDefaultClaim(t *testing.T) { NetworkDevices: []infrav1.NetworkDevice{ { Name: infrav1.DefaultNetworkDevice, - DefaultIPv4: ptr.To(true), + DefaultIPv4: new(true), }, }, } @@ -64,11 +63,11 @@ func TestReconcileIPAddresses_CreateAdditionalClaim(t *testing.T) { machineScope, _, kubeClient := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedWaitingForStaticIPAllocationReason) defaultPool := corev1.TypedLocalObjectReference{ - APIGroup: ptr.To(ipamicv1.GroupVersion.String()), + APIGroup: new(ipamicv1.GroupVersion.String()), Kind: reflect.ValueOf(ipamicv1.InClusterIPPool{}).Type().Name(), Name: getDefaultPoolRefs(machineScope).InClusterIPPoolRefV4.Name, } - extraPool0 := corev1.TypedLocalObjectReference{APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + extraPool0 := corev1.TypedLocalObjectReference{APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool, Name: "extraPool0", } @@ -115,7 +114,7 @@ func TestReconcileIPAddresses_AddIPTag(t *testing.T) { machineScope, proxmoxClient, kubeClient := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedWaitingForStaticIPAllocationReason) defaultPool := corev1.TypedLocalObjectReference{ - APIGroup: ptr.To(ipamicv1.GroupVersion.String()), + APIGroup: new(ipamicv1.GroupVersion.String()), Kind: reflect.ValueOf(ipamicv1.InClusterIPPool{}).Type().Name(), Name: getDefaultPoolRefs(machineScope).InClusterIPPoolRefV4.Name, } @@ -123,7 +122,7 @@ func TestReconcileIPAddresses_AddIPTag(t *testing.T) { NetworkDevices: []infrav1.NetworkDevice{ { Name: infrav1.DefaultNetworkDevice, - DefaultIPv4: ptr.To(true), + DefaultIPv4: new(true), }, }, } @@ -155,11 +154,11 @@ func TestReconcileIPAddresses_SetIPAddresses(t *testing.T) { machineScope, _, kubeClient := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedWaitingForStaticIPAllocationReason) defaultPool := corev1.TypedLocalObjectReference{ - APIGroup: ptr.To(ipamicv1.GroupVersion.String()), + APIGroup: new(ipamicv1.GroupVersion.String()), Kind: reflect.ValueOf(ipamicv1.InClusterIPPool{}).Type().Name(), Name: getDefaultPoolRefs(machineScope).InClusterIPPoolRefV4.Name, } - extraPool0 := corev1.TypedLocalObjectReference{APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + extraPool0 := corev1.TypedLocalObjectReference{APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool, Name: "extraPool0", } @@ -168,7 +167,7 @@ func TestReconcileIPAddresses_SetIPAddresses(t *testing.T) { NetworkDevices: []infrav1.NetworkDevice{ { Name: infrav1.DefaultNetworkDevice, - DefaultIPv4: ptr.To(true), + DefaultIPv4: new(true), }, { Name: "net1", @@ -212,19 +211,19 @@ func TestReconcileIPAddresses_MultipleDevices(t *testing.T) { machineScope, _, kubeClient := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedWaitingForStaticIPAllocationReason) defaultPool := corev1.TypedLocalObjectReference{ - APIGroup: ptr.To(ipamicv1.GroupVersion.String()), + APIGroup: new(ipamicv1.GroupVersion.String()), Kind: reflect.ValueOf(ipamicv1.InClusterIPPool{}).Type().Name(), Name: getDefaultPoolRefs(machineScope).InClusterIPPoolRefV4.Name, } - ipv4pool0 := corev1.TypedLocalObjectReference{APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + ipv4pool0 := corev1.TypedLocalObjectReference{APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool, Name: "ipv4pool0", } - ipv4pool1 := corev1.TypedLocalObjectReference{APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + ipv4pool1 := corev1.TypedLocalObjectReference{APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool, Name: "ipv4pool1", } - ipv6pool := corev1.TypedLocalObjectReference{APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + ipv6pool := corev1.TypedLocalObjectReference{APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool, Name: "ipv6pool", } @@ -233,7 +232,7 @@ func TestReconcileIPAddresses_MultipleDevices(t *testing.T) { NetworkDevices: []infrav1.NetworkDevice{ { Name: infrav1.DefaultNetworkDevice, - DefaultIPv4: ptr.To(true), + DefaultIPv4: new(true), InterfaceConfig: infrav1.InterfaceConfig{IPPoolRef: []corev1.TypedLocalObjectReference{ipv4pool0}}, }, { @@ -306,9 +305,9 @@ func TestReconcileIPAddresses_IPv6(t *testing.T) { {Name: "test-v6-icip"}, } proxmoxCluster.Status.InClusterZoneRef = []infrav1.InClusterZoneRef{{ - Zone: ptr.To("default"), - InClusterIPPoolRefV4: ptr.To(corev1.LocalObjectReference{Name: "test-v4-icip"}), - InClusterIPPoolRefV6: ptr.To(corev1.LocalObjectReference{Name: "test-v6-icip"}), + Zone: new("default"), + InClusterIPPoolRefV4: new(corev1.LocalObjectReference{Name: "test-v4-icip"}), + InClusterIPPoolRefV6: new(corev1.LocalObjectReference{Name: "test-v6-icip"}), }} require.NoError(t, kubeClient.Status().Patch(context.Background(), proxmoxCluster, patch)) @@ -316,15 +315,15 @@ func TestReconcileIPAddresses_IPv6(t *testing.T) { require.NoError(t, machineScope.IPAMHelper.CreateOrUpdateInClusterIPPool(context.Background())) defaultPool := corev1.TypedLocalObjectReference{ - APIGroup: ptr.To(ipamicv1.GroupVersion.String()), + APIGroup: new(ipamicv1.GroupVersion.String()), Kind: reflect.ValueOf(ipamicv1.InClusterIPPool{}).Type().Name(), Name: getDefaultPoolRefs(machineScope).InClusterIPPoolRefV4.Name, } - defaultPoolV6 := corev1.TypedLocalObjectReference{APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + defaultPoolV6 := corev1.TypedLocalObjectReference{APIGroup: new("ipam.cluster.x-k8s.io"), Kind: InClusterIPPool, Name: getDefaultPoolRefs(machineScope).InClusterIPPoolRefV6.Name, } - extraPool0 := corev1.TypedLocalObjectReference{APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + extraPool0 := corev1.TypedLocalObjectReference{APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool, Name: "extrapool0", } @@ -333,8 +332,8 @@ func TestReconcileIPAddresses_IPv6(t *testing.T) { NetworkDevices: []infrav1.NetworkDevice{ { Name: infrav1.DefaultNetworkDevice, - DefaultIPv4: ptr.To(true), - DefaultIPv6: ptr.To(true), + DefaultIPv4: new(true), + DefaultIPv6: new(true), }, { Name: "net1", @@ -379,19 +378,19 @@ func TestReconcileIPAddresses_MachineIPPoolRef(t *testing.T) { machineScope, _, kubeClient := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedWaitingForStaticIPAllocationReason) defaultPool := corev1.TypedLocalObjectReference{ - APIGroup: ptr.To(ipamicv1.GroupVersion.String()), + APIGroup: new(ipamicv1.GroupVersion.String()), Kind: reflect.ValueOf(ipamicv1.InClusterIPPool{}).Type().Name(), Name: getDefaultPoolRefs(machineScope).InClusterIPPoolRefV4.Name, } - extraPool0 := corev1.TypedLocalObjectReference{APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + extraPool0 := corev1.TypedLocalObjectReference{APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool, Name: "extrapool0", } - extraPool1 := corev1.TypedLocalObjectReference{APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + extraPool1 := corev1.TypedLocalObjectReference{APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool, Name: "extrapool1", } - extraPool2 := corev1.TypedLocalObjectReference{APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + extraPool2 := corev1.TypedLocalObjectReference{APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool, Name: "extrapool2", } @@ -400,7 +399,7 @@ func TestReconcileIPAddresses_MachineIPPoolRef(t *testing.T) { NetworkDevices: []infrav1.NetworkDevice{ { Name: "net0", - DefaultIPv4: ptr.To(true), + DefaultIPv4: new(true), InterfaceConfig: infrav1.InterfaceConfig{IPPoolRef: []corev1.TypedLocalObjectReference{extraPool0, extraPool0}}, }, { diff --git a/internal/service/vmservice/power.go b/internal/service/vmservice/power.go index 0bbd557f9..152f106bb 100644 --- a/internal/service/vmservice/power.go +++ b/internal/service/vmservice/power.go @@ -22,7 +22,6 @@ import ( "github.com/luthermonson/go-proxmox" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" "sigs.k8s.io/cluster-api/util/conditions" infrav1 "github.com/ionos-cloud/cluster-api-provider-proxmox/api/v1alpha2" @@ -50,7 +49,7 @@ func reconcilePowerState(ctx context.Context, machineScope *scope.MachineScope) } if t != nil { - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To(string(t.UPID)) + machineScope.ProxmoxMachine.Status.TaskRef = new(string(t.UPID)) return true, nil } diff --git a/internal/service/vmservice/utils_test.go b/internal/service/vmservice/utils_test.go index d024bb72b..b4c2e9a14 100644 --- a/internal/service/vmservice/utils_test.go +++ b/internal/service/vmservice/utils_test.go @@ -20,7 +20,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "k8s.io/utils/ptr" infrav1 "github.com/ionos-cloud/cluster-api-provider-proxmox/api/v1alpha2" ) @@ -167,7 +166,7 @@ func TestShouldUpdateNetworkDevices_NoNetworkConfig(t *testing.T) { func TestShouldUpdateNetworkDevices_MissingDefaultDeviceOnVM(t *testing.T) { machineScope, _, _ := setupReconcilerTest(t) machineScope.ProxmoxMachine.Spec.Network = &infrav1.NetworkSpec{ - NetworkDevices: []infrav1.NetworkDevice{{Bridge: ptr.To("vmbr1"), Model: ptr.To("virtio")}}, + NetworkDevices: []infrav1.NetworkDevice{{Bridge: new("vmbr1"), Model: new("virtio")}}, } machineScope.SetVirtualMachine(newStoppedVM()) @@ -177,7 +176,7 @@ func TestShouldUpdateNetworkDevices_MissingDefaultDeviceOnVM(t *testing.T) { func TestShouldUpdateNetworkDevices_DefaultDeviceNeedsUpdate(t *testing.T) { machineScope, _, _ := setupReconcilerTest(t) machineScope.ProxmoxMachine.Spec.Network = &infrav1.NetworkSpec{ - NetworkDevices: []infrav1.NetworkDevice{{Bridge: ptr.To("vmbr1"), Model: ptr.To("virtio")}}, + NetworkDevices: []infrav1.NetworkDevice{{Bridge: new("vmbr1"), Model: new("virtio")}}, } machineScope.SetVirtualMachine(newVMWithNets("virtio=A6:23:64:4D:84:CB,bridge=vmbr0")) @@ -190,8 +189,8 @@ func TestShouldUpdateNetworkDevices_MissingAdditionalDeviceOnVM(t *testing.T) { NetworkDevices: []infrav1.NetworkDevice{ { Name: "net1", - Bridge: ptr.To("vmbr1"), - Model: ptr.To("virtio"), + Bridge: new("vmbr1"), + Model: new("virtio"), }, }, } @@ -206,8 +205,8 @@ func TestShouldUpdateNetworkDevices_AdditionalDeviceNeedsUpdate(t *testing.T) { NetworkDevices: []infrav1.NetworkDevice{ { Name: "net1", - Bridge: ptr.To("vmbr1"), - Model: ptr.To("virtio"), + Bridge: new("vmbr1"), + Model: new("virtio"), }, }, } @@ -221,15 +220,15 @@ func TestShouldUpdateNetworkDevices_NoUpdate(t *testing.T) { machineScope.ProxmoxMachine.Spec.Network = &infrav1.NetworkSpec{ NetworkDevices: []infrav1.NetworkDevice{ { - Bridge: ptr.To("vmbr0"), - Model: ptr.To("virtio"), - MTU: ptr.To[int32](1500), + Bridge: new("vmbr0"), + Model: new("virtio"), + MTU: new(int32(1500)), }, { Name: "net1", - Bridge: ptr.To("vmbr1"), - Model: ptr.To("virtio"), - MTU: ptr.To[int32](1500), + Bridge: new("vmbr1"), + Model: new("virtio"), + MTU: new(int32(1500)), }, }, } @@ -274,7 +273,7 @@ func TestExtractNetworkVLAN(t *testing.T) { func TestShouldUpdateNetworkDevices_VLANChanged(t *testing.T) { machineScope, _, _ := setupReconcilerTest(t) machineScope.ProxmoxMachine.Spec.Network = &infrav1.NetworkSpec{ - NetworkDevices: []infrav1.NetworkDevice{{Bridge: ptr.To("vmbr0"), Model: ptr.To("virtio"), VLAN: ptr.To(int32(100))}}, + NetworkDevices: []infrav1.NetworkDevice{{Bridge: new("vmbr0"), Model: new("virtio"), VLAN: new(int32(100))}}, } machineScope.SetVirtualMachine(newVMWithNets("virtio=A6:23:64:4D:84:CB,bridge=vmbr0,tag=101")) @@ -315,10 +314,10 @@ func TestExtractNetworkQueue(t *testing.T) { func TestFormatNetworkDevice(t *testing.T) { require.Equal(t, "virtio,bridge=vmbr0", formatNetworkDevice("virtio", "vmbr0", nil, nil, nil)) - require.Equal(t, "virtio,bridge=vmbr0,mtu=1500", formatNetworkDevice("virtio", "vmbr0", ptr.To(int32(1500)), nil, nil)) - require.Equal(t, "virtio,bridge=vmbr0,tag=100", formatNetworkDevice("virtio", "vmbr0", nil, ptr.To(int32(100)), nil)) - require.Equal(t, "virtio,bridge=vmbr0,queues=4", formatNetworkDevice("virtio", "vmbr0", nil, nil, ptr.To(int32(4)))) - require.Equal(t, "virtio,bridge=vmbr0,mtu=1500,tag=100,queues=4", formatNetworkDevice("virtio", "vmbr0", ptr.To(int32(1500)), ptr.To(int32(100)), ptr.To(int32(4)))) + require.Equal(t, "virtio,bridge=vmbr0,mtu=1500", formatNetworkDevice("virtio", "vmbr0", new(int32(1500)), nil, nil)) + require.Equal(t, "virtio,bridge=vmbr0,tag=100", formatNetworkDevice("virtio", "vmbr0", nil, new(int32(100)), nil)) + require.Equal(t, "virtio,bridge=vmbr0,queues=4", formatNetworkDevice("virtio", "vmbr0", nil, nil, new(int32(4)))) + require.Equal(t, "virtio,bridge=vmbr0,mtu=1500,tag=100,queues=4", formatNetworkDevice("virtio", "vmbr0", new(int32(1500)), new(int32(100)), new(int32(4)))) } func TestExtractMACAddress(t *testing.T) { diff --git a/internal/service/vmservice/vm.go b/internal/service/vmservice/vm.go index ed22295e0..fc7a52e81 100644 --- a/internal/service/vmservice/vm.go +++ b/internal/service/vmservice/vm.go @@ -235,7 +235,7 @@ func ensureVirtualMachine(ctx context.Context, machineScope *scope.MachineScope) machineScope.Logger.V(4).Info("Task created", "taskID", resp.Task.ID) // make sure spec.VirtualMachineID is always set. - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To(string(resp.Task.UPID)) + machineScope.ProxmoxMachine.Status.TaskRef = new(string(resp.Task.UPID)) machineScope.SetVirtualMachineID(resp.NewID) // requeue until cloning is finished @@ -357,7 +357,7 @@ func reconcileVirtualMachineConfig(ctx context.Context, machineScope *scope.Mach return false, errors.Wrapf(err, "failed to configure VM %s", machineScope.Name()) } - machineScope.ProxmoxMachine.Status.TaskRef = ptr.To(string(task.UPID)) + machineScope.ProxmoxMachine.Status.TaskRef = new(string(task.UPID)) conditions.Set(machineScope.ProxmoxMachine, metav1.Condition{ Type: infrav1.ProxmoxMachineVirtualMachineProvisionedCondition, @@ -515,7 +515,7 @@ func createVM(ctx context.Context, scope *scope.MachineScope) (proxmox.VMCloneRe node = options.Node } - scope.ProxmoxMachine.Status.ProxmoxNode = ptr.To(node) + scope.ProxmoxMachine.Status.ProxmoxNode = new(node) // if the creation was successful, we store the information about the node in the // cluster status diff --git a/internal/service/vmservice/vm_test.go b/internal/service/vmservice/vm_test.go index f4c8b3fbf..d32e37065 100644 --- a/internal/service/vmservice/vm_test.go +++ b/internal/service/vmservice/vm_test.go @@ -24,7 +24,6 @@ import ( lutherproxmox "github.com/luthermonson/go-proxmox" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" "sigs.k8s.io/cluster-api/util/conditions" @@ -39,8 +38,8 @@ func TestReconcileVM_EverythingReady(t *testing.T) { machineScope, proxmoxClient, _ := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedWaitingForCloudInitReason) vm := newRunningVM() machineScope.SetVirtualMachineID(int64(vm.VMID)) - machineScope.ProxmoxMachine.Status.BootstrapDataProvided = ptr.To(true) - machineScope.ProxmoxMachine.Status.Initialization.Provisioned = ptr.To(true) + machineScope.ProxmoxMachine.Status.BootstrapDataProvided = new(true) + machineScope.ProxmoxMachine.Status.Initialization.Provisioned = new(true) proxmoxClient.EXPECT().GetVM(context.Background(), "node1", int64(123)).Return(vm, nil).Once() proxmoxClient.EXPECT().CloudInitStatus(context.Background(), vm).Return(false, nil).Once() @@ -57,10 +56,10 @@ func TestReconcileVM_QemuAgentCheckDisabled(t *testing.T) { vm := newRunningVM() machineScope.SetVirtualMachineID(int64(vm.VMID)) // machineScope.ProxmoxMachine.Status.IPAddresses = map[string]*infrav1.IPAddresses{infrav1.DefaultNetworkDevice: {IPv4: []string{"10.10.10.10"}}} - machineScope.ProxmoxMachine.Status.BootstrapDataProvided = ptr.To(true) - machineScope.ProxmoxMachine.Status.Initialization.Provisioned = ptr.To(true) + machineScope.ProxmoxMachine.Status.BootstrapDataProvided = new(true) + machineScope.ProxmoxMachine.Status.Initialization.Provisioned = new(true) machineScope.ProxmoxMachine.Spec.Checks = &infrav1.ProxmoxMachineChecks{ - SkipQemuGuestAgent: ptr.To(true), + SkipQemuGuestAgent: new(true), } proxmoxClient.EXPECT().GetVM(context.Background(), "node1", int64(123)).Return(vm, nil).Once() @@ -77,10 +76,10 @@ func TestReconcileVM_CloudInitCheckDisabled(t *testing.T) { vm := newRunningVM() machineScope.SetVirtualMachineID(int64(vm.VMID)) // machineScope.ProxmoxMachine.Status.IPAddresses = map[string]*infrav1.IPAddresses{infrav1.DefaultNetworkDevice: {IPv4: []string{"10.10.10.10"}}} - machineScope.ProxmoxMachine.Status.BootstrapDataProvided = ptr.To(true) - machineScope.ProxmoxMachine.Status.Initialization.Provisioned = ptr.To(true) + machineScope.ProxmoxMachine.Status.BootstrapDataProvided = new(true) + machineScope.ProxmoxMachine.Status.Initialization.Provisioned = new(true) machineScope.ProxmoxMachine.Spec.Checks = &infrav1.ProxmoxMachineChecks{ - SkipCloudInitStatus: ptr.To(true), + SkipCloudInitStatus: new(true), } proxmoxClient.EXPECT().GetVM(context.Background(), "node1", int64(123)).Return(vm, nil).Once() @@ -97,11 +96,11 @@ func TestReconcileVM_InitCheckDisabled(t *testing.T) { vm := newRunningVM() machineScope.SetVirtualMachineID(int64(vm.VMID)) // machineScope.ProxmoxMachine.Status.IPAddresses = map[string]*infrav1.IPAddresses{infrav1.DefaultNetworkDevice: {IPv4: []string{"10.10.10.10"}}} - machineScope.ProxmoxMachine.Status.BootstrapDataProvided = ptr.To(true) - machineScope.ProxmoxMachine.Status.Initialization.Provisioned = ptr.To(true) + machineScope.ProxmoxMachine.Status.BootstrapDataProvided = new(true) + machineScope.ProxmoxMachine.Status.Initialization.Provisioned = new(true) machineScope.ProxmoxMachine.Spec.Checks = &infrav1.ProxmoxMachineChecks{ - SkipCloudInitStatus: ptr.To(true), - SkipQemuGuestAgent: ptr.To(true), + SkipCloudInitStatus: new(true), + SkipQemuGuestAgent: new(true), } proxmoxClient.EXPECT().GetVM(context.Background(), "node1", int64(123)).Return(vm, nil).Once() @@ -114,12 +113,12 @@ func TestReconcileVM_InitCheckDisabled(t *testing.T) { func TestEnsureVirtualMachine_CreateVM_FullOptions(t *testing.T) { machineScope, proxmoxClient, _ := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedCloningReason) - machineScope.ProxmoxMachine.Spec.Description = ptr.To("test vm") - machineScope.ProxmoxMachine.Spec.Format = ptr.To(infrav1.TargetStorageFormatRaw) - machineScope.ProxmoxMachine.Spec.Full = ptr.To(true) - machineScope.ProxmoxMachine.Spec.Pool = ptr.To("pool") - machineScope.ProxmoxMachine.Spec.SnapName = ptr.To("snap") - machineScope.ProxmoxMachine.Spec.Storage = ptr.To("storage") + machineScope.ProxmoxMachine.Spec.Description = new("test vm") + machineScope.ProxmoxMachine.Spec.Format = new(infrav1.TargetStorageFormatRaw) + machineScope.ProxmoxMachine.Spec.Full = new(true) + machineScope.ProxmoxMachine.Spec.Pool = new("pool") + machineScope.ProxmoxMachine.Spec.SnapName = new("snap") + machineScope.ProxmoxMachine.Spec.Storage = new("storage") machineScope.ProxmoxMachine.Spec.AllowedNodes = []string{"node2"} expectedOptions := proxmox.VMCloneRequest{ Node: "node1", @@ -157,12 +156,12 @@ func TestEnsureVirtualMachine_CreateVM_FullOptions_TemplateSelector(t *testing.T }, } - machineScope.ProxmoxMachine.Spec.Description = ptr.To("test vm") - machineScope.ProxmoxMachine.Spec.Format = ptr.To(infrav1.TargetStorageFormatRaw) - machineScope.ProxmoxMachine.Spec.Full = ptr.To(true) - machineScope.ProxmoxMachine.Spec.Pool = ptr.To("pool") - machineScope.ProxmoxMachine.Spec.SnapName = ptr.To("snap") - machineScope.ProxmoxMachine.Spec.Storage = ptr.To("storage") + machineScope.ProxmoxMachine.Spec.Description = new("test vm") + machineScope.ProxmoxMachine.Spec.Format = new(infrav1.TargetStorageFormatRaw) + machineScope.ProxmoxMachine.Spec.Full = new(true) + machineScope.ProxmoxMachine.Spec.Pool = new("pool") + machineScope.ProxmoxMachine.Spec.SnapName = new("snap") + machineScope.ProxmoxMachine.Spec.Storage = new("storage") machineScope.ProxmoxMachine.Spec.AllowedNodes = []string{"node1", "node2"} expectedOptions := proxmox.VMCloneRequest{ Node: "node1", @@ -209,12 +208,12 @@ func TestEnsureVirtualMachine_CreateVM_FullOptions_TemplateSelector_VMTemplateNo }, }, } - machineScope.ProxmoxMachine.Spec.Description = ptr.To("test vm") - machineScope.ProxmoxMachine.Spec.Format = ptr.To(infrav1.TargetStorageFormatRaw) - machineScope.ProxmoxMachine.Spec.Full = ptr.To(true) - machineScope.ProxmoxMachine.Spec.Pool = ptr.To("pool") - machineScope.ProxmoxMachine.Spec.SnapName = ptr.To("snap") - machineScope.ProxmoxMachine.Spec.Storage = ptr.To("storage") + machineScope.ProxmoxMachine.Spec.Description = new("test vm") + machineScope.ProxmoxMachine.Spec.Format = new(infrav1.TargetStorageFormatRaw) + machineScope.ProxmoxMachine.Spec.Full = new(true) + machineScope.ProxmoxMachine.Spec.Pool = new("pool") + machineScope.ProxmoxMachine.Spec.SnapName = new("snap") + machineScope.ProxmoxMachine.Spec.Storage = new("storage") machineScope.ProxmoxMachine.Spec.AllowedNodes = []string{"node2"} proxmoxClient.EXPECT().FindVMTemplateByTags(context.Background(), vmTemplateTags, "exact").Return("", -1, goproxmox.ErrTemplateNotFound).Once() @@ -350,7 +349,7 @@ func TestEnsureVirtualMachine_CreateVM_VMIDRangeCheckExisting(t *testing.T) { Name: "vm1000", }, Spec: infrav1.ProxmoxMachineSpec{ - VirtualMachineID: ptr.To(int64(1000)), + VirtualMachineID: new(int64(1000)), }, } machine := clusterv1.Machine{ @@ -430,27 +429,27 @@ func TestReconcileVirtualMachineConfig_NoConfig(t *testing.T) { func TestReconcileVirtualMachineConfig_ApplyConfig(t *testing.T) { machineScope, proxmoxClient, _ := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedCloningReason) - machineScope.ProxmoxMachine.Spec.Description = ptr.To("test vm") - machineScope.ProxmoxMachine.Spec.NumSockets = ptr.To(int32(4)) - machineScope.ProxmoxMachine.Spec.NumCores = ptr.To(int32(4)) - machineScope.ProxmoxMachine.Spec.MemoryMiB = ptr.To(int32(16 * 1024)) + machineScope.ProxmoxMachine.Spec.Description = new("test vm") + machineScope.ProxmoxMachine.Spec.NumSockets = new(int32(4)) + machineScope.ProxmoxMachine.Spec.NumCores = new(int32(4)) + machineScope.ProxmoxMachine.Spec.MemoryMiB = new(int32(16 * 1024)) machineScope.ProxmoxMachine.Spec.Network = &infrav1.NetworkSpec{ NetworkDevices: []infrav1.NetworkDevice{ - {Name: "net0", Bridge: ptr.To("vmbr0"), Model: ptr.To("virtio"), MTU: ptr.To[int32](1500)}, - {Name: "net1", Bridge: ptr.To("vmbr1"), Model: ptr.To("virtio"), MTU: ptr.To[int32](1500)}, + {Name: "net0", Bridge: new("vmbr0"), Model: new("virtio"), MTU: new(int32(1500))}, + {Name: "net1", Bridge: new("vmbr1"), Model: new("virtio"), MTU: new(int32(1500))}, }, } vm := newStoppedVM() task := newTask() machineScope.SetVirtualMachine(vm) - expectedOptions := []interface{}{ + expectedOptions := []any{ proxmox.VirtualMachineOption{Name: optionSockets, Value: *machineScope.ProxmoxMachine.Spec.NumSockets}, proxmox.VirtualMachineOption{Name: optionCores, Value: *machineScope.ProxmoxMachine.Spec.NumCores}, proxmox.VirtualMachineOption{Name: optionMemory, Value: *machineScope.ProxmoxMachine.Spec.MemoryMiB}, proxmox.VirtualMachineOption{Name: optionDescription, Value: machineScope.ProxmoxMachine.Spec.Description}, - proxmox.VirtualMachineOption{Name: "net0", Value: formatNetworkDevice("virtio", "vmbr0", ptr.To[int32](1500), nil, nil)}, - proxmox.VirtualMachineOption{Name: "net1", Value: formatNetworkDevice("virtio", "vmbr1", ptr.To[int32](1500), nil, nil)}, + proxmox.VirtualMachineOption{Name: "net0", Value: formatNetworkDevice("virtio", "vmbr0", new(int32(1500)), nil, nil)}, + proxmox.VirtualMachineOption{Name: "net1", Value: formatNetworkDevice("virtio", "vmbr1", new(int32(1500)), nil, nil)}, } proxmoxClient.EXPECT().ConfigureVM(context.Background(), vm, expectedOptions...).Return(task, nil).Once() @@ -471,7 +470,7 @@ func TestReconcileVirtualMachineConfigTags(t *testing.T) { vm.VirtualMachineConfig.Tags = "tag0" task := newTask() machineScope.SetVirtualMachine(vm) - expectedOptions := []interface{}{ + expectedOptions := []any{ proxmox.VirtualMachineOption{Name: optionTags, Value: "tag0;tag1;tag2"}, } @@ -484,12 +483,12 @@ func TestReconcileVirtualMachineConfigTags(t *testing.T) { // CASE: empty Tags machineScope.ProxmoxMachine.Spec.Tags = []string{} - machineScope.ProxmoxMachine.Spec.Description = ptr.To("test vm") + machineScope.ProxmoxMachine.Spec.Description = new("test vm") vm = newStoppedVM() vm.VirtualMachineConfig.Tags = "tag0" task = newTask() machineScope.SetVirtualMachine(vm) - expectedOptions = []interface{}{ + expectedOptions = []any{ proxmox.VirtualMachineOption{Name: optionDescription, Value: machineScope.ProxmoxMachine.Spec.Description}, } @@ -544,7 +543,7 @@ func TestReconcileMachineAddresses_IPv4(t *testing.T) { NetName: "default", IPv4: []string{"10.10.10.10"}, }} - machineScope.ProxmoxMachine.Status.BootstrapDataProvided = ptr.To(true) + machineScope.ProxmoxMachine.Status.BootstrapDataProvided = new(true) require.NoError(t, reconcileMachineAddresses(machineScope)) require.Equal(t, machineScope.ProxmoxMachine.Status.Addresses[0].Address, machineScope.ProxmoxMachine.GetName()) @@ -570,7 +569,7 @@ func TestReconcileMachineAddresses_IPv6(t *testing.T) { NetName: "default", IPv6: []string{"2001:db8::2"}, }} - machineScope.ProxmoxMachine.Status.BootstrapDataProvided = ptr.To(true) + machineScope.ProxmoxMachine.Status.BootstrapDataProvided = new(true) require.NoError(t, reconcileMachineAddresses(machineScope)) require.Equal(t, machineScope.ProxmoxMachine.Status.Addresses[0].Address, machineScope.ProxmoxMachine.GetName()) @@ -597,7 +596,7 @@ func TestReconcileMachineAddresses_DualStack(t *testing.T) { IPv4: []string{"10.10.10.10"}, IPv6: []string{"2001:db8::2"}, }} - machineScope.ProxmoxMachine.Status.BootstrapDataProvided = ptr.To(true) + machineScope.ProxmoxMachine.Status.BootstrapDataProvided = new(true) require.NoError(t, reconcileMachineAddresses(machineScope)) require.Equal(t, machineScope.ProxmoxMachine.Status.Addresses[0].Address, machineScope.ProxmoxMachine.GetName()) @@ -607,25 +606,25 @@ func TestReconcileMachineAddresses_DualStack(t *testing.T) { func TestReconcileVirtualMachineConfigVLAN(t *testing.T) { machineScope, proxmoxClient, _ := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedCloningReason) - machineScope.ProxmoxMachine.Spec.NumSockets = ptr.To(int32(4)) - machineScope.ProxmoxMachine.Spec.NumCores = ptr.To(int32(4)) - machineScope.ProxmoxMachine.Spec.MemoryMiB = ptr.To(int32(16 * 1024)) + machineScope.ProxmoxMachine.Spec.NumSockets = new(int32(4)) + machineScope.ProxmoxMachine.Spec.NumCores = new(int32(4)) + machineScope.ProxmoxMachine.Spec.MemoryMiB = new(int32(16 * 1024)) machineScope.ProxmoxMachine.Spec.Network = &infrav1.NetworkSpec{ NetworkDevices: []infrav1.NetworkDevice{ - {Name: infrav1.NetName("net0"), Bridge: ptr.To("vmbr0"), Model: ptr.To("virtio"), VLAN: ptr.To(int32(100))}, - {Name: infrav1.NetName("net1"), Bridge: ptr.To("vmbr1"), Model: ptr.To("virtio"), VLAN: ptr.To(int32(100))}, + {Name: infrav1.NetName("net0"), Bridge: new("vmbr0"), Model: new("virtio"), VLAN: new(int32(100))}, + {Name: infrav1.NetName("net1"), Bridge: new("vmbr1"), Model: new("virtio"), VLAN: new(int32(100))}, }, } vm := newStoppedVM() task := newTask() machineScope.SetVirtualMachine(vm) - expectedOptions := []interface{}{ + expectedOptions := []any{ proxmox.VirtualMachineOption{Name: optionSockets, Value: *machineScope.ProxmoxMachine.Spec.NumSockets}, proxmox.VirtualMachineOption{Name: optionCores, Value: *machineScope.ProxmoxMachine.Spec.NumCores}, proxmox.VirtualMachineOption{Name: optionMemory, Value: *machineScope.ProxmoxMachine.Spec.MemoryMiB}, - proxmox.VirtualMachineOption{Name: "net0", Value: formatNetworkDevice("virtio", "vmbr0", nil, ptr.To(int32(100)), nil)}, - proxmox.VirtualMachineOption{Name: "net1", Value: formatNetworkDevice("virtio", "vmbr1", nil, ptr.To(int32(100)), nil)}, + proxmox.VirtualMachineOption{Name: "net0", Value: formatNetworkDevice("virtio", "vmbr0", nil, new(int32(100)), nil)}, + proxmox.VirtualMachineOption{Name: "net1", Value: formatNetworkDevice("virtio", "vmbr1", nil, new(int32(100)), nil)}, } proxmoxClient.EXPECT().ConfigureVM(context.TODO(), vm, expectedOptions...).Return(task, nil).Once() @@ -638,25 +637,25 @@ func TestReconcileVirtualMachineConfigVLAN(t *testing.T) { func TestReconcileVirtualMachineConfigQueue(t *testing.T) { machineScope, proxmoxClient, _ := setupReconcilerTestWithCondition(t, infrav1.ProxmoxMachineVirtualMachineProvisionedCloningReason) - machineScope.ProxmoxMachine.Spec.NumSockets = ptr.To(int32(4)) - machineScope.ProxmoxMachine.Spec.NumCores = ptr.To(int32(4)) - machineScope.ProxmoxMachine.Spec.MemoryMiB = ptr.To(int32(16 * 1024)) + machineScope.ProxmoxMachine.Spec.NumSockets = new(int32(4)) + machineScope.ProxmoxMachine.Spec.NumCores = new(int32(4)) + machineScope.ProxmoxMachine.Spec.MemoryMiB = new(int32(16 * 1024)) machineScope.ProxmoxMachine.Spec.Network = &infrav1.NetworkSpec{ NetworkDevices: []infrav1.NetworkDevice{ - {Name: infrav1.NetName("net0"), Bridge: ptr.To("vmbr0"), Model: ptr.To("virtio"), VLAN: ptr.To(int32(100)), Queues: ptr.To(int32(4))}, - {Name: infrav1.NetName("net1"), Bridge: ptr.To("vmbr1"), Model: ptr.To("virtio"), VLAN: ptr.To(int32(100)), Queues: ptr.To(int32(4))}, + {Name: infrav1.NetName("net0"), Bridge: new("vmbr0"), Model: new("virtio"), VLAN: new(int32(100)), Queues: new(int32(4))}, + {Name: infrav1.NetName("net1"), Bridge: new("vmbr1"), Model: new("virtio"), VLAN: new(int32(100)), Queues: new(int32(4))}, }, } vm := newStoppedVM() task := newTask() machineScope.SetVirtualMachine(vm) - expectedOptions := []interface{}{ + expectedOptions := []any{ proxmox.VirtualMachineOption{Name: optionSockets, Value: *machineScope.ProxmoxMachine.Spec.NumSockets}, proxmox.VirtualMachineOption{Name: optionCores, Value: *machineScope.ProxmoxMachine.Spec.NumCores}, proxmox.VirtualMachineOption{Name: optionMemory, Value: *machineScope.ProxmoxMachine.Spec.MemoryMiB}, - proxmox.VirtualMachineOption{Name: "net0", Value: formatNetworkDevice("virtio", "vmbr0", nil, ptr.To(int32(100)), ptr.To(int32(4)))}, - proxmox.VirtualMachineOption{Name: "net1", Value: formatNetworkDevice("virtio", "vmbr1", nil, ptr.To(int32(100)), ptr.To(int32(4)))}, + proxmox.VirtualMachineOption{Name: "net0", Value: formatNetworkDevice("virtio", "vmbr0", nil, new(int32(100)), new(int32(4)))}, + proxmox.VirtualMachineOption{Name: "net1", Value: formatNetworkDevice("virtio", "vmbr1", nil, new(int32(100)), new(int32(4)))}, } proxmoxClient.EXPECT().ConfigureVM(context.TODO(), vm, expectedOptions...).Return(task, nil).Once() @@ -690,8 +689,8 @@ func TestReconcileVM_CloudInitFailed(t *testing.T) { NetName: "default", IPv4: []string{"10.10.10.10"}, }} - machineScope.ProxmoxMachine.Status.BootstrapDataProvided = ptr.To(true) - machineScope.ProxmoxMachine.Status.Initialization.Provisioned = ptr.To(true) + machineScope.ProxmoxMachine.Status.BootstrapDataProvided = new(true) + machineScope.ProxmoxMachine.Status.Initialization.Provisioned = new(true) proxmoxClient.EXPECT().GetVM(context.Background(), "node1", int64(123)).Return(vm, nil).Once() proxmoxClient.EXPECT().CloudInitStatus(context.Background(), vm).Return(false, goproxmox.ErrCloudInitFailed).Once() @@ -716,8 +715,8 @@ func TestReconcileVM_CloudInitRunning(t *testing.T) { NetName: "default", IPv4: []string{"10.10.10.10"}, }} - machineScope.ProxmoxMachine.Status.BootstrapDataProvided = ptr.To(true) - machineScope.ProxmoxMachine.Status.Initialization.Provisioned = ptr.To(true) + machineScope.ProxmoxMachine.Status.BootstrapDataProvided = new(true) + machineScope.ProxmoxMachine.Status.Initialization.Provisioned = new(true) proxmoxClient.EXPECT().GetVM(context.Background(), "node1", int64(123)).Return(vm, nil).Once() proxmoxClient.EXPECT().CloudInitStatus(context.Background(), vm).Return(true, nil).Once() @@ -740,16 +739,16 @@ func TestReconcileVM_StateMachine(t *testing.T) { Gateway: "2001:db8::1", } - machineScope.ProxmoxMachine.Spec.Description = ptr.To("test vm") - machineScope.ProxmoxMachine.Spec.Format = ptr.To(infrav1.TargetStorageFormatRaw) - machineScope.ProxmoxMachine.Spec.Full = ptr.To(true) - machineScope.ProxmoxMachine.Spec.Pool = ptr.To("pool") - machineScope.ProxmoxMachine.Spec.SnapName = ptr.To("snap") - machineScope.ProxmoxMachine.Spec.Storage = ptr.To("storage") + machineScope.ProxmoxMachine.Spec.Description = new("test vm") + machineScope.ProxmoxMachine.Spec.Format = new(infrav1.TargetStorageFormatRaw) + machineScope.ProxmoxMachine.Spec.Full = new(true) + machineScope.ProxmoxMachine.Spec.Pool = new("pool") + machineScope.ProxmoxMachine.Spec.SnapName = new("snap") + machineScope.ProxmoxMachine.Spec.Storage = new("storage") machineScope.ProxmoxMachine.Spec.AllowedNodes = []string{"node1", "node2"} - machineScope.ProxmoxMachine.Spec.NumSockets = ptr.To[int32](1) - machineScope.ProxmoxMachine.Spec.NumCores = ptr.To[int32](1) - machineScope.ProxmoxMachine.Spec.MemoryMiB = ptr.To[int32](1024) + machineScope.ProxmoxMachine.Spec.NumSockets = new(int32(1)) + machineScope.ProxmoxMachine.Spec.NumCores = new(int32(1)) + machineScope.ProxmoxMachine.Spec.MemoryMiB = new(int32(1024)) machineScope.ProxmoxMachine.Spec.Disks = &infrav1.Storage{ BootVolume: &infrav1.DiskSize{ Disk: "scsi0", @@ -790,7 +789,7 @@ func TestReconcileVM_StateMachine(t *testing.T) { proxmoxClient.EXPECT().GetTask(context.Background(), "result").Return(task, nil).Once() proxmoxClient.EXPECT().GetVM(context.Background(), "node2", int64(123)).Return(vm, nil).Once() - expectedVMConfigureRequest := []interface{}{ + expectedVMConfigureRequest := []any{ proxmox.VirtualMachineOption{Name: optionSockets, Value: *machineScope.ProxmoxMachine.Spec.NumSockets}, proxmox.VirtualMachineOption{Name: optionCores, Value: *machineScope.ProxmoxMachine.Spec.NumCores}, proxmox.VirtualMachineOption{Name: optionMemory, Value: *machineScope.ProxmoxMachine.Spec.MemoryMiB}, @@ -854,7 +853,7 @@ func TestReconcileVM_StateMachine(t *testing.T) { IPv4: []string{"192.0.2.10"}, IPv6: []string{"2001:db8::2"}, }} - machineScope.ProxmoxMachine.Status.BootstrapDataProvided = ptr.To(true) + machineScope.ProxmoxMachine.Status.BootstrapDataProvided = new(true) result, err = ReconcileVM(context.Background(), machineScope) require.NoError(t, err) diff --git a/internal/webhook/proxmoxmachine_webhook.go b/internal/webhook/proxmoxmachine_webhook.go index f1e74d893..2a5f593e1 100644 --- a/internal/webhook/proxmoxmachine_webhook.go +++ b/internal/webhook/proxmoxmachine_webhook.go @@ -27,7 +27,6 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/validation/field" - "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" @@ -291,10 +290,10 @@ func (p *ProxmoxMachine) Default(_ context.Context, obj runtime.Object) error { // We guarantee that DefaultNetworkDevice is a valid proxmox network device. offset, _ := vmservice.NetNameToOffset(infrav1.DefaultNetworkDevice) if defaultIPv4Count == 0 { - machine.Spec.Network.NetworkDevices[offset].DefaultIPv4 = ptr.To(true) + machine.Spec.Network.NetworkDevices[offset].DefaultIPv4 = new(true) } if defaultIPv6Count == 0 { - machine.Spec.Network.NetworkDevices[offset].DefaultIPv6 = ptr.To(true) + machine.Spec.Network.NetworkDevices[offset].DefaultIPv6 = new(true) } return nil diff --git a/internal/webhook/proxmoxmachine_webhook_test.go b/internal/webhook/proxmoxmachine_webhook_test.go index b3e835f71..1c54262b2 100644 --- a/internal/webhook/proxmoxmachine_webhook_test.go +++ b/internal/webhook/proxmoxmachine_webhook_test.go @@ -23,7 +23,6 @@ import ( . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" infrav1 "github.com/ionos-cloud/cluster-api-provider-proxmox/api/v1alpha2" @@ -46,7 +45,7 @@ var _ = Describe("Controller Test", func() { It("should disallow invalid network mtu for additional device", func() { machine := validProxmoxMachine("test-machine") - machine.Spec.Network.NetworkDevices[0].MTU = ptr.To(int32(1000)) + machine.Spec.Network.NetworkDevices[0].MTU = new(int32(1000)) g.Expect(k8sClient.Create(testEnv.GetContext(), &machine)).To(MatchError(ContainSubstring("mtu must be at least 1280 or 1, but was 1000"))) }) @@ -57,13 +56,13 @@ var _ = Describe("Controller Test", func() { It("should disallow invalid network vlan", func() { machine := validProxmoxMachine("test-machine") - machine.Spec.Network.NetworkDevices[0].VLAN = ptr.To(int32(0)) + machine.Spec.Network.NetworkDevices[0].VLAN = new(int32(0)) g.Expect(k8sClient.Create(testEnv.GetContext(), &machine)).To(MatchError(ContainSubstring("greater than or equal to 1"))) }) It("should disallow invalid link mtu", func() { machine := validProxmoxMachine("test-machine") - machine.Spec.Network.NetworkDevices[0].LinkMTU = ptr.To(int32(1000)) + machine.Spec.Network.NetworkDevices[0].LinkMTU = new(int32(1000)) g.Expect(k8sClient.Create(testEnv.GetContext(), &machine)).To(MatchError(ContainSubstring("mtu must be at least 1280, but was 1000"))) }) @@ -81,7 +80,7 @@ var _ = Describe("Controller Test", func() { It("should accept MTU=1 (inherit bridge MTU) on default device", func() { machine := validProxmoxMachine("net-inherit-mtu-default") - machine.Spec.Network.NetworkDevices[0].MTU = ptr.To(int32(1)) + machine.Spec.Network.NetworkDevices[0].MTU = new(int32(1)) g.Expect(k8sClient.Create(testEnv.GetContext(), &machine)).To(Succeed()) }) @@ -93,23 +92,23 @@ var _ = Describe("Controller Test", func() { It("should reject unknown network model values", func() { machine := validProxmoxMachine("net-unknown-model") - machine.Spec.Network.NetworkDevices[0].Model = ptr.To("foo") + machine.Spec.Network.NetworkDevices[0].Model = new("foo") g.Expect(k8sClient.Create(testEnv.GetContext(), &machine)).To(MatchError(ContainSubstring("Unsupported value"))) }) It("should reject too large MTU", func() { machine := validProxmoxMachine("net-mtu-too-large") - machine.Spec.Network.NetworkDevices[0].MTU = ptr.To(int32(65521)) + machine.Spec.Network.NetworkDevices[0].MTU = new(int32(65521)) g.Expect(k8sClient.Create(testEnv.GetContext(), &machine)).To(MatchError(ContainSubstring("invalid MTU value"))) }) It("should reject FIB rule priorities that match kernel rules", func() { machine5 := validProxmoxMachine("net-routingpolicy-priority-32765") - machine5.Spec.Network.NetworkDevices[0].RoutingPolicy = []infrav1.RoutingPolicySpec{{Priority: ptr.To(int64(32765))}} + machine5.Spec.Network.NetworkDevices[0].RoutingPolicy = []infrav1.RoutingPolicySpec{{Priority: new(int64(32765))}} g.Expect(k8sClient.Create(testEnv.GetContext(), &machine5)).To(MatchError(ContainSubstring("Cowardly refusing to insert FIB rule matching kernel rules"))) machine6 := validProxmoxMachine("net-routingpolicy-priority-32766") - machine6.Spec.Network.NetworkDevices[0].RoutingPolicy = []infrav1.RoutingPolicySpec{{Priority: ptr.To(int64(32766))}} + machine6.Spec.Network.NetworkDevices[0].RoutingPolicy = []infrav1.RoutingPolicySpec{{Priority: new(int64(32766))}} g.Expect(k8sClient.Create(testEnv.GetContext(), &machine6)).To(MatchError(ContainSubstring("Cowardly refusing to insert FIB rule matching kernel rules"))) }) @@ -132,22 +131,22 @@ var _ = Describe("Controller Test", func() { It("should error with multiple default ipv4 pool tags", func() { machine := validProxmoxMachine("multiple-default-v4-pools") - machine.Spec.Network.NetworkDevices[0].DefaultIPv4 = ptr.To(true) - machine.Spec.Network.NetworkDevices[1].DefaultIPv4 = ptr.To(true) + machine.Spec.Network.NetworkDevices[0].DefaultIPv4 = new(true) + machine.Spec.Network.NetworkDevices[1].DefaultIPv4 = new(true) g.Expect(k8sClient.Create(testEnv.GetContext(), &machine)).To(MatchError(ContainSubstring("More than one default IPv4/IPv6 interface in NetworkDevices"))) }) It("should error with multiple default ipv6 pool tags", func() { machine := validProxmoxMachine("multiple-default-v6-pools") - machine.Spec.Network.NetworkDevices[0].DefaultIPv6 = ptr.To(true) - machine.Spec.Network.NetworkDevices[1].DefaultIPv6 = ptr.To(true) + machine.Spec.Network.NetworkDevices[0].DefaultIPv6 = new(true) + machine.Spec.Network.NetworkDevices[1].DefaultIPv6 = new(true) g.Expect(k8sClient.Create(testEnv.GetContext(), &machine)).To(MatchError(ContainSubstring("More than one default IPv4/IPv6 interface in NetworkDevices"))) }) It("should not add default ipv4/ipv6 pool tags when defined", func() { machine := validProxmoxMachine("default-pools-exist") - machine.Spec.Network.NetworkDevices[1].DefaultIPv4 = ptr.To(true) - machine.Spec.Network.NetworkDevices[1].DefaultIPv6 = ptr.To(true) + machine.Spec.Network.NetworkDevices[1].DefaultIPv4 = new(true) + machine.Spec.Network.NetworkDevices[1].DefaultIPv6 = new(true) g.Expect(k8sClient.Create(testEnv.GetContext(), &machine)).To(Succeed()) g.Expect(machine.Spec.Network.NetworkDevices[0].DefaultIPv4).To(BeNil()) g.Expect(machine.Spec.Network.NetworkDevices[0].DefaultIPv6).To(BeNil()) @@ -174,10 +173,10 @@ var _ = Describe("Controller Test", func() { g.Expect(k8sClient.Create(testEnv.GetContext(), &machine)).To(Succeed()) g.Expect(k8sClient.Get(testEnv.GetContext(), client.ObjectKeyFromObject(&machine), &machine)).To(Succeed()) - machine.Spec.Network.NetworkDevices[0].MTU = ptr.To(int32(50)) + machine.Spec.Network.NetworkDevices[0].MTU = new(int32(50)) g.Expect(k8sClient.Update(testEnv.GetContext(), &machine)).To(MatchError(ContainSubstring("invalid MTU value"))) - machine.Spec.Network.NetworkDevices[0].VLAN = ptr.To(int32(0)) + machine.Spec.Network.NetworkDevices[0].VLAN = new(int32(0)) g.Expect(k8sClient.Update(testEnv.GetContext(), &machine)).To(MatchError(ContainSubstring("invalid MTU value"))) @@ -208,13 +207,13 @@ func validProxmoxMachine(name string) infrav1.ProxmoxMachine { Spec: infrav1.ProxmoxMachineSpec{ VirtualMachineCloneSpec: infrav1.VirtualMachineCloneSpec{ TemplateSource: infrav1.TemplateSource{ - SourceNode: ptr.To("pve"), - TemplateID: ptr.To(int32(100)), + SourceNode: new("pve"), + TemplateID: new(int32(100)), }, }, - NumSockets: ptr.To(int32(1)), - NumCores: ptr.To(int32(1)), - MemoryMiB: ptr.To(int32(1024)), + NumSockets: new(int32(1)), + NumCores: new(int32(1)), + MemoryMiB: new(int32(1024)), Disks: &infrav1.Storage{ BootVolume: &infrav1.DiskSize{ Disk: "scsi[0]", @@ -224,25 +223,25 @@ func validProxmoxMachine(name string) infrav1.ProxmoxMachine { Network: &infrav1.NetworkSpec{ NetworkDevices: []infrav1.NetworkDevice{{ Name: infrav1.NetName("net0"), - Bridge: ptr.To("vmbr1"), - Model: ptr.To("virtio"), - MTU: ptr.To(int32(1500)), - VLAN: ptr.To(int32(100)), + Bridge: new("vmbr1"), + Model: new("virtio"), + MTU: new(int32(1500)), + VLAN: new(int32(100)), }, { Name: infrav1.NetName("net1"), - Bridge: ptr.To("vmbr2"), - Model: ptr.To("virtio"), - MTU: ptr.To(int32(1500)), - VLAN: ptr.To(int32(100)), + Bridge: new("vmbr2"), + Model: new("virtio"), + MTU: new(int32(1500)), + VLAN: new(int32(100)), InterfaceConfig: infrav1.InterfaceConfig{ IPPoolRef: []corev1.TypedLocalObjectReference{{ Name: "simple-pool", Kind: InClusterIPPool, - APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + APIGroup: new("ipam.cluster.x-k8s.io"), }}, Routing: infrav1.Routing{ RoutingPolicy: []infrav1.RoutingPolicySpec{{ - Table: ptr.To(int32(665)), + Table: new(int32(665)), }}, }, }, @@ -253,7 +252,7 @@ func validProxmoxMachine(name string) infrav1.ProxmoxMachine { Name: "vrf-green", Routing: infrav1.Routing{ RoutingPolicy: []infrav1.RoutingPolicySpec{{ - Table: ptr.To(int32(665)), + Table: new(int32(665)), }}, }}, }, @@ -267,9 +266,9 @@ func invalidMTUProxmoxMachine(name string) infrav1.ProxmoxMachine { machine := validProxmoxMachine(name) machine.Spec.Network.NetworkDevices = []infrav1.NetworkDevice{{ Name: infrav1.DefaultNetworkDevice, - Bridge: ptr.To("vmbr1"), - Model: ptr.To("virtio"), - MTU: ptr.To[int32](50), + Bridge: new("vmbr1"), + Model: new("virtio"), + MTU: new(int32(50)), }} return machine } @@ -278,9 +277,9 @@ func invalidVLANProxmoxMachine(name string) infrav1.ProxmoxMachine { machine := validProxmoxMachine(name) machine.Spec.Network.NetworkDevices = []infrav1.NetworkDevice{{ Name: infrav1.DefaultNetworkDevice, - Bridge: ptr.To("vmbr1"), - Model: ptr.To("virtio"), - VLAN: ptr.To[int32](0), + Bridge: new("vmbr1"), + Model: new("virtio"), + VLAN: new(int32(0)), }} return machine } diff --git a/pkg/cloudinit/network.go b/pkg/cloudinit/network.go index 6a4a1c6cd..02f8da030 100644 --- a/pkg/cloudinit/network.go +++ b/pkg/cloudinit/network.go @@ -182,7 +182,7 @@ func (r *NetworkConfig) Render() ([]byte, error) { } // Check YAML render to be valid - var unused interface{} + var unused any err = yaml.Unmarshal(nc, &unused) if err != nil { return nil, errors.Wrap(err, diff --git a/pkg/cloudinit/network_test.go b/pkg/cloudinit/network_test.go index 5974e65f8..26de8e668 100644 --- a/pkg/cloudinit/network_test.go +++ b/pkg/cloudinit/network_test.go @@ -22,7 +22,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "k8s.io/utils/ptr" "github.com/ionos-cloud/cluster-api-provider-proxmox/pkg/types" ) @@ -489,7 +488,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -511,10 +510,10 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, - LinkMTU: ptr.To(int32(9001)), + LinkMTU: new(int32(9001)), }, }, }, @@ -535,7 +534,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -558,7 +557,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -581,7 +580,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, { @@ -591,15 +590,15 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.11.12/24"), Gateway: "10.10.11.1", - Metric: ptr.To(int32(200)), + Metric: new(int32(200)), }}, Routes: []types.RoutingData{{ - To: ptr.To("172.16.24.1/24"), - Metric: ptr.To(int32(50)), - Via: ptr.To("10.10.10.254"), + To: new("172.16.24.1/24"), + Metric: new(int32(50)), + Via: new("10.10.10.254"), }, { - To: ptr.To("2002::/64"), - Via: ptr.To("2001:db8::1"), + To: new("2002::/64"), + Via: new("2001:db8::1"), }, }, }, @@ -622,7 +621,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, { @@ -631,14 +630,14 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.11.12/24"), Gateway: "10.10.11.1", - Metric: ptr.To(int32(200)), + Metric: new(int32(200)), }}, MacAddress: "92:60:a0:5b:22:c3", FIBRules: []types.FIBRuleData{{ - To: ptr.To("0.0.0.0/0"), - From: ptr.To("192.168.178.1/24"), - Priority: ptr.To(int64(999)), - Table: ptr.To(int32(100)), + To: new("0.0.0.0/0"), + From: new("192.168.178.1/24"), + Priority: new(int64(999)), + Table: new(int32(100)), }, }, }, @@ -659,7 +658,7 @@ func TestNetworkConfig_Render(t *testing.T) { MacAddress: "92:60:a0:5b:22:c2", IPConfigs: []types.IPConfig{{ Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -680,7 +679,7 @@ func TestNetworkConfig_Render(t *testing.T) { MacAddress: "92:60:a0:5b:22:c2", IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -701,7 +700,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.11/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -723,7 +722,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.11/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, { @@ -733,7 +732,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.11.11/24"), Gateway: "10.10.11.254", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -755,7 +754,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, }, }, @@ -776,7 +775,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -787,7 +786,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("196.168.100.124/24"), Gateway: "196.168.100.254", - Metric: ptr.To(int32(200)), + Metric: new(int32(200)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -819,11 +818,11 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }, { IPAddress: netip.MustParsePrefix("2001:db8::1/64"), Gateway: "2001:db8::1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -845,7 +844,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("2001:db8::1/64"), Gateway: "2001:db8::1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -924,7 +923,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -935,7 +934,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("196.168.100.124/24"), Gateway: "196.168.100.254", - Metric: ptr.To(int32(200)), + Metric: new(int32(200)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -945,20 +944,20 @@ func TestNetworkConfig_Render(t *testing.T) { Table: 500, Interfaces: []string{"eth0", "eth1"}, Routes: []types.RoutingData{{ - To: ptr.To("default"), - Via: ptr.To("192.168.178.1"), - Metric: ptr.To(int32(100)), - Table: ptr.To(int32(100)), + To: new("default"), + Via: new("192.168.178.1"), + Metric: new(int32(100)), + Table: new(int32(100)), }, { - To: ptr.To("10.10.10.0/24"), - Via: ptr.To("192.168.178.254"), - Metric: ptr.To(int32(100)), + To: new("10.10.10.0/24"), + Via: new("192.168.178.254"), + Metric: new(int32(100)), }}, FIBRules: []types.FIBRuleData{{ - To: ptr.To("0.0.0.0/0"), - From: ptr.To("192.168.178.1/24"), - Priority: ptr.To(int64(999)), - Table: ptr.To(int32(100)), + To: new("0.0.0.0/0"), + From: new("192.168.178.1/24"), + Priority: new(int64(999)), + Table: new(int32(100)), }}, }, }, @@ -979,7 +978,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -990,7 +989,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("196.168.100.124/24"), Gateway: "196.168.100.254", - Metric: ptr.To(int32(200)), + Metric: new(int32(200)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -1000,20 +999,20 @@ func TestNetworkConfig_Render(t *testing.T) { Table: int32(500), Interfaces: []string{"eth0"}, Routes: []types.RoutingData{{ - To: ptr.To("default"), - Via: ptr.To("192.168.178.1"), - Metric: ptr.To(int32(100)), - Table: ptr.To(int32(100)), + To: new("default"), + Via: new("192.168.178.1"), + Metric: new(int32(100)), + Table: new(int32(100)), }, { - To: ptr.To("10.10.10.0/24"), - Via: ptr.To("192.168.178.254"), - Metric: ptr.To(int32(100)), + To: new("10.10.10.0/24"), + Via: new("192.168.178.254"), + Metric: new(int32(100)), }}, FIBRules: []types.FIBRuleData{{ - To: ptr.To("0.0.0.0/0"), - From: ptr.To("192.168.178.1/24"), - Priority: ptr.To(int64(999)), - Table: ptr.To(int32(100)), + To: new("0.0.0.0/0"), + From: new("192.168.178.1/24"), + Priority: new(int64(999)), + Table: new(int32(100)), }}, }, { @@ -1022,10 +1021,10 @@ func TestNetworkConfig_Render(t *testing.T) { Table: int32(501), Interfaces: []string{"eth1"}, FIBRules: []types.FIBRuleData{{ - To: ptr.To("0.0.0.0/0"), - From: ptr.To("192.168.100.0/24"), - Priority: ptr.To(int64(999)), - Table: ptr.To(int32(101)), + To: new("0.0.0.0/0"), + From: new("192.168.100.0/24"), + Priority: new(int64(999)), + Table: new(int32(101)), }}, }, }, @@ -1044,7 +1043,7 @@ func TestNetworkConfig_Render(t *testing.T) { Name: "vrf-blue", Table: int32(500), FIBRules: []types.FIBRuleData{{ - From: ptr.To("10.10.0.0/16"), + From: new("10.10.0.0/16"), }}, }, }, @@ -1064,7 +1063,7 @@ func TestNetworkConfig_Render(t *testing.T) { Table: int32(500), Interfaces: []string{"eth0", "eth1"}, Routes: []types.RoutingData{{ - Table: ptr.To(int32(100)), + Table: new(int32(100)), }}, }, }, @@ -1085,7 +1084,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("10.10.10.12/24"), Gateway: "10.10.10.1", - Metric: ptr.To(int32(100)), + Metric: new(int32(100)), }}, DNSServers: []string{"8.8.8.8", "8.8.4.4"}, }, @@ -1096,7 +1095,7 @@ func TestNetworkConfig_Render(t *testing.T) { IPConfigs: []types.IPConfig{{ IPAddress: netip.MustParsePrefix("2001:db8::ffff:0/64"), Gateway: "2001:db8::", - Metric: ptr.To(int32(200)), + Metric: new(int32(200)), }}, DNSServers: []string{"22:22", "::", "[::]"}, }, @@ -1106,8 +1105,8 @@ func TestNetworkConfig_Render(t *testing.T) { Table: int32(500), Interfaces: []string{"on: [NO, \"False\"]"}, Routes: []types.RoutingData{{ - To: ptr.To("::"), - Via: ptr.To("192.168.178.1"), + To: new("::"), + Via: new("192.168.178.1"), }}, }, }}, diff --git a/pkg/consts/consts.go b/pkg/consts/consts.go index b9616f34b..8fd07f175 100644 --- a/pkg/consts/consts.go +++ b/pkg/consts/consts.go @@ -20,7 +20,6 @@ package consts import ( "reflect" - "k8s.io/utils/ptr" ipamicv1 "sigs.k8s.io/cluster-api-ipam-provider-in-cluster/api/v1alpha2" ) @@ -39,7 +38,7 @@ func GetInClusterIPPoolKind() string { // GetIPAMInClusterAPIGroup returns a pointer to APIGroupVersion as required by // typedlocalobjectreferences. func GetIPAMInClusterAPIGroup() *string { - return ptr.To(ipamicv1.GroupVersion.String()) + return new(ipamicv1.GroupVersion.String()) } // GetIPAMInClusterAPIVersion returns the APIGroup as required for TypeMeta. diff --git a/pkg/convert/convert.go b/pkg/convert/convert.go index f64edb069..71a132fa3 100644 --- a/pkg/convert/convert.go +++ b/pkg/convert/convert.go @@ -162,8 +162,8 @@ func marshalWithIndent(node *yaml.Node, indent int) ([]byte, error) { // detectIndent scans YAML input and returns the indentation width by finding // the first line whose leading spaces form a common indent unit. Defaults to 2. func detectIndent(data []byte) int { - lines := bytes.Split(data, []byte("\n")) - for _, line := range lines { + lines := bytes.SplitSeq(data, []byte("\n")) + for line := range lines { if len(line) == 0 { continue } diff --git a/pkg/convert/convert_test.go b/pkg/convert/convert_test.go index 1e65586f9..721457a05 100644 --- a/pkg/convert/convert_test.go +++ b/pkg/convert/convert_test.go @@ -87,7 +87,7 @@ func TestConvert_V1Alpha1Template(t *testing.T) { } // Verify no top-level null fields leaked (exclude block scalars like embedded manifests). - for _, line := range strings.Split(result, "\n") { + for line := range strings.SplitSeq(result, "\n") { trimmed := strings.TrimSpace(line) // Skip lines inside block scalars (indented content or literal blocks). if strings.HasSuffix(trimmed, ": null") && !strings.HasPrefix(strings.TrimSpace(line), "#") { @@ -585,11 +585,8 @@ func unifiedDiff(want, got string) string { gotLines := strings.Split(got, "\n") var b strings.Builder - maxLines := len(wantLines) - if len(gotLines) > maxLines { - maxLines = len(gotLines) - } - for i := 0; i < maxLines; i++ { + maxLines := max(len(gotLines), len(wantLines)) + for i := range maxLines { var w, g string if i < len(wantLines) { w = wantLines[i] diff --git a/pkg/convert/sentinel.go b/pkg/convert/sentinel.go index 2542de61a..d8dbd2a03 100644 --- a/pkg/convert/sentinel.go +++ b/pkg/convert/sentinel.go @@ -174,11 +174,11 @@ func inferType(expr, yamlText string) string { func extractDefault(expr string) string { // Strip ${ and } inner := expr[2 : len(expr)-1] - idx := strings.Index(inner, ":=") - if idx < 0 { + _, after, ok := strings.Cut(inner, ":=") + if !ok { return "" } - return inner[idx+2:] + return after } // extractYAMLKey finds the YAML key on the line containing expr. @@ -194,8 +194,8 @@ func extractYAMLKey(expr, yamlText string) string { // The key is the trimmed text before the colon. line = strings.TrimSpace(line) - if colonIdx := strings.Index(line, ":"); colonIdx >= 0 { - return strings.TrimSpace(line[:colonIdx]) + if before, _, ok := strings.Cut(line, ":"); ok { + return strings.TrimSpace(before) } return "" } @@ -215,11 +215,11 @@ func isWholeValue(expr, yamlText string) bool { lineEnd += idx } line := yamlText[lineStart:lineEnd] - colonIdx := strings.Index(line, ":") - if colonIdx < 0 { + _, after, ok := strings.Cut(line, ":") + if !ok { return false } - value := strings.TrimSpace(line[colonIdx+1:]) + value := strings.TrimSpace(after) return value == expr } diff --git a/pkg/convert/status.go b/pkg/convert/status.go index 8bd824085..51113cc8a 100644 --- a/pkg/convert/status.go +++ b/pkg/convert/status.go @@ -16,7 +16,11 @@ limitations under the License. package convert -import "gopkg.in/yaml.v3" +import ( + "slices" + + "gopkg.in/yaml.v3" +) // StripStatus removes the top-level "status" key from a YAML document node. // If the status block contains any non-zero scalar values, it is kept and a @@ -79,12 +83,7 @@ func hasNonZeroScalar(node *yaml.Node) bool { } // SequenceNode, DocumentNode: check all children. - for _, child := range node.Content { - if hasNonZeroScalar(child) { - return true - } - } - return false + return slices.ContainsFunc(node.Content, hasNonZeroScalar) } // isZeroScalar returns true for scalars that represent zero/empty/false/null. diff --git a/pkg/ignition/enrich.go b/pkg/ignition/enrich.go index 8caa8248f..c1f6f9375 100644 --- a/pkg/ignition/enrich.go +++ b/pkg/ignition/enrich.go @@ -21,11 +21,11 @@ import ( "encoding/json" "fmt" "net/url" + "strings" ignition "github.com/flatcar/ignition/config/v2_3" ignitionTypes "github.com/flatcar/ignition/config/v2_3/types" "github.com/pkg/errors" - "k8s.io/utils/ptr" "github.com/ionos-cloud/cluster-api-provider-proxmox/pkg/types" ) @@ -58,10 +58,10 @@ func (e *Enricher) getEnrichConfig() (*ignitionTypes.Config, error) { Node: ignitionTypes.Node{ Filesystem: "root", Path: "/etc/hostname", - Overwrite: ptr.To(true), + Overwrite: new(true), }, FileEmbedded1: ignitionTypes.FileEmbedded1{ - Mode: ptr.To(0644), + Mode: new(0644), Contents: ignitionTypes.FileContents{ Source: fmt.Sprintf("data:,%s", e.Hostname), }, @@ -71,10 +71,10 @@ func (e *Enricher) getEnrichConfig() (*ignitionTypes.Config, error) { Node: ignitionTypes.Node{ Filesystem: "root", Path: "/etc/proxmox-env", - Overwrite: ptr.To(true), + Overwrite: new(true), }, FileEmbedded1: ignitionTypes.FileEmbedded1{ - Mode: ptr.To(420), + Mode: new(420), Contents: ignitionTypes.FileContents{ Source: fmt.Sprintf("data:,%s", e.getProxmoxEnvContent()), }, @@ -112,19 +112,20 @@ func (e *Enricher) getEnrichConfig() (*ignitionTypes.Config, error) { } func (e *Enricher) getProxmoxEnvContent() string { - content := fmt.Sprintf("COREOS_CUSTOM_HOSTNAME=%s\nCOREOS_CUSTOM_INSTANCE_ID=%s\nCOREOS_CUSTOM_PROVIDER_ID=%s", e.Hostname, e.InstanceID, e.ProviderID) + var content strings.Builder + _, _ = content.WriteString("COREOS_CUSTOM_HOSTNAME=" + e.Hostname + "\nCOREOS_CUSTOM_INSTANCE_ID=" + e.InstanceID + "\nCOREOS_CUSTOM_PROVIDER_ID=" + e.ProviderID) // TODO: consider adding a kube-vip config field to NetworkConfigData for _, network := range e.Network { for _, ipconfig := range network.IPConfigs { if ipconfig.IPAddress.Addr().Is4() && ipconfig.Default { - content += fmt.Sprintf("\nCOREOS_CUSTOM_PRIVATE_IPV4=%s", ipconfig.IPAddress.String()) + _, _ = content.WriteString("\nCOREOS_CUSTOM_PRIVATE_IPV4=" + ipconfig.IPAddress.String()) } if ipconfig.IPAddress.Addr().Is6() && ipconfig.Default { - content += fmt.Sprintf("\nCOREOS_CUSTOM_PRIVATE_IPV6=%s", ipconfig.IPAddress.String()) + _, _ = content.WriteString("\nCOREOS_CUSTOM_PRIVATE_IPV6=" + ipconfig.IPAddress.String()) } } } - return url.PathEscape(content) + return url.PathEscape(content.String()) } func buildIgnitionConfig(bootstrapData []byte, enrichConfig *ignitionTypes.Config) ([]byte, string, error) { diff --git a/pkg/ignition/enrich_test.go b/pkg/ignition/enrich_test.go index ac939f1e5..64f06c7a4 100644 --- a/pkg/ignition/enrich_test.go +++ b/pkg/ignition/enrich_test.go @@ -96,14 +96,14 @@ func TestEnricher_Enrich(t *testing.T) { // Test Data. We'll only test environment variables for now. var environment string - var jsonData interface{} + var jsonData any err = json.Unmarshal(userdata, &jsonData) require.NoError(t, err) - files := jsonData.(map[string]interface{})["storage"].(map[string]interface{})["files"].([]interface{}) + files := jsonData.(map[string]any)["storage"].(map[string]any)["files"].([]any) for _, file := range files { - if v, exists := file.(map[string]interface{})["path"]; exists { + if v, exists := file.(map[string]any)["path"]; exists { if v.(string) == "/etc/proxmox-env" { - environment = file.(map[string]interface{})["contents"].(map[string]interface{})["source"].(string) + environment = file.(map[string]any)["contents"].(map[string]any)["source"].(string) } } } diff --git a/pkg/ignition/network_test.go b/pkg/ignition/network_test.go index c7f3cb5e5..349acc68f 100644 --- a/pkg/ignition/network_test.go +++ b/pkg/ignition/network_test.go @@ -21,7 +21,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "k8s.io/utils/ptr" infrav1 "github.com/ionos-cloud/cluster-api-provider-proxmox/api/v1alpha2" "github.com/ionos-cloud/cluster-api-provider-proxmox/pkg/types" @@ -140,8 +139,8 @@ func TestRenderNetworkConfigData(t *testing.T) { Name: "eth0", MacAddress: "E2:B8:FE:E7:50:75", IPConfigs: []types.IPConfig{ - {IPAddress: netip.MustParsePrefix("10.0.0.98/25"), Gateway: "10.0.0.1", Metric: ptr.To(int32(100))}, - {IPAddress: netip.MustParsePrefix("2001:db8:1::10/64"), Gateway: "2001:db8:1::1", Metric: ptr.To(int32(100))}, + {IPAddress: netip.MustParsePrefix("10.0.0.98/25"), Gateway: "10.0.0.1", Metric: new(int32(100))}, + {IPAddress: netip.MustParsePrefix("2001:db8:1::10/64"), Gateway: "2001:db8:1::1", Metric: new(int32(100))}, }, ProxName: infrav1.DefaultNetworkDevice, DNSServers: []string{"10.0.1.1"}, @@ -151,15 +150,15 @@ func TestRenderNetworkConfigData(t *testing.T) { Name: "eth1", MacAddress: "E2:8E:95:1F:EB:36", IPConfigs: []types.IPConfig{ - {IPAddress: netip.MustParsePrefix("10.0.1.84/25"), Gateway: "10.0.1.1", Metric: ptr.To(int32(200))}, + {IPAddress: netip.MustParsePrefix("10.0.1.84/25"), Gateway: "10.0.1.1", Metric: new(int32(200))}, }, ProxName: "net1", DNSServers: []string{"10.0.1.1"}, FIBRules: []types.FIBRuleData{{ - To: ptr.To("8.7.6.5/32"), - From: ptr.To("1.1.1.1/32"), - Priority: ptr.To(int64(100)), - Table: ptr.To(int32(500)), + To: new("8.7.6.5/32"), + From: new("1.1.1.1/32"), + Priority: new(int64(100)), + Table: new(int32(500)), }}, }, }, @@ -178,8 +177,8 @@ func TestRenderNetworkConfigData(t *testing.T) { Name: "eth0", MacAddress: "E2:B8:FE:E7:50:75", IPConfigs: []types.IPConfig{ - {IPAddress: netip.MustParsePrefix("10.0.0.98/25"), Gateway: "10.0.0.1", Metric: ptr.To(int32(100))}, - {IPAddress: netip.MustParsePrefix("2001:db8:1::10/64"), Gateway: "2001:db8:1::1", Metric: ptr.To(int32(100))}, + {IPAddress: netip.MustParsePrefix("10.0.0.98/25"), Gateway: "10.0.0.1", Metric: new(int32(100))}, + {IPAddress: netip.MustParsePrefix("2001:db8:1::10/64"), Gateway: "2001:db8:1::1", Metric: new(int32(100))}, }, ProxName: infrav1.DefaultNetworkDevice, DNSServers: []string{"10.0.1.1"}, @@ -189,7 +188,7 @@ func TestRenderNetworkConfigData(t *testing.T) { Name: "eth1", MacAddress: "E2:8E:95:1F:EB:36", IPConfigs: []types.IPConfig{ - {IPAddress: netip.MustParsePrefix("10.0.1.84/25"), Gateway: "10.0.1.1", Metric: ptr.To(int32(200))}, + {IPAddress: netip.MustParsePrefix("10.0.1.84/25"), Gateway: "10.0.1.1", Metric: new(int32(200))}, }, ProxName: "net1", DNSServers: []string{"10.0.1.1"}, @@ -201,14 +200,14 @@ func TestRenderNetworkConfigData(t *testing.T) { Table: 644, Interfaces: []string{"eth1"}, Routes: []types.RoutingData{{ - To: ptr.To("3.4.5.6"), - Via: ptr.To("10.0.1.1"), - Metric: ptr.To(int32(100)), + To: new("3.4.5.6"), + Via: new("10.0.1.1"), + Metric: new(int32(100)), }}, FIBRules: []types.FIBRuleData{{ - To: ptr.To("8.7.6.5/32"), - From: ptr.To("1.1.1.1/32"), - Priority: ptr.To(int64(100)), + To: new("8.7.6.5/32"), + From: new("1.1.1.1/32"), + Priority: new(int64(100)), }}, }, }, diff --git a/pkg/kubernetes/ipam/ipam.go b/pkg/kubernetes/ipam/ipam.go index 35636c2cb..b70057d35 100644 --- a/pkg/kubernetes/ipam/ipam.go +++ b/pkg/kubernetes/ipam/ipam.go @@ -93,7 +93,7 @@ func isIPv4(ip string) (bool, error) { // poolFromObjectRef is a local helper to turn any objectRef into a pool, // The awkward calling convention is due to limitations of golang (no generics on methods, // no type conversion of constrained types). -func (h *Helper) poolFromObjectRef(ctx context.Context, o interface{}, namespace *string) (client.Object, error) { +func (h *Helper) poolFromObjectRef(ctx context.Context, o any, namespace *string) (client.Object, error) { ref := corev1.TypedObjectReference{} // Todo: type constrained conversion without panic @@ -105,7 +105,7 @@ func (h *Helper) poolFromObjectRef(ctx context.Context, o interface{}, namespace ref.Kind = GetInClusterIPPoolKind() ref.Name = value.Name - ref.Namespace = ptr.To(h.cluster.GetNamespace()) + ref.Namespace = new(h.cluster.GetNamespace()) case *corev1.TypedLocalObjectReference: value, _ := o.(*corev1.TypedLocalObjectReference) ref.APIGroup = GetIPAMInClusterAPIGroup() @@ -178,7 +178,7 @@ func (h *Helper) GetInClusterPools(ctx context.Context, moxm *infrav1.ProxmoxMac namespace := moxm.ObjectMeta.Namespace - zone := ptr.To(ptr.Deref(moxm.Spec.Network.Zone, "default")) + zone := new(ptr.Deref(moxm.Spec.Network.Zone, "default")) zoneIndex := slices.IndexFunc(h.cluster.Status.InClusterZoneRef, func(z infrav1.InClusterZoneRef) bool { return ptr.Equal(zone, z.Zone) }) @@ -206,7 +206,7 @@ func (h *Helper) GetInClusterPools(ctx context.Context, moxm *infrav1.ProxmoxMac } poolSpec.Pool = pool poolSpec.PoolRef = corev1.TypedLocalObjectReference{ - APIGroup: ptr.To(ipamicv1.GroupVersion.String()), + APIGroup: new(ipamicv1.GroupVersion.String()), Name: pool.Name, Kind: pool.TypeMeta.Kind, } @@ -229,7 +229,7 @@ func (h *Helper) GetInClusterPools(ctx context.Context, moxm *infrav1.ProxmoxMac } poolSpec.Pool = pool poolSpec.PoolRef = corev1.TypedLocalObjectReference{ - APIGroup: ptr.To(ipamicv1.GroupVersion.String()), + APIGroup: new(ipamicv1.GroupVersion.String()), Name: pool.Name, Kind: pool.TypeMeta.Kind, } @@ -612,7 +612,7 @@ func gvkForObject(obj runtime.Object, scheme *runtime.Scheme) (schema.GroupVersi // toTypedLocalObjectReference converts an ipamv1.IPPoolReference to a corev1.TypedLocalObjectReference. func toTypedLocalObjectReference(ref ipamv1.IPPoolReference) corev1.TypedLocalObjectReference { return corev1.TypedLocalObjectReference{ - APIGroup: ptr.To(ref.APIGroup), + APIGroup: new(ref.APIGroup), Kind: ref.Kind, Name: ref.Name, } diff --git a/pkg/kubernetes/ipam/ipam_test.go b/pkg/kubernetes/ipam/ipam_test.go index 9a0170d25..3711f1936 100644 --- a/pkg/kubernetes/ipam/ipam_test.go +++ b/pkg/kubernetes/ipam/ipam_test.go @@ -28,7 +28,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" - "k8s.io/utils/ptr" ipamicv1 "sigs.k8s.io/cluster-api-ipam-provider-in-cluster/api/v1alpha2" clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" ipamv1 "sigs.k8s.io/cluster-api/api/ipam/v1beta2" @@ -110,7 +109,7 @@ func (s *IPAMTestSuite) Test_CreateOrUpdateInClusterIPPool() { s.Equal(pool.Spec.Prefix, 24) s.cluster.Spec.IPv4Config.Gateway = "10.11.0.0" - s.cluster.Spec.IPv4Config.Metric = ptr.To(int32(123)) + s.cluster.Spec.IPv4Config.Metric = new(int32(123)) ipamConfig = s.cluster.Spec.IPv4Config @@ -140,7 +139,7 @@ func (s *IPAMTestSuite) Test_CreateOrUpdateInClusterIPPool() { Addresses: []string{"2001:db8::/64"}, Prefix: 64, Gateway: "2001:db8::1", - Metric: ptr.To(int32(123)), + Metric: new(int32(123)), } s.NoError(s.helper.CreateOrUpdateInClusterIPPool(s.ctx)) @@ -198,7 +197,7 @@ func (s *IPAMTestSuite) Test_GetDefaultInClusterIPPool() { func (s *IPAMTestSuite) Test_GetInClusterIPPool() { notFound, err := s.helper.GetInClusterIPPool(s.ctx, corev1.TypedLocalObjectReference{ Name: "simple-pool", - APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + APIGroup: new("ipam.cluster.x-k8s.io"), Kind: InClusterIPPool, }) s.Nil(notFound) @@ -215,7 +214,7 @@ func (s *IPAMTestSuite) Test_GetInClusterIPPool() { }, &pool)) found, err := s.helper.GetInClusterIPPool(s.ctx, corev1.TypedLocalObjectReference{ - APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + APIGroup: new("ipam.cluster.x-k8s.io"), Name: "test-cluster-v4-icip", Kind: InClusterIPPool}) s.NoError(err) @@ -225,7 +224,7 @@ func (s *IPAMTestSuite) Test_GetInClusterIPPool() { func (s *IPAMTestSuite) Test_GetGlobalInClusterIPPool() { notFound, err := s.helper.GetGlobalInClusterIPPool(s.ctx, corev1.TypedLocalObjectReference{ Name: "simple-global-pool", - APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool}) s.Nil(notFound) s.Error(err) @@ -250,7 +249,7 @@ func (s *IPAMTestSuite) Test_GetGlobalInClusterIPPool() { found, err := s.helper.GetGlobalInClusterIPPool(s.ctx, corev1.TypedLocalObjectReference{ Name: "test-global-cluster-icip", - APIGroup: ptr.To("ipam.cluster.x-k8s.io"), + APIGroup: new("ipam.cluster.x-k8s.io"), Kind: GlobalInClusterIPPool}) s.NoError(err) @@ -349,7 +348,7 @@ func (s *IPAMTestSuite) Test_GetIPPoolAnnotations() { Name: "test-ippool-annotations", }, Address: "10.10.11.11", - Prefix: ptr.To[int32](24), + Prefix: new(int32(24)), Gateway: "10.10.11.254", }, } @@ -577,7 +576,7 @@ func (s *IPAMTestSuite) dummyIPAddress(owner client.Object, poolName string) *ip Name: poolName, }, Address: "10.10.10.11", - Prefix: ptr.To[int32](24), + Prefix: new(int32(24)), Gateway: "10.10.10.1", }, } diff --git a/pkg/proxmox/goproxmox/api_client.go b/pkg/proxmox/goproxmox/api_client.go index 43e4e23ca..24a9cb9c7 100644 --- a/pkg/proxmox/goproxmox/api_client.go +++ b/pkg/proxmox/goproxmox/api_client.go @@ -175,7 +175,7 @@ NEXT_VM: } vmTagMap := make(map[string]string) - for _, tag := range strings.Split(vm.Tags, ";") { + for tag := range strings.SplitSeq(vm.Tags, ";") { vmTagMap[strings.ToLower(strings.TrimSpace(tag))] = "" } diff --git a/pkg/proxmox/goproxmox/api_client_test.go b/pkg/proxmox/goproxmox/api_client_test.go index 132664588..90db6994e 100644 --- a/pkg/proxmox/goproxmox/api_client_test.go +++ b/pkg/proxmox/goproxmox/api_client_test.go @@ -110,8 +110,8 @@ func TestProxmoxAPIClient_GetReservableMemoryBytes(t *testing.T) { httpmock.RegisterResponder(http.MethodGet, `=~/nodes/test/qemu`, // Somehow, setting proxmox.VirtualMachines{} ALWAYS has `Template: true` when defined this way. // So it's better to just define a legitimate json response - newJSONResponder(200, []interface{}{ - map[string]interface{}{ + newJSONResponder(200, []any{ + map[string]any{ "name": "legit-worker", "maxmem": test.maxMem, "vmid": 1111, @@ -127,7 +127,7 @@ func TestProxmoxAPIClient_GetReservableMemoryBytes(t *testing.T) { "netin": 0, "diskread": 0, }, - map[string]interface{}{ + map[string]any{ "name": "template", "maxmem": 102400, "vmid": 2222, @@ -719,7 +719,7 @@ func TestProxmoxAPIClient_CloudInitStatus(t *testing.T) { // AgentExec mock httpmock.RegisterResponder(http.MethodPost, fmt.Sprintf(`=~/nodes/%s/qemu/%d/agent/exec\z`, vm.Node, vm.VMID), newJSONResponder(200, - map[string]interface{}{ + map[string]any{ "pid": test.pid, }, )) diff --git a/pkg/proxmox/logger.go b/pkg/proxmox/logger.go index c6f62825e..6b49e5197 100644 --- a/pkg/proxmox/logger.go +++ b/pkg/proxmox/logger.go @@ -33,21 +33,21 @@ var _ proxmox.LeveledLoggerInterface = Logger{} type Logger struct{} // Errorf logs message at error level. -func (Logger) Errorf(format string, args ...interface{}) { +func (Logger) Errorf(format string, args ...any) { klog.Errorf(format, args...) } // Warnf logs message at warn level. -func (Logger) Warnf(format string, args ...interface{}) { +func (Logger) Warnf(format string, args ...any) { klog.Infof(format, args...) } // Infof logs message at info level. -func (Logger) Infof(format string, args ...interface{}) { +func (Logger) Infof(format string, args ...any) { klog.V(2).Infof(format, args...) } // Debugf logs message at debug level. -func (Logger) Debugf(format string, args ...interface{}) { +func (Logger) Debugf(format string, args ...any) { klog.V(4).Infof(format, args...) } diff --git a/pkg/scope/cluster.go b/pkg/scope/cluster.go index 6910f7987..4727df87c 100644 --- a/pkg/scope/cluster.go +++ b/pkg/scope/cluster.go @@ -31,7 +31,6 @@ import ( corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" "sigs.k8s.io/cluster-api/util/conditions" "sigs.k8s.io/cluster-api/util/patch" @@ -244,5 +243,5 @@ func (s *ClusterScope) Close() error { // SetReady sets the ProxmoxCluster as provisioned. func (s *ClusterScope) SetReady() { - s.ProxmoxCluster.Status.Initialization.Provisioned = ptr.To(true) + s.ProxmoxCluster.Status.Initialization.Provisioned = new(true) } diff --git a/pkg/scope/machine.go b/pkg/scope/machine.go index d314ca16e..649fa1e39 100644 --- a/pkg/scope/machine.go +++ b/pkg/scope/machine.go @@ -161,17 +161,17 @@ func (m *MachineScope) SetProviderID(biosUUID string) { // SetVirtualMachineID sets the ProxmoxMachine instanceID in spec. func (m *MachineScope) SetVirtualMachineID(vmID int64) { - m.ProxmoxMachine.Spec.VirtualMachineID = ptr.To(vmID) + m.ProxmoxMachine.Spec.VirtualMachineID = new(vmID) } // SetReady sets the ProxmoxMachine Ready Status. func (m *MachineScope) SetReady() { - m.ProxmoxMachine.Status.Initialization.Provisioned = ptr.To(true) + m.ProxmoxMachine.Status.Initialization.Provisioned = new(true) } // SetNotReady sets the ProxmoxMachine Ready Status to false. func (m *MachineScope) SetNotReady() { - m.ProxmoxMachine.Status.Initialization.Provisioned = ptr.To(false) + m.ProxmoxMachine.Status.Initialization.Provisioned = new(false) } // SetAnnotation sets a key value annotation on the ProxmoxMachine. diff --git a/pkg/scope/machine_test.go b/pkg/scope/machine_test.go index 6b7ce584e..0e08f083f 100644 --- a/pkg/scope/machine_test.go +++ b/pkg/scope/machine_test.go @@ -22,7 +22,6 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" "github.com/stretchr/testify/require" clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" @@ -126,7 +125,7 @@ func TestMachineScope_SkipQemuCheckEnabled(t *testing.T) { p := infrav1.ProxmoxMachine{ Spec: infrav1.ProxmoxMachineSpec{ Checks: &infrav1.ProxmoxMachineChecks{ - SkipCloudInitStatus: ptr.To(true), + SkipCloudInitStatus: new(true), }, }, } @@ -152,7 +151,7 @@ func TestMachineScope_SkipCloudInitCheckEnabled(t *testing.T) { p := infrav1.ProxmoxMachine{ Spec: infrav1.ProxmoxMachineSpec{ Checks: &infrav1.ProxmoxMachineChecks{ - SkipCloudInitStatus: ptr.To(true), + SkipCloudInitStatus: new(true), }, }, } @@ -178,7 +177,7 @@ func TestMachineScope_SkipQemuDisablesCloudInitCheck(t *testing.T) { p := infrav1.ProxmoxMachine{ Spec: infrav1.ProxmoxMachineSpec{ Checks: &infrav1.ProxmoxMachineChecks{ - SkipQemuGuestAgent: ptr.To(true), + SkipQemuGuestAgent: new(true), }, }, } @@ -199,7 +198,7 @@ func TestMachineScope_GetBootstrapSecret(t *testing.T) { ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "test"}, Spec: clusterv1.MachineSpec{ Bootstrap: clusterv1.Bootstrap{ - DataSecretName: ptr.To("bootstrap"), + DataSecretName: new("bootstrap"), }, }, Status: clusterv1.MachineStatus{}, From 496c7844f4ac20ba6741657bb2fce5cc62effc46 Mon Sep 17 00:00:00 2001 From: Vic Kerr Date: Mon, 20 Apr 2026 15:26:06 +0000 Subject: [PATCH 3/5] build(Makefile): slight tidy-up of verify and test Makes the verify target run more tools. Makes the test target only run tests to save time during dev. Its dependency list was incomplete anyway. Fixes #592 --- Makefile | 46 +++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 3ee46e32f..31771d5da 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -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 @@ -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 From d471070ce258ee18da7c91075fd7cd8656be2112 Mon Sep 17 00:00:00 2001 From: Vic Kerr Date: Tue, 28 Apr 2026 12:03:22 +0000 Subject: [PATCH 4/5] tool: bump golangci-lint from 2.9.0 to 2.11.4 --- go.mod | 28 ++++++++++++++-------------- go.sum | 56 ++++++++++++++++++++++++++++---------------------------- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/go.mod b/go.mod index d38fc0396..3c9433d7d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ionos-cloud/cluster-api-provider-proxmox go 1.26.0 replace ( - github.com/golangci/golangci-lint/v2 => github.com/golangci/golangci-lint/v2 v2.9.0 + github.com/golangci/golangci-lint/v2 => github.com/golangci/golangci-lint/v2 v2.11.4 k8s.io/apimachinery => k8s.io/apimachinery v0.33.3 // temp override until 34 k8s.io/code-generator/cmd/conversion-gen => k8s.io/code-generator/cmd/conversion-gen v0.33.3 k8s.io/kube-openapi/pkg/schemaconv => k8s.io/kube-openapi/pkg/schemaconv v0.0.0-20250701173324-9bd5c66d9911 // drop for k8s 34 @@ -78,7 +78,7 @@ require ( github.com/MakeNowJust/heredoc v1.0.0 // indirect github.com/Masterminds/semver/v3 v3.4.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect - github.com/MirrexOne/unqueryvet v1.5.3 // indirect + github.com/MirrexOne/unqueryvet v1.5.4 // indirect github.com/NYTimes/gziphandler v1.1.1 // indirect github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect @@ -88,7 +88,7 @@ require ( github.com/alecthomas/chroma/v2 v2.23.1 // indirect github.com/alecthomas/go-check-sumtype v0.3.1 // indirect github.com/alexkohler/nakedret/v2 v2.0.6 // indirect - github.com/alexkohler/prealloc v1.0.2 // indirect + github.com/alexkohler/prealloc v1.1.0 // indirect github.com/alfatraining/structtag v1.0.0 // indirect github.com/alingse/asasalint v0.0.11 // indirect github.com/alingse/nilnesserr v0.2.0 // indirect @@ -140,7 +140,7 @@ require ( github.com/emicklei/go-restful/v3 v3.13.0 // indirect github.com/ettle/strcase v0.2.0 // indirect github.com/evanphx/json-patch/v5 v5.9.11 // indirect - github.com/fatih/color v1.18.0 // indirect + github.com/fatih/color v1.19.0 // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/firefart/nonamedreturns v1.0.6 // indirect @@ -167,7 +167,7 @@ require ( github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect github.com/gobuffalo/flect v1.0.3 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/godoc-lint/godoc-lint v0.11.1 // indirect + github.com/godoc-lint/godoc-lint v0.11.2 // indirect github.com/gofrs/flock v0.13.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golangci/asciicheck v0.5.0 // indirect @@ -210,7 +210,7 @@ require ( github.com/json-iterator/go v1.1.12 // indirect github.com/julz/importas v0.2.0 // indirect github.com/karamaru-alpha/copyloopvar v1.2.2 // indirect - github.com/kisielk/errcheck v1.9.0 // indirect + github.com/kisielk/errcheck v1.10.0 // indirect github.com/kkHAIKE/contextcheck v1.1.6 // indirect github.com/kulti/thelper v0.7.1 // indirect github.com/kunwardeep/paralleltest v1.0.15 // indirect @@ -235,7 +235,7 @@ require ( github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect - github.com/mgechev/revive v1.14.0 // indirect + github.com/mgechev/revive v1.15.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect @@ -250,7 +250,7 @@ require ( github.com/nakabonne/nestif v0.3.1 // indirect github.com/nishanths/exhaustive v0.12.0 // indirect github.com/nishanths/predeclared v0.2.2 // indirect - github.com/nunnatsa/ginkgolinter v0.22.0 // indirect + github.com/nunnatsa/ginkgolinter v0.23.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.1 // indirect @@ -271,18 +271,18 @@ require ( github.com/rogpeppe/go-internal v1.14.1 // indirect github.com/rs/zerolog v1.34.0 // indirect github.com/ryancurrah/gomodguard v1.4.1 // indirect - github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect + github.com/ryanrolds/sqlclosecheck v0.6.0 // indirect github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect github.com/sagikazarmark/locafero v0.12.0 // indirect github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect github.com/sashamelentyev/interfacebloat v1.1.0 // indirect github.com/sashamelentyev/usestdlibvars v1.29.0 // indirect - github.com/securego/gosec/v2 v2.22.11 // indirect + github.com/securego/gosec/v2 v2.24.8-0.20260309165252-619ce2117e08 // indirect github.com/sergi/go-diff v1.4.0 // indirect github.com/sirupsen/logrus v1.9.4 // indirect github.com/sivchari/containedctx v1.0.3 // indirect - github.com/sonatard/noctx v0.4.0 // indirect + github.com/sonatard/noctx v0.5.1 // indirect github.com/sourcegraph/go-diff v0.7.0 // indirect github.com/spf13/afero v1.15.0 // indirect github.com/spf13/cast v1.10.0 // indirect @@ -299,7 +299,7 @@ require ( github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect github.com/ultraware/funlen v0.2.0 // indirect github.com/ultraware/whitespace v0.2.0 // indirect - github.com/uudashr/gocognit v1.2.0 // indirect + github.com/uudashr/gocognit v1.2.1 // indirect github.com/uudashr/iface v1.4.1 // indirect github.com/vektra/mockery/v2 v2.53.6 // indirect github.com/vincent-petithory/dataurl v1.0.0 // indirect @@ -331,7 +331,7 @@ require ( go4.org v0.0.0-20201209231011-d4a079459e60 // indirect golang.org/x/crypto v0.51.0 // indirect golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect - golang.org/x/exp/typeparams v0.0.0-20251125195548-87e1e737ad39 // indirect + golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 // indirect golang.org/x/mod v0.36.0 // indirect golang.org/x/net v0.54.0 // indirect golang.org/x/oauth2 v0.34.0 // indirect @@ -350,7 +350,7 @@ require ( gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - honnef.co/go/tools v0.6.1 // indirect + honnef.co/go/tools v0.7.0 // indirect k8s.io/apiextensions-apiserver v0.33.3 // indirect k8s.io/apiserver v0.33.3 // indirect k8s.io/cluster-bootstrap v0.33.3 // indirect diff --git a/go.sum b/go.sum index 726d5ceea..5188881e8 100644 --- a/go.sum +++ b/go.sum @@ -63,8 +63,8 @@ github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/MirrexOne/unqueryvet v1.5.3 h1:LpT3rsH+IY3cQddWF9bg4C7jsbASdGnrOSofY8IPEiw= -github.com/MirrexOne/unqueryvet v1.5.3/go.mod h1:fs9Zq6eh1LRIhsDIsxf9PONVUjYdFHdtkHIgZdJnyPU= +github.com/MirrexOne/unqueryvet v1.5.4 h1:38QOxShO7JmMWT+eCdDMbcUgGCOeJphVkzzRgyLJgsQ= +github.com/MirrexOne/unqueryvet v1.5.4/go.mod h1:fs9Zq6eh1LRIhsDIsxf9PONVUjYdFHdtkHIgZdJnyPU= github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I= github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c= github.com/OpenPeeDeeP/depguard/v2 v2.2.1 h1:vckeWVESWp6Qog7UZSARNqfu/cZqvki8zsuj3piCMx4= @@ -88,8 +88,8 @@ github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/alexkohler/nakedret/v2 v2.0.6 h1:ME3Qef1/KIKr3kWX3nti3hhgNxw6aqN5pZmQiFSsuzQ= github.com/alexkohler/nakedret/v2 v2.0.6/go.mod h1:l3RKju/IzOMQHmsEvXwkqMDzHHvurNQfAgE1eVmT40Q= -github.com/alexkohler/prealloc v1.0.2 h1:MPo8cIkGkZytq7WNH9UHv3DIX1mPz1RatPXnZb0zHWQ= -github.com/alexkohler/prealloc v1.0.2/go.mod h1:fT39Jge3bQrfA7nPMDngUfvUbQGQeJyGQnR+913SCig= +github.com/alexkohler/prealloc v1.1.0 h1:cKGRBqlXw5iyQGLYhrXrDlcHxugXpTq4tQ5c91wkf8M= +github.com/alexkohler/prealloc v1.1.0/go.mod h1:fT39Jge3bQrfA7nPMDngUfvUbQGQeJyGQnR+913SCig= github.com/alfatraining/structtag v1.0.0 h1:2qmcUqNcCoyVJ0up879K614L9PazjBSFruTB0GOFjCc= github.com/alfatraining/structtag v1.0.0/go.mod h1:p3Xi5SwzTi+Ryj64DqjLWz7XurHxbGsq6y3ubePJPus= github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw= @@ -220,8 +220,8 @@ github.com/evanphx/json-patch v5.7.0+incompatible h1:vgGkfT/9f8zE6tvSCe74nfpAVDQ github.com/evanphx/json-patch v5.7.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjTM0wiaDU= github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/fatih/color v1.19.0 h1:Zp3PiM21/9Ld6FzSKyL5c/BULoe/ONr9KlbYVOfG8+w= +github.com/fatih/color v1.19.0/go.mod h1:zNk67I0ZUT1bEGsSGyCZYZNrHuTkJJB+r6Q9VuMi0LE= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -303,8 +303,8 @@ github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw= github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/godbus/dbus v0.0.0-20181025153459-66d97aec3384/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/godoc-lint/godoc-lint v0.11.1 h1:z9as8Qjiy6miRIa3VRymTa+Gt2RLnGICVikcvlUVOaA= -github.com/godoc-lint/godoc-lint v0.11.1/go.mod h1:BAqayheFSuZrEAqCRxgw9MyvsM+S/hZwJbU1s/ejRj8= +github.com/godoc-lint/godoc-lint v0.11.2 h1:Bp0FkJWoSdNsBikdNgIcgtaoo+xz6I/Y9s5WSBQUeeM= +github.com/godoc-lint/godoc-lint v0.11.2/go.mod h1:iVpGdL1JCikNH2gGeAn3Hh+AgN5Gx/I/cxV+91L41jo= github.com/gofrs/flock v0.13.0 h1:95JolYOvGMqeH31+FC7D2+uULf6mG61mEZ/A8dRYMzw= github.com/gofrs/flock v0.13.0/go.mod h1:jxeyy9R1auM5S6JYDBhDt+E2TCo7DkratH4Pgi8P+Z0= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -331,8 +331,8 @@ github.com/golangci/go-printf-func-name v0.1.1 h1:hIYTFJqAGp1iwoIfsNTpoq1xZAarog github.com/golangci/go-printf-func-name v0.1.1/go.mod h1:Es64MpWEZbh0UBtTAICOZiB+miW53w/K9Or/4QogJss= github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d h1:viFft9sS/dxoYY0aiOTsLKO2aZQAPT4nlQCsimGcSGE= github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d/go.mod h1:ivJ9QDg0XucIkmwhzCDsqcnxxlDStoTl89jDMIoNxKY= -github.com/golangci/golangci-lint/v2 v2.9.0 h1:x5RRwa/jpNEjOnbSQSTam47QBsB50NMzCCUKe4GY/0U= -github.com/golangci/golangci-lint/v2 v2.9.0/go.mod h1:gAPaJitu6HsyiuwJYO+WtKT9WmCpQZHR+gkXlCw1bRY= +github.com/golangci/golangci-lint/v2 v2.11.4 h1:GK+UlZBN5y7rh2PBnHA93XLSX6RaF7uhzJQ3JwU1wuA= +github.com/golangci/golangci-lint/v2 v2.11.4/go.mod h1:ODQDCASMA3VqfZYIbbQLpTRTzV7O/vjmIRF6u8NyFwI= github.com/golangci/golines v0.15.0 h1:Qnph25g8Y1c5fdo1X7GaRDGgnMHgnxh4Gk4VfPTtRx0= github.com/golangci/golines v0.15.0/go.mod h1:AZjXd23tbHMpowhtnGlj9KCNsysj72aeZVVHnVcZx10= github.com/golangci/misspell v0.8.0 h1:qvxQhiE2/5z+BVRo1kwYA8yGz+lOlu5Jfvtx2b04Jbg= @@ -456,8 +456,8 @@ github.com/julz/importas v0.2.0/go.mod h1:pThlt589EnCYtMnmhmRYY/qn9lCf/frPOK+WMx github.com/karamaru-alpha/copyloopvar v1.2.2 h1:yfNQvP9YaGQR7VaWLYcfZUlRP2eo2vhExWKxD/fP6q0= github.com/karamaru-alpha/copyloopvar v1.2.2/go.mod h1:oY4rGZqZ879JkJMtX3RRkcXRkmUvH0x35ykgaKgsgJY= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/errcheck v1.9.0 h1:9xt1zI9EBfcYBvdU1nVrzMzzUPUtPKs9bVSIM3TAb3M= -github.com/kisielk/errcheck v1.9.0/go.mod h1:kQxWMMVZgIkDq7U8xtG/n2juOjbLgZtedi0D+/VL/i8= +github.com/kisielk/errcheck v1.10.0 h1:Lvs/YAHP24YKg08LA8oDw2z9fJVme090RAXd90S+rrw= +github.com/kisielk/errcheck v1.10.0/go.mod h1:kQxWMMVZgIkDq7U8xtG/n2juOjbLgZtedi0D+/VL/i8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkHAIKE/contextcheck v1.1.6 h1:7HIyRcnyzxL9Lz06NGhiKvenXq7Zw6Q0UQu/ttjfJCE= github.com/kkHAIKE/contextcheck v1.1.6/go.mod h1:3dDbMRNBFaq8HFXWC1JyvDSPm43CmE6IuHam8Wr0rkg= @@ -530,8 +530,8 @@ github.com/maxatome/go-testdeep v1.14.0 h1:rRlLv1+kI8eOI3OaBXZwb3O7xY3exRzdW5QyX github.com/maxatome/go-testdeep v1.14.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM= github.com/mfridman/tparse v0.18.0 h1:wh6dzOKaIwkUGyKgOntDW4liXSo37qg5AXbIhkMV3vE= github.com/mfridman/tparse v0.18.0/go.mod h1:gEvqZTuCgEhPbYk/2lS3Kcxg1GmTxxU7kTC8DvP0i/A= -github.com/mgechev/revive v1.14.0 h1:CC2Ulb3kV7JFYt+izwORoS3VT/+Plb8BvslI/l1yZsc= -github.com/mgechev/revive v1.14.0/go.mod h1:MvnujelCZBZCaoDv5B3foPo6WWgULSSFxvfxp7GsPfo= +github.com/mgechev/revive v1.15.0 h1:vJ0HzSBzfNyPbHKolgiFjHxLek9KUijhqh42yGoqZ8Q= +github.com/mgechev/revive v1.15.0/go.mod h1:LlAKO3QQe9OJ0pVZzI2GPa8CbXGZ/9lNpCGvK4T/a8A= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -566,8 +566,8 @@ github.com/nishanths/exhaustive v0.12.0 h1:vIY9sALmw6T/yxiASewa4TQcFsVYZQQRUQJhK github.com/nishanths/exhaustive v0.12.0/go.mod h1:mEZ95wPIZW+x8kC4TgC+9YCUgiST7ecevsVDTgc2obs= github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= -github.com/nunnatsa/ginkgolinter v0.22.0 h1:o9g7JN6efdBxAHhejvPkodEjWsOBze9zDnPePsvC/Qg= -github.com/nunnatsa/ginkgolinter v0.22.0/go.mod h1:zIFAk36fhcHQIiYOGXLbrGTXz7cvpufhRYem6ToCVnY= +github.com/nunnatsa/ginkgolinter v0.23.0 h1:x3o4DGYOWbBMP/VdNQKgSj+25aJKx2Pe6lHr8gBcgf8= +github.com/nunnatsa/ginkgolinter v0.23.0/go.mod h1:9qN1+0akwXEccwV1CAcCDfcoBlWXHB+ML9884pL4SZ4= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= @@ -638,8 +638,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk= github.com/ryancurrah/gomodguard v1.4.1 h1:eWC8eUMNZ/wM/PWuZBv7JxxqT5fiIKSIyTvjb7Elr+g= github.com/ryancurrah/gomodguard v1.4.1/go.mod h1:qnMJwV1hX9m+YJseXEBhd2s90+1Xn6x9dLz11ualI1I= -github.com/ryanrolds/sqlclosecheck v0.5.1 h1:dibWW826u0P8jNLsLN+En7+RqWWTYrjCB9fJfSfdyCU= -github.com/ryanrolds/sqlclosecheck v0.5.1/go.mod h1:2g3dUjoS6AL4huFdv6wn55WpLIDjY7ZgUR4J8HOO/XQ= +github.com/ryanrolds/sqlclosecheck v0.6.0 h1:pEyL9okISdg1F1SEpJNlrEotkTGerv5BMk7U4AG0eVg= +github.com/ryanrolds/sqlclosecheck v0.6.0/go.mod h1:xyX16hsDaCMXHrMJ3JMzGf5OpDfHTOTTQrT7HOFUmeU= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI= github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs= github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4= @@ -652,8 +652,8 @@ github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tM github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ= github.com/sashamelentyev/usestdlibvars v1.29.0 h1:8J0MoRrw4/NAXtjQqTHrbW9NN+3iMf7Knkq057v4XOQ= github.com/sashamelentyev/usestdlibvars v1.29.0/go.mod h1:8PpnjHMk5VdeWlVb4wCdrB8PNbLqZ3wBZTZWkrpZZL8= -github.com/securego/gosec/v2 v2.22.11 h1:tW+weM/hCM/GX3iaCV91d5I6hqaRT2TPsFM1+USPXwg= -github.com/securego/gosec/v2 v2.22.11/go.mod h1:KE4MW/eH0GLWztkbt4/7XpyH0zJBBnu7sYB4l6Wn7Mw= +github.com/securego/gosec/v2 v2.24.8-0.20260309165252-619ce2117e08 h1:AoLtJX4WUtZkhhUUMFy3GgecAALp/Mb4S1iyQOA2s0U= +github.com/securego/gosec/v2 v2.24.8-0.20260309165252-619ce2117e08/go.mod h1:+XLCJiRE95ga77XInNELh2M6zQP+PdqiT9Zpm0D9Wpk= github.com/sergi/go-diff v1.4.0 h1:n/SP9D5ad1fORl+llWyN+D6qoUETXNZARKjyY2/KVCw= github.com/sergi/go-diff v1.4.0/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= @@ -668,8 +668,8 @@ github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+W github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4= github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= -github.com/sonatard/noctx v0.4.0 h1:7MC/5Gg4SQ4lhLYR6mvOP6mQVSxCrdyiExo7atBs27o= -github.com/sonatard/noctx v0.4.0/go.mod h1:64XdbzFb18XL4LporKXp8poqZtPKbCrqQ402CV+kJas= +github.com/sonatard/noctx v0.5.1 h1:wklWg9c9ZYugOAk7qG4yP4PBrlQsmSLPTvW1K4PRQMs= +github.com/sonatard/noctx v0.5.1/go.mod h1:64XdbzFb18XL4LporKXp8poqZtPKbCrqQ402CV+kJas= github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0= github.com/sourcegraph/go-diff v0.7.0/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I= @@ -734,8 +734,8 @@ github.com/ultraware/funlen v0.2.0 h1:gCHmCn+d2/1SemTdYMiKLAHFYxTYz7z9VIDRaTGyLk github.com/ultraware/funlen v0.2.0/go.mod h1:ZE0q4TsJ8T1SQcjmkhN/w+MceuatI6pBFSxxyteHIJA= github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSWoFa+g= github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= -github.com/uudashr/gocognit v1.2.0 h1:3BU9aMr1xbhPlvJLSydKwdLN3tEUUrzPSSM8S4hDYRA= -github.com/uudashr/gocognit v1.2.0/go.mod h1:k/DdKPI6XBZO1q7HgoV2juESI2/Ofj9AcHPZhBBdrTU= +github.com/uudashr/gocognit v1.2.1 h1:CSJynt5txTnORn/DkhiB4mZjwPuifyASC8/6Q0I/QS4= +github.com/uudashr/gocognit v1.2.1/go.mod h1:acaubQc6xYlXFEMb9nWX2dYBzJ/bIjEkc1zzvyIZg5Q= github.com/uudashr/iface v1.4.1 h1:J16Xl1wyNX9ofhpHmQ9h9gk5rnv2A6lX/2+APLTo0zU= github.com/uudashr/iface v1.4.1/go.mod h1:pbeBPlbuU2qkNDn0mmfrxP2X+wjPMIQAy+r1MBXSXtg= github.com/vektra/mockery/v2 v2.53.6 h1:qfUB6saauu652ZlMF/mEdlj7B/A0fw2XR0XBACBrf7Y= @@ -838,8 +838,8 @@ golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/y golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/exp/typeparams v0.0.0-20251125195548-87e1e737ad39 h1:yzGKB4T4r1nFi65o7dQ96ERTfU2trk8Ige9aqqADqf4= -golang.org/x/exp/typeparams v0.0.0-20251125195548-87e1e737ad39/go.mod h1:4Mzdyp/6jzw9auFDJ3OMF5qksa7UvPnzKqTVGcb04ms= +golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 h1:qWFG1Dj7TBjOjOvhEOkmyGPVoquqUKnIU0lEVLp8xyk= +golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358/go.mod h1:4Mzdyp/6jzw9auFDJ3OMF5qksa7UvPnzKqTVGcb04ms= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1098,8 +1098,8 @@ honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.6.1 h1:R094WgE8K4JirYjBaOpz/AvTyUu/3wbmAoskKN/pxTI= -honnef.co/go/tools v0.6.1/go.mod h1:3puzxxljPCe8RGJX7BIy1plGbxEOZni5mR2aXe3/uk4= +honnef.co/go/tools v0.7.0 h1:w6WUp1VbkqPEgLz4rkBzH/CSU6HkoqNLp6GstyTx3lU= +honnef.co/go/tools v0.7.0/go.mod h1:pm29oPxeP3P82ISxZDgIYeOaf9ta6Pi0EWvCFoLG2vc= k8s.io/api v0.33.3 h1:SRd5t//hhkI1buzxb288fy2xvjubstenEKL9K51KBI8= k8s.io/api v0.33.3/go.mod h1:01Y/iLUjNBM3TAvypct7DIj0M0NIZc+PzAHCIo0CYGE= k8s.io/apiextensions-apiserver v0.33.3 h1:qmOcAHN6DjfD0v9kxL5udB27SRP6SG/MTopmge3MwEs= From bfaf58f32fd3f760536a960f02cbf787937f0ef0 Mon Sep 17 00:00:00 2001 From: Vic Kerr Date: Thu, 21 May 2026 14:17:16 +0000 Subject: [PATCH 5/5] fixup! build(toolchain): bump go from 1.25 to 1.26 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3c9433d7d..641cbd1fa 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ionos-cloud/cluster-api-provider-proxmox -go 1.26.0 +go 1.26.3 replace ( github.com/golangci/golangci-lint/v2 => github.com/golangci/golangci-lint/v2 v2.11.4