From 8d0b3ed25fa1c2dcc0d319d725aea34f3e18aef8 Mon Sep 17 00:00:00 2001 From: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Date: Thu, 10 Aug 2023 15:27:22 -0400 Subject: [PATCH] fix(vm): default disk cache is not set to `none` if not specified for an existing disk (#478) Also fixes missing `ForceNew` for `file` resources. --- Makefile | 1 - proxmoxtf/resource/file.go | 1 + proxmoxtf/resource/vm.go | 5 +++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 306e8da7..ea334660 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,6 @@ example: example-build example-init example-apply example-destroy example-apply: export TF_CLI_CONFIG_FILE="$(shell pwd -P)/example.tfrc" \ - && export TF_REATTACH_PROVIDERS='{"registry.terraform.io/bpg/proxmox":{"Protocol":"grpc","ProtocolVersion":6,"Pid":82711,"Test":true,"Addr":{"Network":"unix","String":"/var/folders/xx/4plpx_3133lbctp7b7v1yfch0000gn/T/plugin3121225613"}}}' \ && export TF_DISABLE_CHECKPOINT="true" \ && export TF_PLUGIN_CACHE_DIR="$(TERRAFORM_PLUGIN_CACHE_DIRECTORY)" \ && cd ./example \ diff --git a/proxmoxtf/resource/file.go b/proxmoxtf/resource/file.go index 8fc82c32..016d133d 100644 --- a/proxmoxtf/resource/file.go +++ b/proxmoxtf/resource/file.go @@ -196,6 +196,7 @@ func File() *schema.Resource { Type: schema.TypeInt, Description: "Timeout for uploading ISO/VSTMPL files in seconds", Optional: true, + ForceNew: true, Default: dvResourceVirtualEnvironmentFileTimeoutUpload, }, }, diff --git a/proxmoxtf/resource/vm.go b/proxmoxtf/resource/vm.go index e09548a6..41ce0c78 100644 --- a/proxmoxtf/resource/vm.go +++ b/proxmoxtf/resource/vm.go @@ -3706,13 +3706,13 @@ func vmReadCustom( if dd.Discard != nil { disk[mkResourceVirtualEnvironmentVMDiskDiscard] = *dd.Discard } else { - disk[mkResourceVirtualEnvironmentVMDiskDiscard] = "" + disk[mkResourceVirtualEnvironmentVMDiskDiscard] = dvResourceVirtualEnvironmentVMDiskDiscard } if dd.Cache != nil { disk[mkResourceVirtualEnvironmentVMDiskCache] = *dd.Cache } else { - disk[mkResourceVirtualEnvironmentVMDiskCache] = "" + disk[mkResourceVirtualEnvironmentVMDiskCache] = dvResourceVirtualEnvironmentVMDiskCache } diskMap[di] = disk @@ -5007,6 +5007,7 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D tmp.BurstableWriteSpeedMbps = value.BurstableWriteSpeedMbps tmp.MaxReadSpeedMbps = value.MaxReadSpeedMbps tmp.MaxWriteSpeedMbps = value.MaxWriteSpeedMbps + tmp.Cache = value.Cache switch prefix { case "virtio":