Skip to content

Commit

Permalink
chore(refactoring): remove accidentally added types2 import alias (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bpg authored Jul 3, 2023
1 parent f494525 commit feac6b0
Show file tree
Hide file tree
Showing 9 changed files with 439 additions and 444 deletions.
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions proxmox/types/helpers.go → internal/types/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@

package types

import "github.com/bpg/terraform-provider-proxmox/internal/types"

// StrPtr returns a pointer to a string.
func StrPtr(s string) *string {
return &s
}

// BoolPtr returns a pointer to a bool.
func BoolPtr(s bool) *types.CustomBool {
customBool := types.CustomBool(s)
func BoolPtr(s bool) *CustomBool {
customBool := CustomBool(s)
return &customBool
}
File renamed without changes.

Large diffs are not rendered by default.

629 changes: 314 additions & 315 deletions proxmox/nodes/vms/vms_types.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion proxmox/nodes/vms/vms_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/bpg/terraform-provider-proxmox/proxmox/types"
"github.com/bpg/terraform-provider-proxmox/internal/types"
)

func TestCustomStorageDevice_UnmarshalJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion proxmoxtf/resource/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

"github.com/bpg/terraform-provider-proxmox/internal/types"
"github.com/bpg/terraform-provider-proxmox/proxmox/nodes/vms"
"github.com/bpg/terraform-provider-proxmox/proxmox/types"
)

func getBIOSValidator() schema.SchemaValidateDiagFunc {
Expand Down
83 changes: 41 additions & 42 deletions proxmoxtf/resource/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

types2 "github.com/bpg/terraform-provider-proxmox/internal/types"
"github.com/bpg/terraform-provider-proxmox/internal/types"
"github.com/bpg/terraform-provider-proxmox/proxmox/cluster"
"github.com/bpg/terraform-provider-proxmox/proxmox/nodes/vms"
"github.com/bpg/terraform-provider-proxmox/proxmox/types"
"github.com/bpg/terraform-provider-proxmox/proxmoxtf"
)

Expand Down Expand Up @@ -1396,7 +1395,7 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
}
}

fullCopy := types2.CustomBool(cloneFull)
fullCopy := types.CustomBool(cloneFull)

cloneBody := &vms.CloneRequestBody{
FullCopy: &fullCopy,
Expand Down Expand Up @@ -1477,7 +1476,7 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
}

// Migrate to target node
withLocalDisks := types2.CustomBool(true)
withLocalDisks := types.CustomBool(true)
migrateBody := &vms.MigrateRequestBody{
TargetNode: nodeName,
WithLocalDisks: &withLocalDisks,
Expand Down Expand Up @@ -1511,7 +1510,7 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
}

// Now that the virtual machine has been cloned, we need to perform some modifications.
acpi := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMACPI).(bool))
acpi := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMACPI).(bool))
agent := d.Get(mkResourceVirtualEnvironmentVMAgent).([]interface{})
audioDevices := vmGetAudioDeviceList(d)

Expand All @@ -1527,9 +1526,9 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
networkDevice := d.Get(mkResourceVirtualEnvironmentVMNetworkDevice).([]interface{})
operatingSystem := d.Get(mkResourceVirtualEnvironmentVMOperatingSystem).([]interface{})
serialDevice := d.Get(mkResourceVirtualEnvironmentVMSerialDevice).([]interface{})
onBoot := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMOnBoot).(bool))
tabletDevice := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTabletDevice).(bool))
template := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTemplate).(bool))
onBoot := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMOnBoot).(bool))
tabletDevice := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTabletDevice).(bool))
template := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTemplate).(bool))
vga := d.Get(mkResourceVirtualEnvironmentVMVGA).([]interface{})

updateBody := &vms.UpdateRequestBody{
Expand All @@ -1548,10 +1547,10 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
if len(agent) > 0 {
agentBlock := agent[0].(map[string]interface{})

agentEnabled := types2.CustomBool(
agentEnabled := types.CustomBool(
agentBlock[mkResourceVirtualEnvironmentVMAgentEnabled].(bool),
)
agentTrim := types2.CustomBool(agentBlock[mkResourceVirtualEnvironmentVMAgentTrim].(bool))
agentTrim := types.CustomBool(agentBlock[mkResourceVirtualEnvironmentVMAgentTrim].(bool))
agentType := agentBlock[mkResourceVirtualEnvironmentVMAgentType].(string)

updateBody.Agent = &vms.CustomAgent{
Expand Down Expand Up @@ -1618,7 +1617,7 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
cpuCores := cpuBlock[mkResourceVirtualEnvironmentVMCPUCores].(int)
cpuFlags := cpuBlock[mkResourceVirtualEnvironmentVMCPUFlags].([]interface{})
cpuHotplugged := cpuBlock[mkResourceVirtualEnvironmentVMCPUHotplugged].(int)
cpuNUMA := types2.CustomBool(cpuBlock[mkResourceVirtualEnvironmentVMCPUNUMA].(bool))
cpuNUMA := types.CustomBool(cpuBlock[mkResourceVirtualEnvironmentVMCPUNUMA].(bool))
cpuSockets := cpuBlock[mkResourceVirtualEnvironmentVMCPUSockets].(int)
cpuType := cpuBlock[mkResourceVirtualEnvironmentVMCPUType].(string)
cpuUnits := cpuBlock[mkResourceVirtualEnvironmentVMCPUUnits].(int)
Expand Down Expand Up @@ -1841,7 +1840,7 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
)
}

deleteOriginalDisk := types2.CustomBool(true)
deleteOriginalDisk := types.CustomBool(true)

diskMoveBody := &vms.MoveDiskRequestBody{
DeleteOriginalDisk: &deleteOriginalDisk,
Expand Down Expand Up @@ -1912,7 +1911,7 @@ func vmCreateClone(ctx context.Context, d *schema.ResourceData, m interface{}) d
)
}

deleteOriginalDisk := types2.CustomBool(true)
deleteOriginalDisk := types.CustomBool(true)

diskMoveBody := &vms.MoveDiskRequestBody{
DeleteOriginalDisk: &deleteOriginalDisk,
Expand Down Expand Up @@ -1953,7 +1952,7 @@ func vmCreateCustom(ctx context.Context, d *schema.ResourceData, m interface{})

resource := VM()

acpi := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMACPI).(bool))
acpi := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMACPI).(bool))

agentBlock, err := getSchemaBlock(
resource,
Expand All @@ -1966,10 +1965,10 @@ func vmCreateCustom(ctx context.Context, d *schema.ResourceData, m interface{})
return diag.FromErr(err)
}

agentEnabled := types2.CustomBool(
agentEnabled := types.CustomBool(
agentBlock[mkResourceVirtualEnvironmentVMAgentEnabled].(bool),
)
agentTrim := types2.CustomBool(agentBlock[mkResourceVirtualEnvironmentVMAgentTrim].(bool))
agentTrim := types.CustomBool(agentBlock[mkResourceVirtualEnvironmentVMAgentTrim].(bool))
agentType := agentBlock[mkResourceVirtualEnvironmentVMAgentType].(string)

kvmArguments := d.Get(mkResourceVirtualEnvironmentVMKVMArguments).(string)
Expand Down Expand Up @@ -2015,7 +2014,7 @@ func vmCreateCustom(ctx context.Context, d *schema.ResourceData, m interface{})
cpuFlags := cpuBlock[mkResourceVirtualEnvironmentVMCPUFlags].([]interface{})
cpuHotplugged := cpuBlock[mkResourceVirtualEnvironmentVMCPUHotplugged].(int)
cpuSockets := cpuBlock[mkResourceVirtualEnvironmentVMCPUSockets].(int)
cpuNUMA := types2.CustomBool(cpuBlock[mkResourceVirtualEnvironmentVMCPUNUMA].(bool))
cpuNUMA := types.CustomBool(cpuBlock[mkResourceVirtualEnvironmentVMCPUNUMA].(bool))
cpuType := cpuBlock[mkResourceVirtualEnvironmentVMCPUType].(string)
cpuUnits := cpuBlock[mkResourceVirtualEnvironmentVMCPUUnits].(int)

Expand All @@ -2034,7 +2033,7 @@ func vmCreateCustom(ctx context.Context, d *schema.ResourceData, m interface{})
datastoreID, _ := block[mkResourceVirtualEnvironmentVMEFIDiskDatastoreID].(string)
fileFormat, _ := block[mkResourceVirtualEnvironmentVMEFIDiskFileFormat].(string)
efiType, _ := block[mkResourceVirtualEnvironmentVMEFIDiskType].(string)
preEnrolledKeys := types2.CustomBool(block[mkResourceVirtualEnvironmentVMEFIDiskPreEnrolledKeys].(bool))
preEnrolledKeys := types.CustomBool(block[mkResourceVirtualEnvironmentVMEFIDiskPreEnrolledKeys].(bool))

if fileFormat == "" {
fileFormat = dvResourceVirtualEnvironmentVMEFIDiskFileFormat
Expand Down Expand Up @@ -2107,9 +2106,9 @@ func vmCreateCustom(ctx context.Context, d *schema.ResourceData, m interface{})

serialDevices := vmGetSerialDeviceList(d)

onBoot := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMOnBoot).(bool))
tabletDevice := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTabletDevice).(bool))
template := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTemplate).(bool))
onBoot := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMOnBoot).(bool))
tabletDevice := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTabletDevice).(bool))
template := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTemplate).(bool))

vgaDevice, err := vmGetVGADeviceObject(d)
if err != nil {
Expand Down Expand Up @@ -2334,8 +2333,8 @@ func vmCreateCustomDisks(ctx context.Context, d *schema.ResourceData, m interfac
size, _ := block[mkResourceVirtualEnvironmentVMDiskSize].(int)
speed := block[mkResourceVirtualEnvironmentVMDiskSpeed].([]interface{})
diskInterface, _ := block[mkResourceVirtualEnvironmentVMDiskInterface].(string)
ioThread := types2.CustomBool(block[mkResourceVirtualEnvironmentVMDiskIOThread].(bool))
ssd := types2.CustomBool(block[mkResourceVirtualEnvironmentVMDiskSSD].(bool))
ioThread := types.CustomBool(block[mkResourceVirtualEnvironmentVMDiskIOThread].(bool))
ssd := types.CustomBool(block[mkResourceVirtualEnvironmentVMDiskSSD].(bool))
discard, _ := block[mkResourceVirtualEnvironmentVMDiskDiscard].(string)

if fileFormat == "" {
Expand Down Expand Up @@ -2696,8 +2695,8 @@ func vmGetDiskDeviceObjects(
fileID, _ := block[mkResourceVirtualEnvironmentVMDiskFileID].(string)
size, _ := block[mkResourceVirtualEnvironmentVMDiskSize].(int)
diskInterface, _ := block[mkResourceVirtualEnvironmentVMDiskInterface].(string)
ioThread := types2.CustomBool(block[mkResourceVirtualEnvironmentVMDiskIOThread].(bool))
ssd := types2.CustomBool(block[mkResourceVirtualEnvironmentVMDiskSSD].(bool))
ioThread := types.CustomBool(block[mkResourceVirtualEnvironmentVMDiskIOThread].(bool))
ssd := types.CustomBool(block[mkResourceVirtualEnvironmentVMDiskSSD].(bool))
discard := block[mkResourceVirtualEnvironmentVMDiskDiscard].(string)

speedBlock, err := getSchemaBlock(
Expand Down Expand Up @@ -2796,7 +2795,7 @@ func vmGetEfiDisk(d *schema.ResourceData, disk []interface{}) *vms.CustomEFIDisk
datastoreID, _ := block[mkResourceVirtualEnvironmentVMEFIDiskDatastoreID].(string)
fileFormat, _ := block[mkResourceVirtualEnvironmentVMEFIDiskFileFormat].(string)
efiType, _ := block[mkResourceVirtualEnvironmentVMEFIDiskType].(string)
preEnrolledKeys := types2.CustomBool(block[mkResourceVirtualEnvironmentVMEFIDiskPreEnrolledKeys].(bool))
preEnrolledKeys := types.CustomBool(block[mkResourceVirtualEnvironmentVMEFIDiskPreEnrolledKeys].(bool))

// special case for efi disk, the size is ignored, see docs for more info
efiDiskConfig.FileVolume = fmt.Sprintf("%s:1", datastoreID)
Expand Down Expand Up @@ -2850,12 +2849,12 @@ func vmGetHostPCIDeviceObjects(d *schema.ResourceData) vms.CustomPCIDevices {

ids, _ := block[mkResourceVirtualEnvironmentVMHostPCIDeviceID].(string)
mdev, _ := block[mkResourceVirtualEnvironmentVMHostPCIDeviceMDev].(string)
pcie := types2.CustomBool(block[mkResourceVirtualEnvironmentVMHostPCIDevicePCIE].(bool))
rombar := types2.CustomBool(
pcie := types.CustomBool(block[mkResourceVirtualEnvironmentVMHostPCIDevicePCIE].(bool))
rombar := types.CustomBool(
block[mkResourceVirtualEnvironmentVMHostPCIDeviceROMBAR].(bool),
)
romfile, _ := block[mkResourceVirtualEnvironmentVMHostPCIDeviceROMFile].(string)
xvga := types2.CustomBool(block[mkResourceVirtualEnvironmentVMHostPCIDeviceXVGA].(bool))
xvga := types.CustomBool(block[mkResourceVirtualEnvironmentVMHostPCIDeviceXVGA].(bool))

device := vms.CustomPCIDevice{
DeviceIDs: strings.Split(ids, ";"),
Expand Down Expand Up @@ -2890,7 +2889,7 @@ func vmGetNetworkDeviceObjects(d *schema.ResourceData) vms.CustomNetworkDevices

bridge := block[mkResourceVirtualEnvironmentVMNetworkDeviceBridge].(string)
enabled := block[mkResourceVirtualEnvironmentVMNetworkDeviceEnabled].(bool)
firewall := types2.CustomBool(block[mkResourceVirtualEnvironmentVMNetworkDeviceFirewall].(bool))
firewall := types.CustomBool(block[mkResourceVirtualEnvironmentVMNetworkDeviceFirewall].(bool))
macAddress := block[mkResourceVirtualEnvironmentVMNetworkDeviceMACAddress].(string)
model := block[mkResourceVirtualEnvironmentVMNetworkDeviceModel].(string)
rateLimit := block[mkResourceVirtualEnvironmentVMNetworkDeviceRateLimit].(float64)
Expand Down Expand Up @@ -3006,7 +3005,7 @@ func vmGetVGADeviceObject(d *schema.ResourceData) (*vms.CustomVGADevice, error)
return nil, err
}

vgaEnabled := types2.CustomBool(vgaBlock[mkResourceVirtualEnvironmentVMAgentEnabled].(bool))
vgaEnabled := types.CustomBool(vgaBlock[mkResourceVirtualEnvironmentVMAgentEnabled].(bool))
vgaMemory := vgaBlock[mkResourceVirtualEnvironmentVMVGAMemory].(int)
vgaType := vgaBlock[mkResourceVirtualEnvironmentVMVGAType].(string)

Expand Down Expand Up @@ -4346,7 +4345,7 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D

// Prepare the new primitive configuration values.
if d.HasChange(mkResourceVirtualEnvironmentVMACPI) {
acpi := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMACPI).(bool))
acpi := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMACPI).(bool))
updateBody.ACPI = &acpi
rebootRequired = true
}
Expand All @@ -4369,7 +4368,7 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
}

if d.HasChange(mkResourceVirtualEnvironmentVMOnBoot) {
startOnBoot := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMOnBoot).(bool))
startOnBoot := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMOnBoot).(bool))
updateBody.StartOnBoot = &startOnBoot
}

Expand Down Expand Up @@ -4399,12 +4398,12 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
}

if d.HasChange(mkResourceVirtualEnvironmentVMTabletDevice) {
tabletDevice := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTabletDevice).(bool))
tabletDevice := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTabletDevice).(bool))
updateBody.TabletDeviceEnabled = &tabletDevice
rebootRequired = true
}

template := types2.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTemplate).(bool))
template := types.CustomBool(d.Get(mkResourceVirtualEnvironmentVMTemplate).(bool))

if d.HasChange(mkResourceVirtualEnvironmentVMTemplate) {
updateBody.Template = &template
Expand All @@ -4424,10 +4423,10 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
return diag.FromErr(err)
}

agentEnabled := types2.CustomBool(
agentEnabled := types.CustomBool(
agentBlock[mkResourceVirtualEnvironmentVMAgentEnabled].(bool),
)
agentTrim := types2.CustomBool(agentBlock[mkResourceVirtualEnvironmentVMAgentTrim].(bool))
agentTrim := types.CustomBool(agentBlock[mkResourceVirtualEnvironmentVMAgentTrim].(bool))
agentType := agentBlock[mkResourceVirtualEnvironmentVMAgentType].(string)

updateBody.Agent = &vms.CustomAgent{
Expand Down Expand Up @@ -4521,7 +4520,7 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
cpuCores := cpuBlock[mkResourceVirtualEnvironmentVMCPUCores].(int)
cpuFlags := cpuBlock[mkResourceVirtualEnvironmentVMCPUFlags].([]interface{})
cpuHotplugged := cpuBlock[mkResourceVirtualEnvironmentVMCPUHotplugged].(int)
cpuNUMA := types2.CustomBool(cpuBlock[mkResourceVirtualEnvironmentVMCPUNUMA].(bool))
cpuNUMA := types.CustomBool(cpuBlock[mkResourceVirtualEnvironmentVMCPUNUMA].(bool))
cpuSockets := cpuBlock[mkResourceVirtualEnvironmentVMCPUSockets].(int)
cpuType := cpuBlock[mkResourceVirtualEnvironmentVMCPUType].(string)
cpuUnits := cpuBlock[mkResourceVirtualEnvironmentVMCPUUnits].(int)
Expand Down Expand Up @@ -4784,7 +4783,7 @@ func vmUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
return diag.FromErr(e)
}
} else {
forceStop := types2.CustomBool(true)
forceStop := types.CustomBool(true)
shutdownTimeout := d.Get(mkResourceVirtualEnvironmentVMTimeoutShutdownVM).(int)

e = vmAPI.ShutdownVM(ctx, &vms.ShutdownRequestBody{
Expand Down Expand Up @@ -4897,7 +4896,7 @@ func vmUpdateDiskLocationAndSize(
}

if *oldDisk.ID != *diskNewEntries[prefix][oldKey].ID {
deleteOriginalDisk := types2.CustomBool(true)
deleteOriginalDisk := types.CustomBool(true)

diskMoveBodies = append(
diskMoveBodies,
Expand Down Expand Up @@ -4925,7 +4924,7 @@ func vmUpdateDiskLocationAndSize(
}

if shutdownForDisksRequired && !template {
forceStop := types2.CustomBool(true)
forceStop := types.CustomBool(true)
shutdownTimeout := d.Get(mkResourceVirtualEnvironmentVMTimeoutShutdownVM).(int)

err = vmAPI.ShutdownVM(
Expand Down Expand Up @@ -5009,7 +5008,7 @@ func vmDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
}

if status.Status != "stopped" {
forceStop := types2.CustomBool(true)
forceStop := types.CustomBool(true)
shutdownTimeout := d.Get(mkResourceVirtualEnvironmentVMTimeoutShutdownVM).(int)

err = vmAPI.ShutdownVM(
Expand Down

0 comments on commit feac6b0

Please sign in to comment.