Skip to content

Commit

Permalink
cleanup in kubevirt.go
Browse files Browse the repository at this point in the history
Signed-off-by: Arik Hadas <[email protected]>
  • Loading branch information
ahadas committed Jun 18, 2024
1 parent 9969e1b commit 187243c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions pkg/controller/plan/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -920,27 +920,25 @@ 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
}
r.Log.Info("setting vm firmware", "vmId", vm.ID, "firmware", firmware)
vm.Firmware = firmware
r.Log.Info("setting vm firmware", "vmId", vm.ID, "firmware", vm.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)
Expand Down

0 comments on commit 187243c

Please sign in to comment.