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,
|
FloatingMemory: &memoryFloating,
|
||||||
IDEDevices: ideDevices,
|
IDEDevices: ideDevices,
|
||||||
KeyboardLayout: &keyboardLayout,
|
KeyboardLayout: &keyboardLayout,
|
||||||
KVMArguments: &kvmArguments,
|
|
||||||
NetworkDevices: networkDeviceObjects,
|
NetworkDevices: networkDeviceObjects,
|
||||||
OSType: &operatingSystemType,
|
OSType: &operatingSystemType,
|
||||||
PCIDevices: pciDeviceObjects,
|
PCIDevices: pciDeviceObjects,
|
||||||
@ -2022,6 +2021,10 @@ func resourceVirtualEnvironmentVMCreateCustom(
|
|||||||
createBody.Tags = &tagsString
|
createBody.Tags = &tagsString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if kvmArguments != "" {
|
||||||
|
createBody.KVMArguments = &kvmArguments
|
||||||
|
}
|
||||||
|
|
||||||
if machine != "" {
|
if machine != "" {
|
||||||
createBody.Machine = &machine
|
createBody.Machine = &machine
|
||||||
}
|
}
|
||||||
@ -3754,7 +3757,8 @@ func resourceVirtualEnvironmentVMReadPrimitiveValues(
|
|||||||
currentkvmArguments := d.Get(mkResourceVirtualEnvironmentVMKVMArguments).(string)
|
currentkvmArguments := d.Get(mkResourceVirtualEnvironmentVMKVMArguments).(string)
|
||||||
|
|
||||||
if len(clone) == 0 || currentkvmArguments != dvResourceVirtualEnvironmentVMKVMArguments {
|
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)
|
err = d.Set(mkResourceVirtualEnvironmentVMKVMArguments, *vmConfig.KVMArguments)
|
||||||
} else {
|
} else {
|
||||||
// Default value of "args" is "" according to the API documentation.
|
// Default value of "args" is "" according to the API documentation.
|
||||||
|
Loading…
Reference in New Issue
Block a user