From 02aad5706cedae50f698fa52b89a2de3c0ba242a Mon Sep 17 00:00:00 2001 From: mrhillsman Date: Tue, 19 May 2026 23:59:22 -0500 Subject: [PATCH] fix: replace deprecated Running field with RunStrategy in VM spec Replace the deprecated `Running: &running` boolean pointer field with `RunStrategy: kubevirtv1.RunStrategyAlways` in the VirtualMachine spec. The Running field was deprecated in KubeVirt 1.0+ and may be removed in future releases. Also updated the corresponding test to verify RunStrategy instead of the deprecated Running field. Fixes #9 Signed-Off-By: Melvin Hillsman --- internal/vm/vm.go | 4 ++-- internal/vm/vm_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/vm/vm.go b/internal/vm/vm.go index 65449c0..18b06e4 100644 --- a/internal/vm/vm.go +++ b/internal/vm/vm.go @@ -40,7 +40,7 @@ type VMSpecOpts struct { // It configures a containerDisk for the OS image, cloudInitNoCloud for userdata, // masquerade networking, and virtio disk bus. func BuildVMSpec(opts VMSpecOpts) *kubevirtv1.VirtualMachine { - running := true + runStrategy := kubevirtv1.RunStrategyAlways disks := []kubevirtv1.Disk{ { @@ -109,7 +109,7 @@ func BuildVMSpec(opts VMSpecOpts) *kubevirtv1.VirtualMachine { Labels: opts.Labels, }, Spec: kubevirtv1.VirtualMachineSpec{ - Running: &running, + RunStrategy: &runStrategy, Template: &kubevirtv1.VirtualMachineInstanceTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: opts.Labels, diff --git a/internal/vm/vm_test.go b/internal/vm/vm_test.go index 72aa776..3aaf674 100644 --- a/internal/vm/vm_test.go +++ b/internal/vm/vm_test.go @@ -99,9 +99,9 @@ var _ = Describe("BuildVMSpec", func() { Expect(memReq.Equal(expected)).To(BeTrue()) }) - It("should set running to true", func() { - Expect(result.Spec.Running).NotTo(BeNil()) - Expect(*result.Spec.Running).To(BeTrue()) + It("should set RunStrategy to Always", func() { + Expect(result.Spec.RunStrategy).NotTo(BeNil()) + Expect(*result.Spec.RunStrategy).To(Equal(kubevirtv1.RunStrategyAlways)) }) It("should configure masquerade networking", func() {