From 7a6668f690047d61552001dd175fbf3ccf9b3eeb Mon Sep 17 00:00:00 2001 From: Frederic Mereu Date: Tue, 24 Oct 2023 08:37:15 +0200 Subject: [PATCH] fix: pointer comparison --- nutanix/resource_nutanix_virtual_machine.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nutanix/resource_nutanix_virtual_machine.go b/nutanix/resource_nutanix_virtual_machine.go index f1180293d..29134cad0 100644 --- a/nutanix/resource_nutanix_virtual_machine.go +++ b/nutanix/resource_nutanix_virtual_machine.go @@ -1255,15 +1255,20 @@ func getVMSpecVersion(conn *v3.Client, vmID string) (*int64, error) { func bootConfigHasChange(boot *v3.VMBootConfig, d *schema.ResourceData) (*v3.VMBootConfig, bool) { hotPlugChange := false + bootConfig := &v3.VMBootConfig{} + if boot != nil { + *bootConfig = *boot + } + if d.HasChange("boot_device_order_list") { _, n := d.GetChange("boot_device_order_list") - boot.BootDeviceOrderList = expandStringList(n.([]interface{})) + bootConfig.BootDeviceOrderList = expandStringList(n.([]interface{})) hotPlugChange = false } if d.HasChange("boot_type") { _, n := d.GetChange("boot_type") - boot.BootType = utils.StringPtr(n.(string)) + bootConfig.BootType = utils.StringPtr(n.(string)) hotPlugChange = false } @@ -1284,13 +1289,13 @@ func bootConfigHasChange(boot *v3.VMBootConfig, d *schema.ResourceData) (*v3.VMB bd.MacAddress = utils.StringPtr(n.(string)) hotPlugChange = false } - boot.BootDevice = bd + bootConfig.BootDevice = bd if dska.AdapterType == nil && dska.DeviceIndex == nil && bd.MacAddress == nil { - boot.BootDevice = nil + bootConfig.BootDevice = nil } - return boot, hotPlugChange + return bootConfig, hotPlugChange } func changePowerState(ctx context.Context, conn *v3.Client, id string, powerState string) error {