From 0d37a47d49a45a440a5ba272d18ff1cc56a8a142 Mon Sep 17 00:00:00 2001 From: thorntonmc Date: Thu, 30 Nov 2023 19:34:53 +0300 Subject: [PATCH] type check memory --- proxmox/config_qemu.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/proxmox/config_qemu.go b/proxmox/config_qemu.go index aeedcd42..914e51b1 100644 --- a/proxmox/config_qemu.go +++ b/proxmox/config_qemu.go @@ -517,7 +517,16 @@ func (ConfigQemu) mapToStruct(params map[string]interface{}) (*ConfigQemu, error config.Hookscript = params["hookscript"].(string) } if _, isSet := params["memory"]; isSet { - config.Memory = int(params["memory"].(float64)) + switch params["memory"].(type) { + case float64: + config.Memory = int(params["memory"].(float64)) + case string: + mem, err := strconv.ParseFloat(params["memory"].(string), 64) + if err != nil { + return nil, err + } + config.Memory = int(mem) + } } if _, isSet := params["name"]; isSet { config.Name = params["name"].(string)