From e10d2875ba62ec879d05c7121eafb0f3f881ead6 Mon Sep 17 00:00:00 2001 From: Bella Khizgiyaev Date: Tue, 12 Mar 2024 11:08:45 +0200 Subject: [PATCH] minor changes Signed-off-by: Bella Khizgiyaev --- pkg/controller/plan/adapter/ova/kubevirtvmparser.go | 4 +++- pkg/controller/plan/kubevirt.go | 6 ++---- virt-v2v/cold/entrypoint.go | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/controller/plan/adapter/ova/kubevirtvmparser.go b/pkg/controller/plan/adapter/ova/kubevirtvmparser.go index 1297eac16..1c2955fe5 100644 --- a/pkg/controller/plan/adapter/ova/kubevirtvmparser.go +++ b/pkg/controller/plan/adapter/ova/kubevirtvmparser.go @@ -1,6 +1,7 @@ package ova import ( + liberr "github.com/konveyor/forklift-controller/pkg/lib/error" "gopkg.in/yaml.v2" ) @@ -38,7 +39,7 @@ type EFI struct { SecureBoot bool `yaml:"secureBoot"` } -func ReadConfFromYaml(yamlData []byte) (firmware string, err error) { +func GetFirmwareFromYaml(yamlData []byte) (firmware string, err error) { var vmi VirtualMachineInstance if err = yaml.Unmarshal(yamlData, &vmi); err != nil { return @@ -52,5 +53,6 @@ func ReadConfFromYaml(yamlData []byte) (firmware string, err error) { firmware = "efi" return } + err = liberr.New("Firmware type was not detected") return } diff --git a/pkg/controller/plan/kubevirt.go b/pkg/controller/plan/kubevirt.go index 5c23011af..2f7629f6a 100644 --- a/pkg/controller/plan/kubevirt.go +++ b/pkg/controller/plan/kubevirt.go @@ -882,14 +882,12 @@ func (r *KubeVirt) UpdateVmByConvertedConfig(vm *plan.VMStatus, pod *core.Pod, s return } - vm.Firmware, err = yamlparser.ReadConfFromYaml(vmConf) + vm.Firmware, err = yamlparser.GetFirmwareFromYaml(vmConf) if err != nil { r.Log.Error(err, "failed to get firmware configuration") } - r.Log.Info("Setting the vm firmware", - "vm", - vm.String()) + r.Log.Info("Setting the vm firmware ", vm.Firmware, "vmId", vm.ID) shutdownURL := fmt.Sprintf("http://%s:8080/shutdown", pod.Status.PodIP) resp, err = http.Post(shutdownURL, "application/json", nil) diff --git a/virt-v2v/cold/entrypoint.go b/virt-v2v/cold/entrypoint.go index 3a749e90a..c2ad68fd1 100644 --- a/virt-v2v/cold/entrypoint.go +++ b/virt-v2v/cold/entrypoint.go @@ -264,8 +264,8 @@ func vmHandler(w http.ResponseWriter, r *http.Request) { err := addFirmwareToYaml(yamlFilePath) if err != nil { - fmt.Printf("Error setting yaml file: %v\n", err) - http.Error(w, "Error setting yaml file", http.StatusInternalServerError) + fmt.Printf("Error modifying vm configuration: %v\n", err) + http.Error(w, "Error modifying vm configuration:", http.StatusInternalServerError) } yamlData, err := os.ReadFile(yamlFilePath)