Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vm): Fix handling of empty kvm arguments #228

Merged
merged 2 commits into from
Feb 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions proxmoxtf/resource_virtual_environment_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,6 @@ func resourceVirtualEnvironmentVMCreateCustom(
FloatingMemory: &memoryFloating,
IDEDevices: ideDevices,
KeyboardLayout: &keyboardLayout,
KVMArguments: &kvmArguments,
NetworkDevices: networkDeviceObjects,
OSType: &operatingSystemType,
PCIDevices: pciDeviceObjects,
Expand Down Expand Up @@ -2022,6 +2021,10 @@ func resourceVirtualEnvironmentVMCreateCustom(
createBody.Tags = &tagsString
}

if kvmArguments != "" {
createBody.KVMArguments = &kvmArguments
}

if machine != "" {
createBody.Machine = &machine
}
Expand Down Expand Up @@ -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.
Expand Down