mirror of
https://github.com/bpg/terraform-provider-proxmox.git
synced 2025-07-05 05:24:01 +00:00
chore(lxc,vm): refactor: move vm and container code to subpackages (#1046)
* chore(lxc,vm): refactor: move vm and container code to subpackages --------- Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
This commit is contained in:
parent
61754069a4
commit
079119444d
@ -72,6 +72,7 @@ linters:
|
|||||||
- gomnd
|
- gomnd
|
||||||
- ireturn
|
- ireturn
|
||||||
- maintidx
|
- maintidx
|
||||||
|
- nestif
|
||||||
- nlreturn
|
- nlreturn
|
||||||
- perfsprint
|
- perfsprint
|
||||||
- tagliatelle
|
- tagliatelle
|
||||||
|
47
.vscode/settings.json
vendored
47
.vscode/settings.json
vendored
@ -1,31 +1,76 @@
|
|||||||
{
|
{
|
||||||
"git.alwaysSignOff": true,
|
"git.alwaysSignOff": true,
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
|
"aarch",
|
||||||
|
"ACPI",
|
||||||
|
"archlinux",
|
||||||
|
"armhf",
|
||||||
|
"burstable",
|
||||||
"capi",
|
"capi",
|
||||||
|
"CDROM",
|
||||||
|
"cloudinit",
|
||||||
"CLRF",
|
"CLRF",
|
||||||
|
"clusterfirewall",
|
||||||
|
"cmode",
|
||||||
|
"cpulimit",
|
||||||
|
"CPUNUMA",
|
||||||
|
"cputype",
|
||||||
|
"cpuunits",
|
||||||
|
"customdiff",
|
||||||
"deepcode",
|
"deepcode",
|
||||||
|
"directsync",
|
||||||
|
"efidisk",
|
||||||
|
"efidisks",
|
||||||
|
"FSTRIM",
|
||||||
|
"gocritic",
|
||||||
|
"gosimple",
|
||||||
|
"hookscript",
|
||||||
|
"hostpci",
|
||||||
|
"Hotplugged",
|
||||||
"iface",
|
"iface",
|
||||||
|
"importdisk",
|
||||||
"iothread",
|
"iothread",
|
||||||
|
"iothreads",
|
||||||
|
"ivshmem",
|
||||||
"keyctl",
|
"keyctl",
|
||||||
"mbps",
|
"mbps",
|
||||||
|
"mdev",
|
||||||
"nameserver",
|
"nameserver",
|
||||||
"nestif",
|
"nestif",
|
||||||
|
"nixos",
|
||||||
"nolint",
|
"nolint",
|
||||||
"NUMA",
|
"NUMA",
|
||||||
|
"ostype",
|
||||||
|
"OVMF",
|
||||||
|
"prealloc",
|
||||||
"proxmoxtf",
|
"proxmoxtf",
|
||||||
|
"pvesm",
|
||||||
"qcow",
|
"qcow",
|
||||||
|
"ROMBAR",
|
||||||
|
"romfile",
|
||||||
"rootfs",
|
"rootfs",
|
||||||
|
"seabios",
|
||||||
"signoff",
|
"signoff",
|
||||||
|
"SMBIOSSKU",
|
||||||
|
"SMBIOSUUID",
|
||||||
"stretchr",
|
"stretchr",
|
||||||
"testacc",
|
"testacc",
|
||||||
"tflog",
|
"tflog",
|
||||||
|
"tfstate",
|
||||||
"tfvars",
|
"tfvars",
|
||||||
|
"tpmstate",
|
||||||
"unmanaged",
|
"unmanaged",
|
||||||
|
"usbdisk",
|
||||||
|
"vcpus",
|
||||||
"virtio",
|
"virtio",
|
||||||
"VLANID",
|
"VLANID",
|
||||||
"vmbr",
|
"vmbr",
|
||||||
"VMID",
|
"VMID",
|
||||||
"vztmpl"
|
"vztmpl",
|
||||||
|
"writeback",
|
||||||
|
"writethrough",
|
||||||
|
"wvista",
|
||||||
|
"XVGA"
|
||||||
],
|
],
|
||||||
"go.lintTool": "golangci-lint",
|
"go.lintTool": "golangci-lint",
|
||||||
"go.lintFlags": [
|
"go.lintFlags": [
|
||||||
|
@ -11,7 +11,9 @@ import (
|
|||||||
|
|
||||||
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource"
|
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource"
|
||||||
clusterfirewall "github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/cluster/firewall"
|
clusterfirewall "github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/cluster/firewall"
|
||||||
|
container "github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/container"
|
||||||
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/firewall"
|
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/firewall"
|
||||||
|
vm "github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func createResourceMap() map[string]*schema.Resource {
|
func createResourceMap() map[string]*schema.Resource {
|
||||||
@ -19,7 +21,7 @@ func createResourceMap() map[string]*schema.Resource {
|
|||||||
"proxmox_virtual_environment_certificate": resource.Certificate(),
|
"proxmox_virtual_environment_certificate": resource.Certificate(),
|
||||||
"proxmox_virtual_environment_cluster_firewall": clusterfirewall.Firewall(),
|
"proxmox_virtual_environment_cluster_firewall": clusterfirewall.Firewall(),
|
||||||
"proxmox_virtual_environment_cluster_firewall_security_group": clusterfirewall.SecurityGroup(),
|
"proxmox_virtual_environment_cluster_firewall_security_group": clusterfirewall.SecurityGroup(),
|
||||||
"proxmox_virtual_environment_container": resource.Container(),
|
"proxmox_virtual_environment_container": container.Container(),
|
||||||
"proxmox_virtual_environment_dns": resource.DNS(),
|
"proxmox_virtual_environment_dns": resource.DNS(),
|
||||||
"proxmox_virtual_environment_file": resource.File(),
|
"proxmox_virtual_environment_file": resource.File(),
|
||||||
"proxmox_virtual_environment_firewall_alias": firewall.Alias(),
|
"proxmox_virtual_environment_firewall_alias": firewall.Alias(),
|
||||||
@ -28,11 +30,10 @@ func createResourceMap() map[string]*schema.Resource {
|
|||||||
"proxmox_virtual_environment_firewall_rules": firewall.Rules(),
|
"proxmox_virtual_environment_firewall_rules": firewall.Rules(),
|
||||||
"proxmox_virtual_environment_group": resource.Group(),
|
"proxmox_virtual_environment_group": resource.Group(),
|
||||||
"proxmox_virtual_environment_hosts": resource.Hosts(),
|
"proxmox_virtual_environment_hosts": resource.Hosts(),
|
||||||
// "proxmox_virtual_environment_network_linux_bridge": resource.NetworkLinuxBridge(),
|
|
||||||
"proxmox_virtual_environment_pool": resource.Pool(),
|
"proxmox_virtual_environment_pool": resource.Pool(),
|
||||||
"proxmox_virtual_environment_role": resource.Role(),
|
"proxmox_virtual_environment_role": resource.Role(),
|
||||||
"proxmox_virtual_environment_time": resource.Time(),
|
"proxmox_virtual_environment_time": resource.Time(),
|
||||||
"proxmox_virtual_environment_user": resource.User(),
|
"proxmox_virtual_environment_user": resource.User(),
|
||||||
"proxmox_virtual_environment_vm": resource.VM(),
|
"proxmox_virtual_environment_vm": vm.VM(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
315
proxmoxtf/resource/container/container_test.go
Normal file
315
proxmoxtf/resource/container/container_test.go
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package resource
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
|
||||||
|
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/test"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestContainerInstantiation tests whether the Container instance can be instantiated.
|
||||||
|
func TestContainerInstantiation(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
s := Container()
|
||||||
|
if s == nil {
|
||||||
|
t.Fatalf("Cannot instantiate Container")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestContainerSchema tests the Container schema.
|
||||||
|
func TestContainerSchema(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
s := Container()
|
||||||
|
|
||||||
|
test.AssertRequiredArguments(t, s, []string{
|
||||||
|
mkNodeName,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, s, []string{
|
||||||
|
mkCPU,
|
||||||
|
mkDescription,
|
||||||
|
mkDisk,
|
||||||
|
mkInitialization,
|
||||||
|
mkMemory,
|
||||||
|
mkMountPoint,
|
||||||
|
mkOperatingSystem,
|
||||||
|
mkPoolID,
|
||||||
|
mkStarted,
|
||||||
|
mkTags,
|
||||||
|
mkTemplate,
|
||||||
|
mkUnprivileged,
|
||||||
|
mkStartOnBoot,
|
||||||
|
mkFeatures,
|
||||||
|
mkVMID,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, s, map[string]schema.ValueType{
|
||||||
|
mkCPU: schema.TypeList,
|
||||||
|
mkDescription: schema.TypeString,
|
||||||
|
mkDisk: schema.TypeList,
|
||||||
|
mkInitialization: schema.TypeList,
|
||||||
|
mkMemory: schema.TypeList,
|
||||||
|
mkMountPoint: schema.TypeList,
|
||||||
|
mkOperatingSystem: schema.TypeList,
|
||||||
|
mkPoolID: schema.TypeString,
|
||||||
|
mkStarted: schema.TypeBool,
|
||||||
|
mkTags: schema.TypeList,
|
||||||
|
mkTemplate: schema.TypeBool,
|
||||||
|
mkUnprivileged: schema.TypeBool,
|
||||||
|
mkStartOnBoot: schema.TypeBool,
|
||||||
|
mkFeatures: schema.TypeList,
|
||||||
|
mkVMID: schema.TypeInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
cloneSchema := test.AssertNestedSchemaExistence(t, s, mkClone)
|
||||||
|
|
||||||
|
test.AssertRequiredArguments(t, cloneSchema, []string{
|
||||||
|
mkCloneVMID,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, cloneSchema, []string{
|
||||||
|
mkCloneDatastoreID,
|
||||||
|
mkCloneNodeName,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, cloneSchema, map[string]schema.ValueType{
|
||||||
|
mkCloneDatastoreID: schema.TypeString,
|
||||||
|
mkCloneNodeName: schema.TypeString,
|
||||||
|
mkCloneVMID: schema.TypeInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
cpuSchema := test.AssertNestedSchemaExistence(t, s, mkCPU)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, cpuSchema, []string{
|
||||||
|
mkCPUArchitecture,
|
||||||
|
mkCPUCores,
|
||||||
|
mkCPUUnits,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, cpuSchema, map[string]schema.ValueType{
|
||||||
|
mkCPUArchitecture: schema.TypeString,
|
||||||
|
mkCPUCores: schema.TypeInt,
|
||||||
|
mkCPUUnits: schema.TypeInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
diskSchema := test.AssertNestedSchemaExistence(t, s, mkDisk)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, diskSchema, []string{
|
||||||
|
mkDiskDatastoreID,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, diskSchema, map[string]schema.ValueType{
|
||||||
|
mkDiskDatastoreID: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
featuresSchema := test.AssertNestedSchemaExistence(t, s, mkFeatures)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, featuresSchema, []string{
|
||||||
|
mkFeaturesNesting,
|
||||||
|
mkFeaturesKeyControl,
|
||||||
|
mkFeaturesFUSE,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, featuresSchema, map[string]schema.ValueType{
|
||||||
|
mkFeaturesNesting: schema.TypeBool,
|
||||||
|
mkFeaturesKeyControl: schema.TypeBool,
|
||||||
|
mkFeaturesFUSE: schema.TypeBool,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkInitialization,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationSchema, []string{
|
||||||
|
mkInitializationDNS,
|
||||||
|
mkInitializationHostname,
|
||||||
|
mkInitializationIPConfig,
|
||||||
|
mkInitializationUserAccount,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationSchema, map[string]schema.ValueType{
|
||||||
|
mkInitializationDNS: schema.TypeList,
|
||||||
|
mkInitializationHostname: schema.TypeString,
|
||||||
|
mkInitializationIPConfig: schema.TypeList,
|
||||||
|
mkInitializationUserAccount: schema.TypeList,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationDNSSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkInitializationDNS,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationDNSSchema, []string{
|
||||||
|
mkInitializationDNSDomain,
|
||||||
|
mkInitializationDNSServer,
|
||||||
|
mkInitializationDNSServers,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationDNSSchema, map[string]schema.ValueType{
|
||||||
|
mkInitializationDNSDomain: schema.TypeString,
|
||||||
|
mkInitializationDNSServer: schema.TypeString,
|
||||||
|
mkInitializationDNSServers: schema.TypeList,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationIPConfigSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkInitializationIPConfig,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationIPConfigSchema, []string{
|
||||||
|
mkInitializationIPConfigIPv4,
|
||||||
|
mkInitializationIPConfigIPv6,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationIPConfigSchema, map[string]schema.ValueType{
|
||||||
|
mkInitializationIPConfigIPv4: schema.TypeList,
|
||||||
|
mkInitializationIPConfigIPv6: schema.TypeList,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationIPConfigIPv4Schema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationIPConfigSchema,
|
||||||
|
mkInitializationIPConfigIPv4,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationIPConfigIPv4Schema, []string{
|
||||||
|
mkInitializationIPConfigIPv4Address,
|
||||||
|
mkInitializationIPConfigIPv4Gateway,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationIPConfigIPv4Schema, map[string]schema.ValueType{
|
||||||
|
mkInitializationIPConfigIPv4Address: schema.TypeString,
|
||||||
|
mkInitializationIPConfigIPv4Gateway: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationIPConfigIPv6Schema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationIPConfigSchema,
|
||||||
|
mkInitializationIPConfigIPv6,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationIPConfigIPv6Schema, []string{
|
||||||
|
mkInitializationIPConfigIPv6Address,
|
||||||
|
mkInitializationIPConfigIPv6Gateway,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationIPConfigIPv6Schema, map[string]schema.ValueType{
|
||||||
|
mkInitializationIPConfigIPv6Address: schema.TypeString,
|
||||||
|
mkInitializationIPConfigIPv6Gateway: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationUserAccountSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkInitializationUserAccount,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationUserAccountSchema, []string{
|
||||||
|
mkInitializationUserAccountKeys,
|
||||||
|
mkInitializationUserAccountPassword,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationUserAccountSchema, map[string]schema.ValueType{
|
||||||
|
mkInitializationUserAccountKeys: schema.TypeList,
|
||||||
|
mkInitializationUserAccountPassword: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
memorySchema := test.AssertNestedSchemaExistence(t, s, mkMemory)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, memorySchema, []string{
|
||||||
|
mkMemoryDedicated,
|
||||||
|
mkMemorySwap,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, memorySchema, map[string]schema.ValueType{
|
||||||
|
mkMemoryDedicated: schema.TypeInt,
|
||||||
|
mkMemorySwap: schema.TypeInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
mountPointSchema := test.AssertNestedSchemaExistence(t, s, mkMountPoint)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, mountPointSchema, []string{
|
||||||
|
mkMountPointACL,
|
||||||
|
mkMountPointBackup,
|
||||||
|
mkMountPointMountOptions,
|
||||||
|
mkMountPointQuota,
|
||||||
|
mkMountPointReadOnly,
|
||||||
|
mkMountPointReplicate,
|
||||||
|
mkMountPointShared,
|
||||||
|
mkMountPointSize,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, mountPointSchema, map[string]schema.ValueType{
|
||||||
|
mkMountPointACL: schema.TypeBool,
|
||||||
|
mkMountPointBackup: schema.TypeBool,
|
||||||
|
mkMountPointMountOptions: schema.TypeList,
|
||||||
|
mkMountPointPath: schema.TypeString,
|
||||||
|
mkMountPointQuota: schema.TypeBool,
|
||||||
|
mkMountPointReadOnly: schema.TypeBool,
|
||||||
|
mkMountPointReplicate: schema.TypeBool,
|
||||||
|
mkMountPointShared: schema.TypeBool,
|
||||||
|
mkMountPointSize: schema.TypeString,
|
||||||
|
mkMountPointVolume: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
networkInterfaceSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkNetworkInterface,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertRequiredArguments(t, networkInterfaceSchema, []string{
|
||||||
|
mkNetworkInterfaceName,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, networkInterfaceSchema, []string{
|
||||||
|
mkNetworkInterfaceBridge,
|
||||||
|
mkNetworkInterfaceEnabled,
|
||||||
|
mkNetworkInterfaceMACAddress,
|
||||||
|
mkNetworkInterfaceRateLimit,
|
||||||
|
mkNetworkInterfaceVLANID,
|
||||||
|
mkNetworkInterfaceMTU,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, networkInterfaceSchema, map[string]schema.ValueType{
|
||||||
|
mkNetworkInterfaceBridge: schema.TypeString,
|
||||||
|
mkNetworkInterfaceEnabled: schema.TypeBool,
|
||||||
|
mkNetworkInterfaceMACAddress: schema.TypeString,
|
||||||
|
mkNetworkInterfaceName: schema.TypeString,
|
||||||
|
mkNetworkInterfaceRateLimit: schema.TypeFloat,
|
||||||
|
mkNetworkInterfaceVLANID: schema.TypeInt,
|
||||||
|
mkNetworkInterfaceMTU: schema.TypeInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
operatingSystemSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkOperatingSystem,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertRequiredArguments(t, operatingSystemSchema, []string{
|
||||||
|
mkOperatingSystemTemplateFileID,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, operatingSystemSchema, []string{
|
||||||
|
mkOperatingSystemType,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, operatingSystemSchema, map[string]schema.ValueType{
|
||||||
|
mkOperatingSystemTemplateFileID: schema.TypeString,
|
||||||
|
mkOperatingSystemType: schema.TypeString,
|
||||||
|
})
|
||||||
|
}
|
55
proxmoxtf/resource/container/validators.go
Normal file
55
proxmoxtf/resource/container/validators.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package resource
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MountTypeValidator returns a schema validation function for a mount type on a lxc container.
|
||||||
|
func MountTypeValidator() schema.SchemaValidateDiagFunc {
|
||||||
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
|
"cifs",
|
||||||
|
"nfs",
|
||||||
|
}, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConsoleModeValidator returns a schema validation function for a console mode on a lxc container.
|
||||||
|
func ConsoleModeValidator() schema.SchemaValidateDiagFunc {
|
||||||
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
|
"console",
|
||||||
|
"shell",
|
||||||
|
"tty",
|
||||||
|
}, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CPUArchitectureValidator returns a schema validation function for a CPU architecture on a lxc container.
|
||||||
|
func CPUArchitectureValidator() schema.SchemaValidateDiagFunc {
|
||||||
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
|
"amd64",
|
||||||
|
"arm64",
|
||||||
|
"armhf",
|
||||||
|
"i386",
|
||||||
|
}, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperatingSystemTypeValidator returns a schema validation function for an operating system type on a lxc container.
|
||||||
|
func OperatingSystemTypeValidator() schema.SchemaValidateDiagFunc {
|
||||||
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
|
"alpine",
|
||||||
|
"archlinux",
|
||||||
|
"centos",
|
||||||
|
"debian",
|
||||||
|
"fedora",
|
||||||
|
"gentoo",
|
||||||
|
"nixos",
|
||||||
|
"opensuse",
|
||||||
|
"ubuntu",
|
||||||
|
"unmanaged",
|
||||||
|
}, false))
|
||||||
|
}
|
@ -1,315 +0,0 @@
|
|||||||
/*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package resource
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
|
|
||||||
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/test"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TestContainerInstantiation tests whether the Container instance can be instantiated.
|
|
||||||
func TestContainerInstantiation(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
s := Container()
|
|
||||||
if s == nil {
|
|
||||||
t.Fatalf("Cannot instantiate Container")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestContainerSchema tests the Container schema.
|
|
||||||
func TestContainerSchema(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
s := Container()
|
|
||||||
|
|
||||||
test.AssertRequiredArguments(t, s, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerNodeName,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, s, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerCPU,
|
|
||||||
mkResourceVirtualEnvironmentContainerDescription,
|
|
||||||
mkResourceVirtualEnvironmentContainerDisk,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitialization,
|
|
||||||
mkResourceVirtualEnvironmentContainerMemory,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPoint,
|
|
||||||
mkResourceVirtualEnvironmentContainerOperatingSystem,
|
|
||||||
mkResourceVirtualEnvironmentContainerPoolID,
|
|
||||||
mkResourceVirtualEnvironmentContainerStarted,
|
|
||||||
mkResourceVirtualEnvironmentContainerTags,
|
|
||||||
mkResourceVirtualEnvironmentContainerTemplate,
|
|
||||||
mkResourceVirtualEnvironmentContainerUnprivileged,
|
|
||||||
mkResourceVirtualEnvironmentContainerStartOnBoot,
|
|
||||||
mkResourceVirtualEnvironmentContainerFeatures,
|
|
||||||
mkResourceVirtualEnvironmentContainerVMID,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, s, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerCPU: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerDescription: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerDisk: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitialization: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerMemory: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPoint: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerOperatingSystem: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerPoolID: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerStarted: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerTags: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerTemplate: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerUnprivileged: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerStartOnBoot: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerFeatures: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerVMID: schema.TypeInt,
|
|
||||||
})
|
|
||||||
|
|
||||||
cloneSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerClone)
|
|
||||||
|
|
||||||
test.AssertRequiredArguments(t, cloneSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerCloneVMID,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, cloneSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerCloneDatastoreID,
|
|
||||||
mkResourceVirtualEnvironmentContainerCloneNodeName,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, cloneSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerCloneDatastoreID: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerCloneNodeName: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerCloneVMID: schema.TypeInt,
|
|
||||||
})
|
|
||||||
|
|
||||||
cpuSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerCPU)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, cpuSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerCPUArchitecture,
|
|
||||||
mkResourceVirtualEnvironmentContainerCPUCores,
|
|
||||||
mkResourceVirtualEnvironmentContainerCPUUnits,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, cpuSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerCPUArchitecture: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerCPUCores: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentContainerCPUUnits: schema.TypeInt,
|
|
||||||
})
|
|
||||||
|
|
||||||
diskSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerDisk)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, diskSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerDiskDatastoreID,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, diskSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerDiskDatastoreID: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
featuresSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerFeatures)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, featuresSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerFeaturesNesting,
|
|
||||||
mkResourceVirtualEnvironmentContainerFeaturesKeyControl,
|
|
||||||
mkResourceVirtualEnvironmentContainerFeaturesFUSE,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, featuresSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerFeaturesNesting: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerFeaturesKeyControl: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerFeaturesFUSE: schema.TypeBool,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
s,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitialization,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationDNS,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationHostname,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfig,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationUserAccount,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationDNS: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationHostname: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfig: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationUserAccount: schema.TypeList,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationDNSSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
initializationSchema,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationDNS,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationDNSSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationDNSDomain,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationDNSServer,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationDNSServers,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationDNSSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationDNSDomain: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationDNSServer: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationDNSServers: schema.TypeList,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationIPConfigSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
initializationSchema,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfig,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationIPConfigSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationIPConfigSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6: schema.TypeList,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationIPConfigIPv4Schema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
initializationIPConfigSchema,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationIPConfigIPv4Schema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationIPConfigIPv4Schema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Address: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv4Gateway: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationIPConfigIPv6Schema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
initializationIPConfigSchema,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationIPConfigIPv6Schema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationIPConfigIPv6Schema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Address: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationIPConfigIPv6Gateway: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationUserAccountSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
initializationSchema,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationUserAccount,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationUserAccountSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationUserAccountKeys,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationUserAccountPassword,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationUserAccountSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationUserAccountKeys: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerInitializationUserAccountPassword: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
memorySchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerMemory)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, memorySchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerMemoryDedicated,
|
|
||||||
mkResourceVirtualEnvironmentContainerMemorySwap,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, memorySchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerMemoryDedicated: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentContainerMemorySwap: schema.TypeInt,
|
|
||||||
})
|
|
||||||
|
|
||||||
mountPointSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentContainerMountPoint)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, mountPointSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointACL,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointBackup,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointMountOptions,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointQuota,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointReadOnly,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointReplicate,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointShared,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointSize,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, mountPointSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointACL: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointBackup: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointMountOptions: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointPath: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointQuota: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointReadOnly: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointReplicate: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointShared: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointSize: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerMountPointVolume: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
networkInterfaceSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
s,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterface,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertRequiredArguments(t, networkInterfaceSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceName,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, networkInterfaceSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceBridge,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceEnabled,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceMACAddress,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, networkInterfaceSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceBridge: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceEnabled: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceMACAddress: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceName: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceRateLimit: schema.TypeFloat,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceVLANID: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentContainerNetworkInterfaceMTU: schema.TypeInt,
|
|
||||||
})
|
|
||||||
|
|
||||||
operatingSystemSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
s,
|
|
||||||
mkResourceVirtualEnvironmentContainerOperatingSystem,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertRequiredArguments(t, operatingSystemSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerOperatingSystemTemplateFileID,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, operatingSystemSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentContainerOperatingSystemType,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, operatingSystemSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentContainerOperatingSystemTemplateFileID: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentContainerOperatingSystemType: schema.TypeString,
|
|
||||||
})
|
|
||||||
}
|
|
@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
"github.com/bpg/terraform-provider-proxmox/proxmox/firewall"
|
"github.com/bpg/terraform-provider-proxmox/proxmox/firewall"
|
||||||
"github.com/bpg/terraform-provider-proxmox/proxmoxtf"
|
"github.com/bpg/terraform-provider-proxmox/proxmoxtf"
|
||||||
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/validator"
|
resource "github.com/bpg/terraform-provider-proxmox/proxmoxtf/resource/vm"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -35,14 +35,14 @@ func selectorSchema() map[string]*schema.Schema {
|
|||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "The ID of the VM to manage the firewall for.",
|
Description: "The ID of the VM to manage the firewall for.",
|
||||||
RequiredWith: []string{mkSelectorNodeName},
|
RequiredWith: []string{mkSelectorNodeName},
|
||||||
ValidateDiagFunc: validator.VMID(),
|
ValidateDiagFunc: resource.VMIDValidator(),
|
||||||
},
|
},
|
||||||
mkSelectorContainerID: {
|
mkSelectorContainerID: {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Description: "The ID of the container to manage the firewall for.",
|
Description: "The ID of the container to manage the firewall for.",
|
||||||
RequiredWith: []string{mkSelectorNodeName},
|
RequiredWith: []string{mkSelectorNodeName},
|
||||||
ValidateDiagFunc: validator.VMID(),
|
ValidateDiagFunc: resource.VMIDValidator(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package validator
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MountType returns a schema validation function for a mount type on a lxc container.
|
|
||||||
func MountType() schema.SchemaValidateDiagFunc {
|
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
|
||||||
"cifs",
|
|
||||||
"nfs",
|
|
||||||
}, false))
|
|
||||||
}
|
|
@ -16,6 +16,16 @@ import (
|
|||||||
"github.com/bpg/terraform-provider-proxmox/proxmox/types"
|
"github.com/bpg/terraform-provider-proxmox/proxmox/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ContentType returns a schema validation function for a content type on a storage device.
|
||||||
|
func ContentType() schema.SchemaValidateDiagFunc {
|
||||||
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
|
"dump",
|
||||||
|
"iso",
|
||||||
|
"snippets",
|
||||||
|
"vztmpl",
|
||||||
|
}, false))
|
||||||
|
}
|
||||||
|
|
||||||
// FileFormat returns a schema validation function for a file format.
|
// FileFormat returns a schema validation function for a file format.
|
||||||
func FileFormat() schema.SchemaValidateDiagFunc {
|
func FileFormat() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
|
@ -4,24 +4,26 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package validator
|
package resource
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
|
||||||
)
|
)
|
||||||
|
|
||||||
// VMID returns a schema validation function for a VM ID.
|
// VMIDValidator returns a schema validation function for a VM ID.
|
||||||
func VMID() schema.SchemaValidateDiagFunc {
|
func VMIDValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(func(i interface{}, k string) ([]string, []error) {
|
return validation.ToDiagFunc(func(i interface{}, k string) ([]string, []error) {
|
||||||
minID := 100
|
minID := 100
|
||||||
maxID := 2147483647
|
maxID := 2147483647
|
||||||
|
|
||||||
var ws []string
|
var ws []string
|
||||||
|
|
||||||
var es []error
|
var es []error
|
||||||
|
|
||||||
v, ok := i.(int)
|
v, ok := i.(int)
|
||||||
@ -42,26 +44,24 @@ func VMID() schema.SchemaValidateDiagFunc {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// BIOS returns a schema validation function for a BIOS type.
|
// BIOSValidator returns a schema validation function for a BIOSValidator type.
|
||||||
func BIOS() schema.SchemaValidateDiagFunc {
|
func BIOSValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
"ovmf",
|
"ovmf",
|
||||||
"seabios",
|
"seabios",
|
||||||
}, false))
|
}, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContentType returns a schema validation function for a content type on a storage device.
|
// CPUArchitectureValidator returns a schema validation function for a CPU architecture.
|
||||||
func ContentType() schema.SchemaValidateDiagFunc {
|
func CPUArchitectureValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
"dump",
|
"aarch64",
|
||||||
"iso",
|
"x86_64",
|
||||||
"snippets",
|
|
||||||
"vztmpl",
|
|
||||||
}, false))
|
}, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// CPUType returns a schema validation function for a CPU type.
|
// CPUTypeValidator returns a schema validation function for a CPU type.
|
||||||
func CPUType() schema.SchemaValidateDiagFunc {
|
func CPUTypeValidator() schema.SchemaValidateDiagFunc {
|
||||||
standardTypes := []string{
|
standardTypes := []string{
|
||||||
"486",
|
"486",
|
||||||
"Broadwell",
|
"Broadwell",
|
||||||
@ -144,18 +144,18 @@ func CPUType() schema.SchemaValidateDiagFunc {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// NetworkDeviceModel is a schema validation function for network device models.
|
// NetworkDeviceModelValidator is a schema validation function for network device models.
|
||||||
func NetworkDeviceModel() schema.SchemaValidateDiagFunc {
|
func NetworkDeviceModelValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{"e1000", "rtl8139", "virtio", "vmxnet3"}, false))
|
return validation.ToDiagFunc(validation.StringInSlice([]string{"e1000", "rtl8139", "virtio", "vmxnet3"}, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// QEMUAgentType is a schema validation function for QEMU agent types.
|
// QEMUAgentTypeValidator is a schema validation function for QEMU agent types.
|
||||||
func QEMUAgentType() schema.SchemaValidateDiagFunc {
|
func QEMUAgentTypeValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{"isa", "virtio"}, false))
|
return validation.ToDiagFunc(validation.StringInSlice([]string{"isa", "virtio"}, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyboardLayout is a schema validation function for keyboard layouts.
|
// KeyboardLayoutValidator is a schema validation function for keyboard layouts.
|
||||||
func KeyboardLayout() schema.SchemaValidateDiagFunc {
|
func KeyboardLayoutValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
"da",
|
"da",
|
||||||
"de",
|
"de",
|
||||||
@ -185,20 +185,21 @@ func KeyboardLayout() schema.SchemaValidateDiagFunc {
|
|||||||
}, false))
|
}, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// MachineType is a schema validation function for machine types.
|
// MachineTypeValidator is a schema validation function for machine types.
|
||||||
func MachineType() schema.SchemaValidateDiagFunc {
|
func MachineTypeValidator() schema.SchemaValidateDiagFunc {
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
r := regexp.MustCompile(`^$|^(pc|pc(-i440fx)?-\d+(\.\d+)+(\+pve\d+)?(\.pxe)?|q35|pc-q35-\d+(\.\d+)+(\+pve\d+)?(\.pxe)?|virt(?:-\d+(\.\d+)+)?(\+pve\d+)?)$`)
|
r := regexp.MustCompile(`^$|^(pc|pc(-i440fx)?-\d+(\.\d+)+(\+pve\d+)?(\.pxe)?|q35|pc-q35-\d+(\.\d+)+(\+pve\d+)?(\.pxe)?|virt(?:-\d+(\.\d+)+)?(\+pve\d+)?)$`)
|
||||||
|
|
||||||
return validation.ToDiagFunc(validation.StringMatch(r, "must be a valid machine type"))
|
return validation.ToDiagFunc(validation.StringMatch(r, "must be a valid machine type"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Timeout is a schema validation function for timeouts.
|
// TimeoutValidator is a schema validation function for timeouts.
|
||||||
func Timeout() schema.SchemaValidateDiagFunc {
|
func TimeoutValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(func(i interface{}, k string) ([]string, []error) {
|
return validation.ToDiagFunc(func(i interface{}, k string) ([]string, []error) {
|
||||||
v, ok := i.(string)
|
v, ok := i.(string)
|
||||||
|
|
||||||
var ws []string
|
var ws []string
|
||||||
|
|
||||||
var es []error
|
var es []error
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -216,13 +217,13 @@ func Timeout() schema.SchemaValidateDiagFunc {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// VGAMemory is a schema validation function for VGA memory sizes.
|
// VGAMemoryValidator is a schema validation function for VGA memory sizes.
|
||||||
func VGAMemory() schema.SchemaValidateDiagFunc {
|
func VGAMemoryValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.IntBetween(4, 512))
|
return validation.ToDiagFunc(validation.IntBetween(4, 512))
|
||||||
}
|
}
|
||||||
|
|
||||||
// VGAType is a schema validation function for VGA device types.
|
// VGATypeValidator is a schema validation function for VGA device types.
|
||||||
func VGAType() schema.SchemaValidateDiagFunc {
|
func VGATypeValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
"cirrus",
|
"cirrus",
|
||||||
"qxl",
|
"qxl",
|
||||||
@ -239,8 +240,8 @@ func VGAType() schema.SchemaValidateDiagFunc {
|
|||||||
}, false))
|
}, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SCSIHardware is a schema validation function for SCSI hardware.
|
// SCSIHardwareValidator is a schema validation function for SCSI hardware.
|
||||||
func SCSIHardware() schema.SchemaValidateDiagFunc {
|
func SCSIHardwareValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
"lsi",
|
"lsi",
|
||||||
"lsi53c810",
|
"lsi53c810",
|
||||||
@ -251,8 +252,8 @@ func SCSIHardware() schema.SchemaValidateDiagFunc {
|
|||||||
}, false))
|
}, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDEInterface is a schema validation function for IDE interfaces.
|
// IDEInterfaceValidator is a schema validation function for IDE interfaces.
|
||||||
func IDEInterface() schema.SchemaValidateDiagFunc {
|
func IDEInterfaceValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
"ide0",
|
"ide0",
|
||||||
"ide1",
|
"ide1",
|
||||||
@ -261,9 +262,9 @@ func IDEInterface() schema.SchemaValidateDiagFunc {
|
|||||||
}, false))
|
}, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
// CloudInitInterface is a schema validation function that accepts either an IDE interface identifier or an
|
// CloudInitInterfaceValidator is a schema validation function that accepts either an IDE interface identifier or an
|
||||||
// empty string, which is used as the default and means "detect which interface should be used automatically".
|
// empty string, which is used as the default and means "detect which interface should be used automatically".
|
||||||
func CloudInitInterface() schema.SchemaValidateDiagFunc {
|
func CloudInitInterfaceValidator() schema.SchemaValidateDiagFunc {
|
||||||
r := regexp.MustCompile(`^ide[0-3]|sata[0-5]|scsi(?:30|[12][0-9]|[0-9])$`)
|
r := regexp.MustCompile(`^ide[0-3]|sata[0-5]|scsi(?:30|[12][0-9]|[0-9])$`)
|
||||||
|
|
||||||
return validation.ToDiagFunc(validation.Any(
|
return validation.ToDiagFunc(validation.Any(
|
||||||
@ -272,10 +273,66 @@ func CloudInitInterface() schema.SchemaValidateDiagFunc {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// CloudInitType is a schema validation function for cloud-init types.
|
// CloudInitTypeValidator is a schema validation function for cloud-init types.
|
||||||
func CloudInitType() schema.SchemaValidateDiagFunc {
|
func CloudInitTypeValidator() schema.SchemaValidateDiagFunc {
|
||||||
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
"configdrive2",
|
"configdrive2",
|
||||||
"nocloud",
|
"nocloud",
|
||||||
}, false))
|
}, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AudioDeviceValidator is a schema validation function for audio devices.
|
||||||
|
func AudioDeviceValidator() schema.SchemaValidateDiagFunc {
|
||||||
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
|
"AC97",
|
||||||
|
"ich9-intel-hda",
|
||||||
|
"intel-hda",
|
||||||
|
}, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
// AudioDriverValidator is a schema validation function for audio drivers.
|
||||||
|
func AudioDriverValidator() schema.SchemaValidateDiagFunc {
|
||||||
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
|
"spice",
|
||||||
|
}, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperatingSystemTypeValidator is a schema validation function for operating system types.
|
||||||
|
func OperatingSystemTypeValidator() schema.SchemaValidateDiagFunc {
|
||||||
|
return validation.ToDiagFunc(validation.StringInSlice([]string{
|
||||||
|
"l24",
|
||||||
|
"l26",
|
||||||
|
"other",
|
||||||
|
"solaris",
|
||||||
|
"w2k",
|
||||||
|
"w2k3",
|
||||||
|
"w2k8",
|
||||||
|
"win7",
|
||||||
|
"win8",
|
||||||
|
"win10",
|
||||||
|
"win11",
|
||||||
|
"wvista",
|
||||||
|
"wxp",
|
||||||
|
}, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
// SerialDeviceValidator is a schema validation function for serial devices.
|
||||||
|
func SerialDeviceValidator() schema.SchemaValidateDiagFunc {
|
||||||
|
return validation.ToDiagFunc(func(i interface{}, k string) ([]string, []error) {
|
||||||
|
v, ok := i.(string)
|
||||||
|
|
||||||
|
var es []error
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
es = append(es, fmt.Errorf("expected type of %s to be string", k))
|
||||||
|
return nil, es
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.HasPrefix(v, "/dev/") && v != "socket" {
|
||||||
|
es = append(es, fmt.Errorf("expected %s to be '/dev/*' or 'socket'", k))
|
||||||
|
return nil, es
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, es
|
||||||
|
})
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package validator
|
package resource
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
@ -32,7 +32,7 @@ func TestCPUType(t *testing.T) {
|
|||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
f := CPUType()
|
f := CPUTypeValidator()
|
||||||
res := f(tt.value, nil)
|
res := f(tt.value, nil)
|
||||||
|
|
||||||
if tt.valid {
|
if tt.valid {
|
||||||
@ -66,7 +66,7 @@ func TestMachineType(t *testing.T) {
|
|||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
f := MachineType()
|
f := MachineTypeValidator()
|
||||||
res := f(tt.value, nil)
|
res := f(tt.value, nil)
|
||||||
|
|
||||||
if tt.valid {
|
if tt.valid {
|
File diff suppressed because it is too large
Load Diff
493
proxmoxtf/resource/vm/vm_test.go
Normal file
493
proxmoxtf/resource/vm/vm_test.go
Normal file
@ -0,0 +1,493 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package resource
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/test"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestVMInstantiation tests whether the VM instance can be instantiated.
|
||||||
|
func TestVMInstantiation(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
s := VM()
|
||||||
|
if s == nil {
|
||||||
|
t.Fatalf("Cannot instantiate VM")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestVMSchema tests the VM schema.
|
||||||
|
func TestVMSchema(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
s := VM()
|
||||||
|
|
||||||
|
test.AssertRequiredArguments(t, s, []string{
|
||||||
|
mkNodeName,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, s, []string{
|
||||||
|
mkACPI,
|
||||||
|
mkAgent,
|
||||||
|
mkAudioDevice,
|
||||||
|
mkBIOS,
|
||||||
|
mkBootOrder,
|
||||||
|
mkCDROM,
|
||||||
|
mkClone,
|
||||||
|
mkCPU,
|
||||||
|
mkDescription,
|
||||||
|
mkDisk,
|
||||||
|
mkEFIDisk,
|
||||||
|
mkInitialization,
|
||||||
|
mkHostPCI,
|
||||||
|
mkHostUSB,
|
||||||
|
mkKeyboardLayout,
|
||||||
|
mkKVMArguments,
|
||||||
|
mkMachine,
|
||||||
|
mkMemory,
|
||||||
|
mkName,
|
||||||
|
mkNetworkDevice,
|
||||||
|
mkOperatingSystem,
|
||||||
|
mkPoolID,
|
||||||
|
mkSerialDevice,
|
||||||
|
mkStarted,
|
||||||
|
mkTabletDevice,
|
||||||
|
mkTemplate,
|
||||||
|
mkVMID,
|
||||||
|
mkSCSIHardware,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertComputedAttributes(t, s, []string{
|
||||||
|
mkIPv4Addresses,
|
||||||
|
mkIPv6Addresses,
|
||||||
|
mkMACAddresses,
|
||||||
|
mkNetworkInterfaceNames,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, s, map[string]schema.ValueType{
|
||||||
|
mkACPI: schema.TypeBool,
|
||||||
|
mkAgent: schema.TypeList,
|
||||||
|
mkAudioDevice: schema.TypeList,
|
||||||
|
mkBIOS: schema.TypeString,
|
||||||
|
mkBootOrder: schema.TypeList,
|
||||||
|
mkCDROM: schema.TypeList,
|
||||||
|
mkCPU: schema.TypeList,
|
||||||
|
mkDescription: schema.TypeString,
|
||||||
|
mkDisk: schema.TypeList,
|
||||||
|
mkEFIDisk: schema.TypeList,
|
||||||
|
mkHostPCI: schema.TypeList,
|
||||||
|
mkHostUSB: schema.TypeList,
|
||||||
|
mkInitialization: schema.TypeList,
|
||||||
|
mkIPv4Addresses: schema.TypeList,
|
||||||
|
mkIPv6Addresses: schema.TypeList,
|
||||||
|
mkKeyboardLayout: schema.TypeString,
|
||||||
|
mkKVMArguments: schema.TypeString,
|
||||||
|
mkMachine: schema.TypeString,
|
||||||
|
mkMemory: schema.TypeList,
|
||||||
|
mkName: schema.TypeString,
|
||||||
|
mkNetworkDevice: schema.TypeList,
|
||||||
|
mkMACAddresses: schema.TypeList,
|
||||||
|
mkNetworkInterfaceNames: schema.TypeList,
|
||||||
|
mkOperatingSystem: schema.TypeList,
|
||||||
|
mkPoolID: schema.TypeString,
|
||||||
|
mkSerialDevice: schema.TypeList,
|
||||||
|
mkStarted: schema.TypeBool,
|
||||||
|
mkTabletDevice: schema.TypeBool,
|
||||||
|
mkTemplate: schema.TypeBool,
|
||||||
|
mkVMID: schema.TypeInt,
|
||||||
|
mkSCSIHardware: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
agentSchema := test.AssertNestedSchemaExistence(t, s, mkAgent)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, agentSchema, []string{
|
||||||
|
mkAgentEnabled,
|
||||||
|
mkAgentTimeout,
|
||||||
|
mkAgentTrim,
|
||||||
|
mkAgentType,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, agentSchema, map[string]schema.ValueType{
|
||||||
|
mkAgentEnabled: schema.TypeBool,
|
||||||
|
mkAgentTrim: schema.TypeBool,
|
||||||
|
mkAgentType: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
audioDeviceSchema := test.AssertNestedSchemaExistence(t, s, mkAudioDevice)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, audioDeviceSchema, []string{
|
||||||
|
mkAudioDeviceDevice,
|
||||||
|
mkAudioDeviceDriver,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, audioDeviceSchema, map[string]schema.ValueType{
|
||||||
|
mkAudioDeviceDevice: schema.TypeString,
|
||||||
|
mkAudioDeviceDriver: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
cdromSchema := test.AssertNestedSchemaExistence(t, s, mkCDROM)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, cdromSchema, []string{
|
||||||
|
mkCDROMEnabled,
|
||||||
|
mkCDROMFileID,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, cdromSchema, map[string]schema.ValueType{
|
||||||
|
mkCDROMEnabled: schema.TypeBool,
|
||||||
|
mkCDROMFileID: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
cloneSchema := test.AssertNestedSchemaExistence(t, s, mkClone)
|
||||||
|
|
||||||
|
test.AssertRequiredArguments(t, cloneSchema, []string{
|
||||||
|
mkCloneVMID,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, cloneSchema, []string{
|
||||||
|
mkCloneDatastoreID,
|
||||||
|
mkCloneNodeName,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, cloneSchema, map[string]schema.ValueType{
|
||||||
|
mkCloneDatastoreID: schema.TypeString,
|
||||||
|
mkCloneNodeName: schema.TypeString,
|
||||||
|
mkCloneVMID: schema.TypeInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
cpuSchema := test.AssertNestedSchemaExistence(t, s, mkCPU)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, cpuSchema, []string{
|
||||||
|
mkCPUArchitecture,
|
||||||
|
mkCPUCores,
|
||||||
|
mkCPUFlags,
|
||||||
|
mkCPUHotplugged,
|
||||||
|
mkCPUNUMA,
|
||||||
|
mkCPUSockets,
|
||||||
|
mkCPUType,
|
||||||
|
mkCPUUnits,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, cpuSchema, map[string]schema.ValueType{
|
||||||
|
mkCPUArchitecture: schema.TypeString,
|
||||||
|
mkCPUCores: schema.TypeInt,
|
||||||
|
mkCPUFlags: schema.TypeList,
|
||||||
|
mkCPUHotplugged: schema.TypeInt,
|
||||||
|
mkCPUNUMA: schema.TypeBool,
|
||||||
|
mkCPUSockets: schema.TypeInt,
|
||||||
|
mkCPUType: schema.TypeString,
|
||||||
|
mkCPUUnits: schema.TypeInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
diskSchema := test.AssertNestedSchemaExistence(t, s, mkDisk)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, diskSchema, []string{
|
||||||
|
mkDiskDatastoreID,
|
||||||
|
mkDiskPathInDatastore,
|
||||||
|
mkDiskFileFormat,
|
||||||
|
mkDiskFileID,
|
||||||
|
mkDiskSize,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, diskSchema, map[string]schema.ValueType{
|
||||||
|
mkDiskDatastoreID: schema.TypeString,
|
||||||
|
mkDiskPathInDatastore: schema.TypeString,
|
||||||
|
mkDiskFileFormat: schema.TypeString,
|
||||||
|
mkDiskFileID: schema.TypeString,
|
||||||
|
mkDiskSize: schema.TypeInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
diskSpeedSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
diskSchema,
|
||||||
|
mkDiskSpeed,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, diskSpeedSchema, []string{
|
||||||
|
mkDiskSpeedRead,
|
||||||
|
mkDiskSpeedReadBurstable,
|
||||||
|
mkDiskSpeedWrite,
|
||||||
|
mkDiskSpeedWriteBurstable,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, diskSpeedSchema, map[string]schema.ValueType{
|
||||||
|
mkDiskSpeedRead: schema.TypeInt,
|
||||||
|
mkDiskSpeedReadBurstable: schema.TypeInt,
|
||||||
|
mkDiskSpeedWrite: schema.TypeInt,
|
||||||
|
mkDiskSpeedWriteBurstable: schema.TypeInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
efiDiskSchema := test.AssertNestedSchemaExistence(t, s, mkEFIDisk)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, efiDiskSchema, []string{
|
||||||
|
mkEFIDiskDatastoreID,
|
||||||
|
mkEFIDiskFileFormat,
|
||||||
|
mkEFIDiskType,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, efiDiskSchema, map[string]schema.ValueType{
|
||||||
|
mkEFIDiskDatastoreID: schema.TypeString,
|
||||||
|
mkEFIDiskFileFormat: schema.TypeString,
|
||||||
|
mkEFIDiskType: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkInitialization,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationSchema, []string{
|
||||||
|
mkInitializationDatastoreID,
|
||||||
|
mkInitializationInterface,
|
||||||
|
mkInitializationDNS,
|
||||||
|
mkInitializationIPConfig,
|
||||||
|
mkInitializationUserAccount,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationSchema, map[string]schema.ValueType{
|
||||||
|
mkInitializationDatastoreID: schema.TypeString,
|
||||||
|
mkInitializationInterface: schema.TypeString,
|
||||||
|
mkInitializationDNS: schema.TypeList,
|
||||||
|
mkInitializationIPConfig: schema.TypeList,
|
||||||
|
mkInitializationUserAccount: schema.TypeList,
|
||||||
|
})
|
||||||
|
|
||||||
|
hostPCISchema := test.AssertNestedSchemaExistence(t, s, mkHostPCI)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, hostPCISchema, []string{
|
||||||
|
mkHostPCIDeviceMDev,
|
||||||
|
mkHostPCIDevicePCIE,
|
||||||
|
mkHostPCIDeviceROMBAR,
|
||||||
|
mkHostPCIDeviceROMFile,
|
||||||
|
mkHostPCIDeviceXVGA,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, hostPCISchema, map[string]schema.ValueType{
|
||||||
|
mkHostPCIDevice: schema.TypeString,
|
||||||
|
mkHostPCIDeviceMDev: schema.TypeString,
|
||||||
|
mkHostPCIDevicePCIE: schema.TypeBool,
|
||||||
|
mkHostPCIDeviceROMBAR: schema.TypeBool,
|
||||||
|
mkHostPCIDeviceROMFile: schema.TypeString,
|
||||||
|
mkHostPCIDeviceXVGA: schema.TypeBool,
|
||||||
|
})
|
||||||
|
|
||||||
|
hostUSBSchema := test.AssertNestedSchemaExistence(t, s, mkHostUSB)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, hostUSBSchema, []string{
|
||||||
|
mkHostUSBDeviceMapping,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, hostUSBSchema, map[string]schema.ValueType{
|
||||||
|
mkHostUSBDevice: schema.TypeString,
|
||||||
|
mkHostUSBDeviceUSB3: schema.TypeBool,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationDNSSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkInitializationDNS,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationDNSSchema, []string{
|
||||||
|
mkInitializationDNSDomain,
|
||||||
|
mkInitializationDNSServer,
|
||||||
|
mkInitializationDNSServers,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationDNSSchema, map[string]schema.ValueType{
|
||||||
|
mkInitializationDNSDomain: schema.TypeString,
|
||||||
|
mkInitializationDNSServer: schema.TypeString,
|
||||||
|
mkInitializationDNSServers: schema.TypeList,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationIPConfigSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkInitializationIPConfig,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationIPConfigSchema, []string{
|
||||||
|
mkInitializationIPConfigIPv4,
|
||||||
|
mkInitializationIPConfigIPv6,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationIPConfigSchema, map[string]schema.ValueType{
|
||||||
|
mkInitializationIPConfigIPv4: schema.TypeList,
|
||||||
|
mkInitializationIPConfigIPv6: schema.TypeList,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationIPConfigIPv4Schema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationIPConfigSchema,
|
||||||
|
mkInitializationIPConfigIPv4,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationIPConfigIPv4Schema, []string{
|
||||||
|
mkInitializationIPConfigIPv4Address,
|
||||||
|
mkInitializationIPConfigIPv4Gateway,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationIPConfigIPv4Schema, map[string]schema.ValueType{
|
||||||
|
mkInitializationIPConfigIPv4Address: schema.TypeString,
|
||||||
|
mkInitializationIPConfigIPv4Gateway: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationIPConfigIPv6Schema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationIPConfigSchema,
|
||||||
|
mkInitializationIPConfigIPv6,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationIPConfigIPv6Schema, []string{
|
||||||
|
mkInitializationIPConfigIPv6Address,
|
||||||
|
mkInitializationIPConfigIPv6Gateway,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationIPConfigIPv6Schema, map[string]schema.ValueType{
|
||||||
|
mkInitializationIPConfigIPv6Address: schema.TypeString,
|
||||||
|
mkInitializationIPConfigIPv6Gateway: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
initializationUserAccountSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
initializationSchema,
|
||||||
|
mkInitializationUserAccount,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, initializationUserAccountSchema, []string{
|
||||||
|
mkInitializationUserAccountKeys,
|
||||||
|
mkInitializationUserAccountPassword,
|
||||||
|
mkInitializationUserAccountUsername,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, initializationUserAccountSchema, map[string]schema.ValueType{
|
||||||
|
mkInitializationUserAccountKeys: schema.TypeList,
|
||||||
|
mkInitializationUserAccountPassword: schema.TypeString,
|
||||||
|
mkInitializationUserAccountUsername: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
memorySchema := test.AssertNestedSchemaExistence(t, s, mkMemory)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, memorySchema, []string{
|
||||||
|
mkMemoryDedicated,
|
||||||
|
mkMemoryFloating,
|
||||||
|
mkMemoryShared,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, memorySchema, map[string]schema.ValueType{
|
||||||
|
mkMemoryDedicated: schema.TypeInt,
|
||||||
|
mkMemoryFloating: schema.TypeInt,
|
||||||
|
mkMemoryShared: schema.TypeInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
networkDeviceSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkNetworkDevice,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, networkDeviceSchema, []string{
|
||||||
|
mkNetworkDeviceBridge,
|
||||||
|
mkNetworkDeviceEnabled,
|
||||||
|
mkNetworkDeviceMACAddress,
|
||||||
|
mkNetworkDeviceModel,
|
||||||
|
mkNetworkDeviceRateLimit,
|
||||||
|
mkNetworkDeviceVLANID,
|
||||||
|
mkNetworkDeviceMTU,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, networkDeviceSchema, map[string]schema.ValueType{
|
||||||
|
mkNetworkDeviceBridge: schema.TypeString,
|
||||||
|
mkNetworkDeviceEnabled: schema.TypeBool,
|
||||||
|
mkNetworkDeviceMACAddress: schema.TypeString,
|
||||||
|
mkNetworkDeviceModel: schema.TypeString,
|
||||||
|
mkNetworkDeviceRateLimit: schema.TypeFloat,
|
||||||
|
mkNetworkDeviceVLANID: schema.TypeInt,
|
||||||
|
mkNetworkDeviceMTU: schema.TypeInt,
|
||||||
|
})
|
||||||
|
|
||||||
|
operatingSystemSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkOperatingSystem,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, operatingSystemSchema, []string{
|
||||||
|
mkOperatingSystemType,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, operatingSystemSchema, map[string]schema.ValueType{
|
||||||
|
mkOperatingSystemType: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
serialDeviceSchema := test.AssertNestedSchemaExistence(
|
||||||
|
t,
|
||||||
|
s,
|
||||||
|
mkSerialDevice,
|
||||||
|
)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, serialDeviceSchema, []string{
|
||||||
|
mkSerialDeviceDevice,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, serialDeviceSchema, map[string]schema.ValueType{
|
||||||
|
mkSerialDeviceDevice: schema.TypeString,
|
||||||
|
})
|
||||||
|
|
||||||
|
vgaSchema := test.AssertNestedSchemaExistence(t, s, mkVGA)
|
||||||
|
|
||||||
|
test.AssertOptionalArguments(t, vgaSchema, []string{
|
||||||
|
mkVGAEnabled,
|
||||||
|
mkVGAMemory,
|
||||||
|
mkVGAType,
|
||||||
|
})
|
||||||
|
|
||||||
|
test.AssertValueTypes(t, vgaSchema, map[string]schema.ValueType{
|
||||||
|
mkVGAEnabled: schema.TypeBool,
|
||||||
|
mkVGAMemory: schema.TypeInt,
|
||||||
|
mkVGAType: schema.TypeString,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_parseImportIDWIthNodeName(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
value string
|
||||||
|
valid bool
|
||||||
|
expectedNodeName string
|
||||||
|
expectedID string
|
||||||
|
}{
|
||||||
|
{"empty", "", false, "", ""},
|
||||||
|
{"missing slash", "invalid", false, "", ""},
|
||||||
|
{"valid", "host/id", true, "host", "id"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
tt := tt
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
nodeName, id, err := parseImportIDWithNodeName(tt.value)
|
||||||
|
|
||||||
|
if !tt.valid {
|
||||||
|
require.Error(t, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, tt.expectedNodeName, nodeName)
|
||||||
|
require.Equal(t, tt.expectedID, id)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
@ -1,492 +0,0 @@
|
|||||||
/*
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package resource
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
|
|
||||||
"github.com/bpg/terraform-provider-proxmox/proxmoxtf/test"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TestVMInstantiation tests whether the VM instance can be instantiated.
|
|
||||||
func TestVMInstantiation(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
s := VM()
|
|
||||||
if s == nil {
|
|
||||||
t.Fatalf("Cannot instantiate VM")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestVMSchema tests the VM schema.
|
|
||||||
func TestVMSchema(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
s := VM()
|
|
||||||
|
|
||||||
test.AssertRequiredArguments(t, s, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMNodeName,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, s, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMACPI,
|
|
||||||
mkResourceVirtualEnvironmentVMAgent,
|
|
||||||
mkResourceVirtualEnvironmentVMAudioDevice,
|
|
||||||
mkResourceVirtualEnvironmentVMBIOS,
|
|
||||||
mkResourceVirtualEnvironmentVMBootOrder,
|
|
||||||
mkResourceVirtualEnvironmentVMCDROM,
|
|
||||||
mkResourceVirtualEnvironmentVMClone,
|
|
||||||
mkResourceVirtualEnvironmentVMCPU,
|
|
||||||
mkResourceVirtualEnvironmentVMDescription,
|
|
||||||
mkResourceVirtualEnvironmentVMDisk,
|
|
||||||
mkResourceVirtualEnvironmentVMEFIDisk,
|
|
||||||
mkResourceVirtualEnvironmentVMInitialization,
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCI,
|
|
||||||
mkResourceVirtualEnvironmentVMHostUSB,
|
|
||||||
mkResourceVirtualEnvironmentVMKeyboardLayout,
|
|
||||||
mkResourceVirtualEnvironmentVMKVMArguments,
|
|
||||||
mkResourceVirtualEnvironmentVMMachine,
|
|
||||||
mkResourceVirtualEnvironmentVMMemory,
|
|
||||||
mkResourceVirtualEnvironmentVMName,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDevice,
|
|
||||||
mkResourceVirtualEnvironmentVMOperatingSystem,
|
|
||||||
mkResourceVirtualEnvironmentVMPoolID,
|
|
||||||
mkResourceVirtualEnvironmentVMSerialDevice,
|
|
||||||
mkResourceVirtualEnvironmentVMStarted,
|
|
||||||
mkResourceVirtualEnvironmentVMTabletDevice,
|
|
||||||
mkResourceVirtualEnvironmentVMTemplate,
|
|
||||||
mkResourceVirtualEnvironmentVMVMID,
|
|
||||||
mkResourceVirtualEnvironmentVMSCSIHardware,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertComputedAttributes(t, s, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMIPv4Addresses,
|
|
||||||
mkResourceVirtualEnvironmentVMIPv6Addresses,
|
|
||||||
mkResourceVirtualEnvironmentVMMACAddresses,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkInterfaceNames,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, s, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMACPI: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMAgent: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMAudioDevice: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMBIOS: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMBootOrder: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMCDROM: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMCPU: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMDescription: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMDisk: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMEFIDisk: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCI: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMHostUSB: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMInitialization: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMIPv4Addresses: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMIPv6Addresses: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMKeyboardLayout: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMKVMArguments: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMMachine: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMMemory: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMName: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDevice: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMMACAddresses: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkInterfaceNames: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMOperatingSystem: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMPoolID: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMSerialDevice: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMStarted: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMTabletDevice: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMTemplate: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMVMID: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentVMSCSIHardware: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
agentSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMAgent)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, agentSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMAgentEnabled,
|
|
||||||
mkResourceVirtualEnvironmentVMAgentTimeout,
|
|
||||||
mkResourceVirtualEnvironmentVMAgentTrim,
|
|
||||||
mkResourceVirtualEnvironmentVMAgentType,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, agentSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMAgentEnabled: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMAgentTrim: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMAgentType: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
audioDeviceSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMAudioDevice)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, audioDeviceSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMAudioDeviceDevice,
|
|
||||||
mkResourceVirtualEnvironmentVMAudioDeviceDriver,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, audioDeviceSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMAudioDeviceDevice: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMAudioDeviceDriver: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
cdromSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMCDROM)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, cdromSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMCDROMEnabled,
|
|
||||||
mkResourceVirtualEnvironmentVMCDROMFileID,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, cdromSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMCDROMEnabled: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMCDROMFileID: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
cloneSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMClone)
|
|
||||||
|
|
||||||
test.AssertRequiredArguments(t, cloneSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMCloneVMID,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, cloneSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMCloneDatastoreID,
|
|
||||||
mkResourceVirtualEnvironmentVMCloneNodeName,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, cloneSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMCloneDatastoreID: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMCloneNodeName: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMCloneVMID: schema.TypeInt,
|
|
||||||
})
|
|
||||||
|
|
||||||
cpuSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMCPU)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, cpuSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMCPUArchitecture,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUCores,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUFlags,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUHotplugged,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUNUMA,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUSockets,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUType,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUUnits,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, cpuSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMCPUArchitecture: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUCores: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUFlags: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUHotplugged: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUNUMA: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUSockets: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUType: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMCPUUnits: schema.TypeInt,
|
|
||||||
})
|
|
||||||
|
|
||||||
diskSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMDisk)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, diskSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMDiskDatastoreID,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskPathInDatastore,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskFileFormat,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskFileID,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskSize,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, diskSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMDiskDatastoreID: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskPathInDatastore: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskFileFormat: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskFileID: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskSize: schema.TypeInt,
|
|
||||||
})
|
|
||||||
|
|
||||||
diskSpeedSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
diskSchema,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskSpeed,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, diskSpeedSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMDiskSpeedRead,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskSpeedReadBurstable,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskSpeedWrite,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskSpeedWriteBurstable,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, diskSpeedSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMDiskSpeedRead: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskSpeedReadBurstable: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskSpeedWrite: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentVMDiskSpeedWriteBurstable: schema.TypeInt,
|
|
||||||
})
|
|
||||||
|
|
||||||
efiDiskSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMEFIDisk)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, efiDiskSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMEFIDiskDatastoreID,
|
|
||||||
mkResourceVirtualEnvironmentVMEFIDiskFileFormat,
|
|
||||||
mkResourceVirtualEnvironmentVMEFIDiskType,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, efiDiskSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMEFIDiskDatastoreID: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMEFIDiskFileFormat: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMEFIDiskType: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
s,
|
|
||||||
mkResourceVirtualEnvironmentVMInitialization,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationDatastoreID,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationInterface,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationDNS,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfig,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationUserAccount,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationDatastoreID: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationInterface: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationDNS: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfig: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationUserAccount: schema.TypeList,
|
|
||||||
})
|
|
||||||
|
|
||||||
hostPCISchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMHostPCI)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, hostPCISchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCIDeviceMDev,
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCIDevicePCIE,
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCIDeviceROMBAR,
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCIDeviceROMFile,
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCIDeviceXVGA,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, hostPCISchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCIDevice: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCIDeviceMDev: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCIDevicePCIE: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCIDeviceROMBAR: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCIDeviceROMFile: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMHostPCIDeviceXVGA: schema.TypeBool,
|
|
||||||
})
|
|
||||||
|
|
||||||
hostUSBSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMHostUSB)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, hostUSBSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMHostUSBDeviceMapping,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, hostUSBSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMHostUSBDevice: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMHostUSBDeviceUSB3: schema.TypeBool,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationDNSSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
initializationSchema,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationDNS,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationDNSSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationDNSDomain,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationDNSServer,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationDNSServers,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationDNSSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationDNSDomain: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationDNSServer: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationDNSServers: schema.TypeList,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationIPConfigSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
initializationSchema,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfig,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationIPConfigSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationIPConfigSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6: schema.TypeList,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationIPConfigIPv4Schema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
initializationIPConfigSchema,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationIPConfigIPv4Schema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4Address,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4Gateway,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationIPConfigIPv4Schema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4Address: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv4Gateway: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationIPConfigIPv6Schema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
initializationIPConfigSchema,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationIPConfigIPv6Schema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6Address,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6Gateway,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationIPConfigIPv6Schema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6Address: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationIPConfigIPv6Gateway: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
initializationUserAccountSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
initializationSchema,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationUserAccount,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, initializationUserAccountSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationUserAccountKeys,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationUserAccountPassword,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationUserAccountUsername,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, initializationUserAccountSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationUserAccountKeys: schema.TypeList,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationUserAccountPassword: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMInitializationUserAccountUsername: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
memorySchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMMemory)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, memorySchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMMemoryDedicated,
|
|
||||||
mkResourceVirtualEnvironmentVMMemoryFloating,
|
|
||||||
mkResourceVirtualEnvironmentVMMemoryShared,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, memorySchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMMemoryDedicated: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentVMMemoryFloating: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentVMMemoryShared: schema.TypeInt,
|
|
||||||
})
|
|
||||||
|
|
||||||
networkDeviceSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
s,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDevice,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, networkDeviceSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceBridge,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceEnabled,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceMACAddress,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceModel,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceRateLimit,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceVLANID,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceMTU,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, networkDeviceSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceBridge: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceEnabled: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceMACAddress: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceModel: schema.TypeString,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceRateLimit: schema.TypeFloat,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceVLANID: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentVMNetworkDeviceMTU: schema.TypeInt,
|
|
||||||
})
|
|
||||||
|
|
||||||
operatingSystemSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
s,
|
|
||||||
mkResourceVirtualEnvironmentVMOperatingSystem,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, operatingSystemSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMOperatingSystemType,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, operatingSystemSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMOperatingSystemType: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
serialDeviceSchema := test.AssertNestedSchemaExistence(
|
|
||||||
t,
|
|
||||||
s,
|
|
||||||
mkResourceVirtualEnvironmentVMSerialDevice,
|
|
||||||
)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, serialDeviceSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMSerialDeviceDevice,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, serialDeviceSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMSerialDeviceDevice: schema.TypeString,
|
|
||||||
})
|
|
||||||
|
|
||||||
vgaSchema := test.AssertNestedSchemaExistence(t, s, mkResourceVirtualEnvironmentVMVGA)
|
|
||||||
|
|
||||||
test.AssertOptionalArguments(t, vgaSchema, []string{
|
|
||||||
mkResourceVirtualEnvironmentVMVGAEnabled,
|
|
||||||
mkResourceVirtualEnvironmentVMVGAMemory,
|
|
||||||
mkResourceVirtualEnvironmentVMVGAType,
|
|
||||||
})
|
|
||||||
|
|
||||||
test.AssertValueTypes(t, vgaSchema, map[string]schema.ValueType{
|
|
||||||
mkResourceVirtualEnvironmentVMVGAEnabled: schema.TypeBool,
|
|
||||||
mkResourceVirtualEnvironmentVMVGAMemory: schema.TypeInt,
|
|
||||||
mkResourceVirtualEnvironmentVMVGAType: schema.TypeString,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_parseImportIDWIthNodeName(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
value string
|
|
||||||
valid bool
|
|
||||||
expectedNodeName string
|
|
||||||
expectedID string
|
|
||||||
}{
|
|
||||||
{"empty", "", false, "", ""},
|
|
||||||
{"missing slash", "invalid", false, "", ""},
|
|
||||||
{"valid", "host/id", true, "host", "id"},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, tt := range tests {
|
|
||||||
tt := tt
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
nodeName, id, err := parseImportIDWithNodeName(tt.value)
|
|
||||||
|
|
||||||
if !tt.valid {
|
|
||||||
require.Error(t, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.Equal(t, tt.expectedNodeName, nodeName)
|
|
||||||
require.Equal(t, tt.expectedID, id)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user