From bbcc9e19d7e970919939483febdf7c888b096bcb 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 --- 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 bd814908b..2ef7e5f70 100644 --- a/pkg/controller/plan/kubevirt.go +++ b/pkg/controller/plan/kubevirt.go @@ -920,27 +920,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)