From 43cbc51b18ec0a4b63c46a914982783b868004cf Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Fri, 26 Jul 2024 15:45:48 +0200 Subject: [PATCH] fix: can't clear `description` --- proxmox/config_qemu.go | 10 +++------- proxmox/config_qemu_test.go | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/proxmox/config_qemu.go b/proxmox/config_qemu.go index 8160e0ab..eed6fe53 100644 --- a/proxmox/config_qemu.go +++ b/proxmox/config_qemu.go @@ -183,19 +183,15 @@ func (config ConfigQemu) mapToAPI(currentConfig ConfigQemu, version Version) (re if config.Boot != "" { params["boot"] = config.Boot } + if config.Description != nil && (*config.Description != "" || currentConfig.Description != nil) { + params["description"] = *config.Description + } if config.QemuCores != 0 { params["cores"] = config.QemuCores } if config.QemuCpu != "" { params["cpu"] = config.QemuCpu } - if config.Description != nil { - if *config.Description != "" { - params["description"] = *config.Description - } else if currentConfig.Description != nil { - itemsToDelete += ",description" - } - } if config.Hookscript != "" { params["hookscript"] = config.Hookscript } diff --git a/proxmox/config_qemu_test.go b/proxmox/config_qemu_test.go index 983c09b4..81d17005 100644 --- a/proxmox/config_qemu_test.go +++ b/proxmox/config_qemu_test.go @@ -630,7 +630,7 @@ func Test_ConfigQemu_mapToAPI(t *testing.T) { {name: `Description empty`, config: &ConfigQemu{Description: util.Pointer("")}, currentConfig: ConfigQemu{Description: util.Pointer("old description")}, - output: map[string]interface{}{"delete": "description"}}}}, + output: map[string]interface{}{"description": ""}}}}, {category: `Disks.Ide`, update: []test{ {name: `Disk.Ide.Disk_X DELETE`,