From fd1f866a8de9d03b514cc4aa70f80e548825b3ce Mon Sep 17 00:00:00 2001 From: Tinyblargon <76069640+Tinyblargon@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:46:57 +0200 Subject: [PATCH] fix: can't clear description --- go.mod | 2 +- go.sum | 4 ++-- proxmox/resource_vm_qemu.go | 13 ++++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 43534dbd..6ab59dcc 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 toolchain go1.21.0 require ( - github.com/Telmate/proxmox-api-go v0.0.0-20240623131159-931b286955ba + github.com/Telmate/proxmox-api-go v0.0.0-20240726134822-4c4580d03d9e github.com/google/uuid v1.6.0 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0 diff --git a/go.sum b/go.sum index e91f5c2b..66fed86c 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/ProtonMail/go-crypto v1.1.0-alpha.2-proton h1:HKz85FwoXx86kVtTvFke7rgHvq/HoloSUvW5semjFWs= github.com/ProtonMail/go-crypto v1.1.0-alpha.2-proton/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= -github.com/Telmate/proxmox-api-go v0.0.0-20240623131159-931b286955ba h1:3LHJ7Y6/8KC6fUo5XKi/+WvNVuA7kY9Xz+pp7bUznlo= -github.com/Telmate/proxmox-api-go v0.0.0-20240623131159-931b286955ba/go.mod h1:O6yNUi0hG9GQLMBgpikSvbnuek1OMweFtbac1sfGuUs= +github.com/Telmate/proxmox-api-go v0.0.0-20240726134822-4c4580d03d9e h1:e2StaFGv+J2yhCP29DBQmchLQHNqbCnLomZGx66p6/Q= +github.com/Telmate/proxmox-api-go v0.0.0-20240726134822-4c4580d03d9e/go.mod h1:O6yNUi0hG9GQLMBgpikSvbnuek1OMweFtbac1sfGuUs= github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= diff --git a/proxmox/resource_vm_qemu.go b/proxmox/resource_vm_qemu.go index ed873971..3d09b1c9 100755 --- a/proxmox/resource_vm_qemu.go +++ b/proxmox/resource_vm_qemu.go @@ -876,7 +876,7 @@ func resourceVmQemuCreate(ctx context.Context, d *schema.ResourceData, meta inte config := pxapi.ConfigQemu{ Name: vmName, - Description: d.Get("desc").(string), + Description: pointer(d.Get("desc").(string)), Pool: pointer(pxapi.PoolName(d.Get("pool").(string))), Bios: d.Get("bios").(string), Onboot: pointer(d.Get("onboot").(bool)), @@ -1138,7 +1138,7 @@ func resourceVmQemuUpdate(ctx context.Context, d *schema.ResourceData, meta inte config := pxapi.ConfigQemu{ Name: d.Get("name").(string), - Description: d.Get("desc").(string), + Description: pointer(d.Get("desc").(string)), Pool: pointer(pxapi.PoolName(d.Get("pool").(string))), Bios: d.Get("bios").(string), Onboot: pointer(d.Get("onboot").(bool)), @@ -1426,7 +1426,7 @@ func resourceVmQemuRead(ctx context.Context, d *schema.ResourceData, meta interf d.SetId(resourceId(vmr.Node(), "qemu", vmr.VmId())) d.Set("name", config.Name) - d.Set("desc", config.Description) + d.Set("desc", mapToTerraform_Description(config.Description)) d.Set("bios", config.Bios) d.Set("onboot", config.Onboot) d.Set("startup", config.Startup) @@ -1987,6 +1987,13 @@ func mapToTerraform_CloudInitNetworkConfig(config pxapi.CloudInitNetworkConfig) return "" } +func mapToTerraform_Description(description *string) string { + if description != nil { + return *description + } + return "" +} + func mapFormStruct_IsoFile(config *pxapi.IsoFile) string { if config == nil { return ""