From d01d8319da832b8747041b508dabc1d8f2a1aaf2 Mon Sep 17 00:00:00 2001 From: Arik Hadas Date: Tue, 18 Jun 2024 09:49:02 +0300 Subject: [PATCH] cleanup in kubevirt.go Signed-off-by: Arik Hadas --- pkg/controller/plan/kubevirt.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/controller/plan/kubevirt.go b/pkg/controller/plan/kubevirt.go index 98e3a94f0..9888436a9 100644 --- a/pkg/controller/plan/kubevirt.go +++ b/pkg/controller/plan/kubevirt.go @@ -924,27 +924,24 @@ func (r *KubeVirt) UpdateVmByConvertedConfig(vm *plan.VMStatus, pod *core.Pod, s } defer resp.Body.Close() - vmConfigXML, err := io.ReadAll(resp.Body) + vmConfigBytes, err := io.ReadAll(resp.Body) if err != nil { + err = liberr.Wrap(err) return } + vmConfigXML := string(vmConfigBytes) switch r.Source.Provider.Type() { case api.Ova: - firmware, erro := ovfparser.GetFirmwareFromConfig(string(vmConfigXML)) - if erro != nil { - err = erro + if vm.Firmware, err = ovfparser.GetFirmwareFromConfig(vmConfigXML); err != nil { + err = liberr.Wrap(err) return } - - vm.Firmware = firmware case api.VSphere: - os, erro := ovfparser.GetOperationSystemFromConfig(string(vmConfigXML)) - if erro != nil { - err = erro + if vm.OperatingSystem, err = ovfparser.GetOperationSystemFromConfig(vmConfigXML); err != nil { + err = liberr.Wrap(err) return } - vm.OperatingSystem = os } shutdownURL := fmt.Sprintf("http://%s:8080/shutdown", pod.Status.PodIP)