mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-05 13:33:58 +00:00
fix(vm): Fix handling of empty kvm arguments (#228)
* fix(vm): Fix false detection of a changed VM state when KVM arguments is empty PVE returns a single space string (`" "`) when KVM arguments are not set. * fix(vm): set KVM arguments only if non-empty
This commit is contained in:
parent
19185611b3
commit
e2802d0654
@ -1977,7 +1977,6 @@ func resourceVirtualEnvironmentVMCreateCustom(
|
||||
FloatingMemory: &memoryFloating,
|
||||
IDEDevices: ideDevices,
|
||||
KeyboardLayout: &keyboardLayout,
|
||||
KVMArguments: &kvmArguments,
|
||||
NetworkDevices: networkDeviceObjects,
|
||||
OSType: &operatingSystemType,
|
||||
PCIDevices: pciDeviceObjects,
|
||||
@ -2022,6 +2021,10 @@ func resourceVirtualEnvironmentVMCreateCustom(
|
||||
createBody.Tags = &tagsString
|
||||
}
|
||||
|
||||
if kvmArguments != "" {
|
||||
createBody.KVMArguments = &kvmArguments
|
||||
}
|
||||
|
||||
if machine != "" {
|
||||
createBody.Machine = &machine
|
||||
}
|
||||
@ -3754,7 +3757,8 @@ func resourceVirtualEnvironmentVMReadPrimitiveValues(
|
||||
currentkvmArguments := d.Get(mkResourceVirtualEnvironmentVMKVMArguments).(string)
|
||||
|
||||
if len(clone) == 0 || currentkvmArguments != dvResourceVirtualEnvironmentVMKVMArguments {
|
||||
if vmConfig.KVMArguments != nil {
|
||||
// PVE API returns "args" as " " if it is set to empty.
|
||||
if vmConfig.KVMArguments != nil && len(strings.TrimSpace(*vmConfig.KVMArguments)) > 0 {
|
||||
err = d.Set(mkResourceVirtualEnvironmentVMKVMArguments, *vmConfig.KVMArguments)
|
||||
} else {
|
||||
// Default value of "args" is "" according to the API documentation.
|
||||
|
Loading…
Reference in New Issue
Block a user