From a9eec5a50c099acf8a989cee45e1a89b77b161e3 Mon Sep 17 00:00:00 2001 From: "abhishek.chaudhary" Date: Tue, 10 Dec 2024 15:13:33 +0530 Subject: [PATCH] golint fixes --- .../data_source_nutanix_host_entity_v2.go | 26 +++--- ...data_source_nutanix_host_entity_v2_test.go | 8 +- nutanix/services/clustersv2/main_test.go | 2 +- ..._cluster_discover_unconfigured_nodes_v2.go | 6 +- ...ter_discover_unconfigured_nodes_v2_test.go | 2 +- ...nutanix_cluster_entity_add_node_v2_test.go | 4 +- ...ource_nutanix_cluster_fetch_networks_v2.go | 6 +- ...esource_nutanix_pc_registration_v2_test.go | 8 +- ...a_source_nutanix_recovery_point_v2_test.go | 6 +- ..._nutanix_vm_recovery_point_info_v2_test.go | 30 +++---- .../services/dataprotectionv2/main_test.go | 2 +- ...tanix_recovery_points_replicate_v2_test.go | 2 +- ...urce_nutanix_recovery_points_restore_v2.go | 4 +- ...nutanix_recovery_points_restore_v2_test.go | 4 +- .../resource_nutanix_recovery_points_v2.go | 4 +- ...esource_nutanix_recovery_points_v2_test.go | 24 +++--- ...ource_nutanix_directory_service_v2_test.go | 2 +- ...urce_nutanix_directory_services_v2_test.go | 2 +- .../data_source_nutanix_user_group_v2_test.go | 2 +- ...data_source_nutanix_user_groups_v2_test.go | 2 +- .../iamv2/datasource_nutanix_user_v2_test.go | 2 +- nutanix/services/iamv2/main_test.go | 22 ++--- ..._nutanix_authorization_policies_v2_test.go | 33 +++----- ...urce_nutanix_directory_services_v2_test.go | 12 +-- .../resource_nutanix_saml_idp_v2_test.go | 4 +- .../resource_nutanix_user_groups_v2_test.go | 8 +- .../iamv2/resource_nutanix_users_v2_test.go | 8 +- nutanix/services/networkingv2/main_test.go | 2 +- .../resource_nutanix_vpcs_v2_test.go | 34 ++++---- ...ce_nutanix_storage_container_stats_test.go | 4 +- ...ta_source_nutanix_storge_container_test.go | 16 ++-- ...resource_nutanix_storge_containers_test.go | 4 +- .../data_source_nutanix_virtual_machine_v2.go | 82 ++++++++----------- .../resource_nutanix_image_placement_v2.go | 5 +- .../vmmv2/resource_nutanix_image_v2.go | 5 +- .../resource_nutanix_template_deploy_v2.go | 31 +------ .../resource_nutanix_template_v2_test.go | 4 +- ...ce_nutanix_vms_shutdown_actions_v2_test.go | 5 +- ...data_source_nutanix_volume_disk_v2_test.go | 4 +- ...ata_source_nutanix_volume_disks_v2_test.go | 4 +- ...anix_volume_group_iscsi_clients_v2_test.go | 2 +- ...ata_source_nutanix_volume_group_v2_test.go | 2 +- ...source_nutanix_volume_group_vms_v2_test.go | 9 +- ...ta_source_nutanix_volume_groups_v2_test.go | 4 +- nutanix/services/volumesv2/helpers_test.go | 6 +- nutanix/services/volumesv2/main_test.go | 2 +- ...ource_nutanix_volume_group_disk_v2_test.go | 4 +- ...tanix_volume_group_iscsi_client_v2_test.go | 2 +- .../resource_nutanix_volume_group_v2_test.go | 2 +- ...esource_nutanix_volume_group_vm_v2_test.go | 6 +- 50 files changed, 214 insertions(+), 260 deletions(-) diff --git a/nutanix/services/clustersv2/data_source_nutanix_host_entity_v2.go b/nutanix/services/clustersv2/data_source_nutanix_host_entity_v2.go index 18f6bb3cf..ed0b508be 100644 --- a/nutanix/services/clustersv2/data_source_nutanix_host_entity_v2.go +++ b/nutanix/services/clustersv2/data_source_nutanix_host_entity_v2.go @@ -579,21 +579,21 @@ func flattenHypervisorState(pr *import1.HypervisorState) string { func flattenHostHypervisorType(pr *import1.HypervisorType) string { if pr != nil { - const AHV, ESX, HYPERV, XEN, NATIVEHOST = 2, 3, 4, 5, 6 + const ahv, esx, hyperv, xen, native = 2, 3, 4, 5, 6 - if *pr == import1.HypervisorType(AHV) { + if *pr == import1.HypervisorType(ahv) { return "AHV" } - if *pr == import1.HypervisorType(ESX) { + if *pr == import1.HypervisorType(esx) { return "ESX" } - if *pr == import1.HypervisorType(HYPERV) { + if *pr == import1.HypervisorType(hyperv) { return "HYPERV" } - if *pr == import1.HypervisorType(XEN) { + if *pr == import1.HypervisorType(xen) { return "XEN" } - if *pr == import1.HypervisorType(NATIVEHOST) { + if *pr == import1.HypervisorType(native) { return "NATIVEHOST" } } @@ -602,12 +602,12 @@ func flattenHostHypervisorType(pr *import1.HypervisorType) string { func flattenAcropolisConnectionState(pr *import1.AcropolisConnectionState) string { if pr != nil { - const CONNECTED, DISCONNECTED = 2, 3 + const connected, disconnected = 2, 3 - if *pr == import1.AcropolisConnectionState(CONNECTED) { + if *pr == import1.AcropolisConnectionState(connected) { return "CONNECTED" } - if *pr == import1.AcropolisConnectionState(DISCONNECTED) { + if *pr == import1.AcropolisConnectionState(disconnected) { return "DISCONNECTED" } } @@ -718,14 +718,14 @@ func flattenKeyManagementDeviceToCertStatusInfo(pr []import1.KeyManagementDevice func flattenStorageTierReference(pr *import1.StorageTierReference) string { if pr != nil { - const PCIE_SSD, SATA_SSD, HDD = 2, 3, 4 - if *pr == import1.StorageTierReference(PCIE_SSD) { + const pci, sata, hdd = 2, 3, 4 + if *pr == import1.StorageTierReference(pci) { return "PCIE_SSD" } - if *pr == import1.StorageTierReference(SATA_SSD) { + if *pr == import1.StorageTierReference(sata) { return "SATA_SSD" } - if *pr == import1.StorageTierReference(HDD) { + if *pr == import1.StorageTierReference(hdd) { return "HDD" } } diff --git a/nutanix/services/clustersv2/data_source_nutanix_host_entity_v2_test.go b/nutanix/services/clustersv2/data_source_nutanix_host_entity_v2_test.go index e3728a75a..a735926c4 100644 --- a/nutanix/services/clustersv2/data_source_nutanix_host_entity_v2_test.go +++ b/nutanix/services/clustersv2/data_source_nutanix_host_entity_v2_test.go @@ -33,7 +33,7 @@ func TestAccNutanixHostEntityV2Datasource_WithNoClsExtId(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testHostEntityDatasourceV4WithoutClsExtIdConfig(), + Config: testHostEntityDatasourceV4WithoutClsExtIDConfig(), ExpectError: regexp.MustCompile("Missing required argument"), }, }, @@ -46,7 +46,7 @@ func TestAccNutanixHostEntityV2Datasource_WithNoHostExtId(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testHostEntityDatasourceV4WithoutHostExtIdConfig(), + Config: testHostEntityDatasourceV4WithoutHostExtIDConfig(), ExpectError: regexp.MustCompile("Missing required argument"), }, }, @@ -65,7 +65,7 @@ func testHostEntityDatasourceV4Config() string { ` } -func testHostEntityDatasourceV4WithoutClsExtIdConfig() string { +func testHostEntityDatasourceV4WithoutClsExtIDConfig() string { return ` data "nutanix_host_v2" "test" { ext_id = "00000000-0000-0000-0000-000000000000" @@ -73,7 +73,7 @@ func testHostEntityDatasourceV4WithoutClsExtIdConfig() string { ` } -func testHostEntityDatasourceV4WithoutHostExtIdConfig() string { +func testHostEntityDatasourceV4WithoutHostExtIDConfig() string { return ` data "nutanix_host_v2" "test" { cluster_ext_id = "00000000-0000-0000-0000-000000000000" diff --git a/nutanix/services/clustersv2/main_test.go b/nutanix/services/clustersv2/main_test.go index 117fb24d2..a192357d6 100644 --- a/nutanix/services/clustersv2/main_test.go +++ b/nutanix/services/clustersv2/main_test.go @@ -13,7 +13,7 @@ type TestConfig struct { PEPassword string `json:"pe_password"` CvmIP string `json:"cvm_ip"` Nodes []struct { - CvmIp string `json:"cvm_ip"` + CvmIP string `json:"cvm_ip"` Username string `json:"username"` Password string `json:"password"` } `json:"nodes"` diff --git a/nutanix/services/clustersv2/resource_nutanix_cluster_discover_unconfigured_nodes_v2.go b/nutanix/services/clustersv2/resource_nutanix_cluster_discover_unconfigured_nodes_v2.go index 4ce3f0447..b6361ce06 100644 --- a/nutanix/services/clustersv2/resource_nutanix_cluster_discover_unconfigured_nodes_v2.go +++ b/nutanix/services/clustersv2/resource_nutanix_cluster_discover_unconfigured_nodes_v2.go @@ -315,8 +315,8 @@ func DatasourceNutanixClusterDiscoverUnconfiguredNodesV2Create(ctx context.Conte uuid := strings.Split(utils.StringValue(rUUID.ExtId), "=:")[1] - const UNCONFIGURED_NODES = 2 - taskResponseType := config.TaskResponseType(UNCONFIGURED_NODES) + const unconfiguredNodes = 2 + taskResponseType := config.TaskResponseType(unconfiguredNodes) unconfiguredNodesResp, taskErr := conn.ClusterEntityAPI.FetchTaskResponse(utils.StringPtr(uuid), &taskResponseType) if taskErr != nil { return diag.Errorf("error while fetching Task Response for Unconfigured Nodes : %v", taskErr) @@ -324,7 +324,7 @@ func DatasourceNutanixClusterDiscoverUnconfiguredNodesV2Create(ctx context.Conte taskResp := unconfiguredNodesResp.Data.GetValue().(config.TaskResponse) - if *taskResp.TaskResponseType != config.TaskResponseType(UNCONFIGURED_NODES) { + if *taskResp.TaskResponseType != config.TaskResponseType(unconfiguredNodes) { return diag.Errorf("error while fetching Task Response for Unconfigured Nodes : %v", "task response type mismatch") } diff --git a/nutanix/services/clustersv2/resource_nutanix_cluster_discover_unconfigured_nodes_v2_test.go b/nutanix/services/clustersv2/resource_nutanix_cluster_discover_unconfigured_nodes_v2_test.go index 17fce072a..7c56c6462 100644 --- a/nutanix/services/clustersv2/resource_nutanix_cluster_discover_unconfigured_nodes_v2_test.go +++ b/nutanix/services/clustersv2/resource_nutanix_cluster_discover_unconfigured_nodes_v2_test.go @@ -20,7 +20,7 @@ func TestAccNutanixClusterDiscoverUnconfiguredNodesV2Resource_basic(t *testing.T Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceNameDiscoverUnconfiguredNodes, "ext_id"), resource.TestCheckResourceAttrSet(resourceNameDiscoverUnconfiguredNodes, "unconfigured_nodes.#"), - resource.TestCheckResourceAttr(resourceNameDiscoverUnconfiguredNodes, "unconfigured_nodes.0.cvm_ip.0.ipv4.0.value", testVars.Clusters.Nodes[0].CvmIp), + resource.TestCheckResourceAttr(resourceNameDiscoverUnconfiguredNodes, "unconfigured_nodes.0.cvm_ip.0.ipv4.0.value", testVars.Clusters.Nodes[0].CvmIP), ), }, }, diff --git a/nutanix/services/clustersv2/resource_nutanix_cluster_entity_add_node_v2_test.go b/nutanix/services/clustersv2/resource_nutanix_cluster_entity_add_node_v2_test.go index ae184db08..1277d7b04 100644 --- a/nutanix/services/clustersv2/resource_nutanix_cluster_entity_add_node_v2_test.go +++ b/nutanix/services/clustersv2/resource_nutanix_cluster_entity_add_node_v2_test.go @@ -55,7 +55,7 @@ func TestAccNutanixClusterAddNodeV2Resource_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( // unconfigured Node to be added check resource.TestCheckResourceAttr(resourceNameDiscoverUnconfiguredNode, "unconfigured_nodes.#", "1"), - resource.TestCheckResourceAttr(resourceNameDiscoverUnconfiguredNode, "unconfigured_nodes.0.cvm_ip.0.ipv4.0.value", testVars.Clusters.Nodes[3].CvmIp), + resource.TestCheckResourceAttr(resourceNameDiscoverUnconfiguredNode, "unconfigured_nodes.0.cvm_ip.0.ipv4.0.value", testVars.Clusters.Nodes[3].CvmIP), resource.TestCheckResourceAttrSet(resourceNameDiscoverUnconfiguredNode, "unconfigured_nodes.0.nos_version"), resource.TestCheckResourceAttrSet(resourceNameDiscoverUnconfiguredNode, "unconfigured_nodes.0.node_uuid"), @@ -83,7 +83,7 @@ func TestAccNutanixClusterAddNodeV2Resource_basic(t *testing.T) { Config: testAccClustersConfig(clusterName) + testAccAddNodeToClusterConfig(), Check: resource.ComposeTestCheckFunc( // add node to cluster check - resource.TestCheckResourceAttr(resourceNameAddNodeToCluster, "node_params.0.node_list.0.cvm_ip.0.ipv4.0.value", testVars.Clusters.Nodes[3].CvmIp), + resource.TestCheckResourceAttr(resourceNameAddNodeToCluster, "node_params.0.node_list.0.cvm_ip.0.ipv4.0.value", testVars.Clusters.Nodes[3].CvmIP), ), }, }, diff --git a/nutanix/services/clustersv2/resource_nutanix_cluster_fetch_networks_v2.go b/nutanix/services/clustersv2/resource_nutanix_cluster_fetch_networks_v2.go index ad13ce157..2d0a74c90 100644 --- a/nutanix/services/clustersv2/resource_nutanix_cluster_fetch_networks_v2.go +++ b/nutanix/services/clustersv2/resource_nutanix_cluster_fetch_networks_v2.go @@ -331,8 +331,8 @@ func ResourceNutanixClusterUnconfiguredNodeNetworkV2Create(ctx context.Context, uuid := strings.Split(utils.StringValue(rUUID.ExtId), "=:")[1] - const NETWORKING_DETAILS = 3 - taskResponseType := config.TaskResponseType(NETWORKING_DETAILS) + const networkingDetails = 3 + taskResponseType := config.TaskResponseType(networkingDetails) networkDetailsResp, taskErr := conn.ClusterEntityAPI.FetchTaskResponse(utils.StringPtr(uuid), &taskResponseType) if taskErr != nil { return diag.Errorf("error while fetching Task Response for Unconfigured Nodes : %v", taskErr) @@ -340,7 +340,7 @@ func ResourceNutanixClusterUnconfiguredNodeNetworkV2Create(ctx context.Context, taskResp := networkDetailsResp.Data.GetValue().(config.TaskResponse) - if *taskResp.TaskResponseType != config.TaskResponseType(NETWORKING_DETAILS) { + if *taskResp.TaskResponseType != config.TaskResponseType(networkingDetails) { return diag.Errorf("error while fetching Task Response for Network Detail Nodes : %v", "task response type mismatch") } diff --git a/nutanix/services/clustersv2/resource_nutanix_pc_registration_v2_test.go b/nutanix/services/clustersv2/resource_nutanix_pc_registration_v2_test.go index 86ab0e412..5467e5a0d 100644 --- a/nutanix/services/clustersv2/resource_nutanix_pc_registration_v2_test.go +++ b/nutanix/services/clustersv2/resource_nutanix_pc_registration_v2_test.go @@ -15,7 +15,7 @@ func TestAccNutanixPePcRegistrationV2Resource_ValidationsDomainManagerRemoteClus Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccClusterResourceDomainManagerRemoteClusterSpecInvalidConfigWithoutPcExtId(), + Config: testAccClusterResourceDomainManagerRemoteClusterSpecInvalidConfigWithoutPcExtID(), ExpectError: regexp.MustCompile("Missing required argument"), }, { @@ -61,7 +61,7 @@ func TestAccNutanixPePcRegistrationV2Resource_ValidationsClusterReference(t *tes Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccClusterResourceClusterReferenceInvalidConfigWithoutClusterExtId(), + Config: testAccClusterResourceClusterReferenceInvalidConfigWithoutClusterExtID(), ExpectError: regexp.MustCompile("Missing required argument"), }, }, @@ -69,7 +69,7 @@ func TestAccNutanixPePcRegistrationV2Resource_ValidationsClusterReference(t *tes } // Invalid Configs for DomainManagerRemoteClusterSpec -func testAccClusterResourceDomainManagerRemoteClusterSpecInvalidConfigWithoutPcExtId() string { +func testAccClusterResourceDomainManagerRemoteClusterSpecInvalidConfigWithoutPcExtID() string { return ` resource "nutanix_pc_registration_v2" "test" { remote_cluster { @@ -224,7 +224,7 @@ func testAccClusterResourceAOSRemoteClusterSpecInvalidConfigWithoutAuthenticatio // Invalid Configs for ClusterReference -func testAccClusterResourceClusterReferenceInvalidConfigWithoutClusterExtId() string { +func testAccClusterResourceClusterReferenceInvalidConfigWithoutClusterExtID() string { return ` resource "nutanix_pc_registration_v2" "test" { remote_cluster { diff --git a/nutanix/services/dataprotectionv2/data_source_nutanix_recovery_point_v2_test.go b/nutanix/services/dataprotectionv2/data_source_nutanix_recovery_point_v2_test.go index 9e16345e3..572b337a0 100644 --- a/nutanix/services/dataprotectionv2/data_source_nutanix_recovery_point_v2_test.go +++ b/nutanix/services/dataprotectionv2/data_source_nutanix_recovery_point_v2_test.go @@ -27,7 +27,7 @@ func TestAccNutanixRecoveryPointV2Datasource_VmRecoveryPoints(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVmConfig(vmName) + testRecoveryPointDatasourceConfigWithVmRecoveryPoints(name, expirationTimeFormatted), + Config: testVmConfig(vmName) + testRecoveryPointDatasourceConfigWithVMRecoveryPoints(name, expirationTimeFormatted), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(datasourceNameRecoveryPoint, "ext_id"), resource.TestCheckResourceAttr(datasourceNameRecoveryPoint, "name", name), @@ -41,7 +41,7 @@ func TestAccNutanixRecoveryPointV2Datasource_VmRecoveryPoints(t *testing.T) { }) } -func testRecoveryPointDatasourceConfigWithVmRecoveryPoints(name, expirationTime string) string { +func testRecoveryPointDatasourceConfigWithVMRecoveryPoints(name, expirationTime string) string { return fmt.Sprintf(` resource "nutanix_recovery_points_v2" "test" { @@ -89,7 +89,7 @@ func testVmConfig(name string) string { `, name, filepath) } -func testVm2Config(name string) string { +func testVMConfig(name string) string { return fmt.Sprintf(` resource "nutanix_virtual_machine_v2" "test-2"{ diff --git a/nutanix/services/dataprotectionv2/data_source_nutanix_vm_recovery_point_info_v2_test.go b/nutanix/services/dataprotectionv2/data_source_nutanix_vm_recovery_point_info_v2_test.go index 3d2dc284e..cf98680dc 100644 --- a/nutanix/services/dataprotectionv2/data_source_nutanix_vm_recovery_point_info_v2_test.go +++ b/nutanix/services/dataprotectionv2/data_source_nutanix_vm_recovery_point_info_v2_test.go @@ -10,7 +10,7 @@ import ( acc "github.com/terraform-providers/terraform-provider-nutanix/nutanix/acctest" ) -const datasourceNameVmRecoveryPoint = "data.nutanix_vm_recovery_point_info_v2.test" +const datasourceNameVMRecoveryPoint = "data.nutanix_vm_recovery_point_info_v2.test" func TestAccNutanixVmRecoveryPointV2Datasource_VmRecoveryPoint(t *testing.T) { r := acctest.RandInt() @@ -27,12 +27,12 @@ func TestAccNutanixVmRecoveryPointV2Datasource_VmRecoveryPoint(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVmConfig(vmName) + testVmRecoveryPointDatasourceConfigWithVmRecoveryPoint(name, expirationTimeFormatted), + Config: testVmConfig(vmName) + testVMRecoveryPointDatasourceConfigWithVMRecoveryPoint(name, expirationTimeFormatted), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet(datasourceNameVmRecoveryPoint, "ext_id"), - resource.TestCheckResourceAttrSet(datasourceNameVmRecoveryPoint, "location_agnostic_id"), - resource.TestCheckResourceAttrSet(datasourceNameVmRecoveryPoint, "recovery_point_ext_id"), - resource.TestCheckResourceAttrSet(datasourceNameVmRecoveryPoint, "vm_ext_id"), + resource.TestCheckResourceAttrSet(datasourceNameVMRecoveryPoint, "ext_id"), + resource.TestCheckResourceAttrSet(datasourceNameVMRecoveryPoint, "location_agnostic_id"), + resource.TestCheckResourceAttrSet(datasourceNameVMRecoveryPoint, "recovery_point_ext_id"), + resource.TestCheckResourceAttrSet(datasourceNameVMRecoveryPoint, "vm_ext_id"), ), }, }, @@ -55,12 +55,12 @@ func TestAccNutanixVmRecoveryPointV2Datasource_VmRecoveryPointWithAppConsProps(t Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVmConfig(vmName) + testVmRecoveryPointsDatasourceConfigWithAppConsProps(name, expirationTimeFormatted), + Config: testVmConfig(vmName) + testVMRecoveryPointsDatasourceConfigWithAppConsProps(name, expirationTimeFormatted), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet(datasourceNameVmRecoveryPoint, "ext_id"), - resource.TestCheckResourceAttrSet(datasourceNameVmRecoveryPoint, "location_agnostic_id"), - resource.TestCheckResourceAttrSet(datasourceNameVmRecoveryPoint, "recovery_point_ext_id"), - resource.TestCheckResourceAttrSet(datasourceNameVmRecoveryPoint, "vm_ext_id"), + resource.TestCheckResourceAttrSet(datasourceNameVMRecoveryPoint, "ext_id"), + resource.TestCheckResourceAttrSet(datasourceNameVMRecoveryPoint, "location_agnostic_id"), + resource.TestCheckResourceAttrSet(datasourceNameVMRecoveryPoint, "recovery_point_ext_id"), + resource.TestCheckResourceAttrSet(datasourceNameVMRecoveryPoint, "vm_ext_id"), resource.TestCheckResourceAttr(resourceNameRecoveryPoints, "application_consistent_properties.0.backup_type", "FULL_BACKUP"), resource.TestCheckResourceAttr(resourceNameRecoveryPoints, "application_consistent_properties.0.should_include_writers", "true"), resource.TestCheckResourceAttr(resourceNameRecoveryPoints, "application_consistent_properties.0.should_store_vss_metadata", "true"), @@ -71,8 +71,8 @@ func TestAccNutanixVmRecoveryPointV2Datasource_VmRecoveryPointWithAppConsProps(t }) } -func testVmRecoveryPointDatasourceConfigWithVmRecoveryPoint(name, expirationTime string) string { - return testRecoveryPointsResourceConfigWithVmRecoveryPoints(name, expirationTime) + ` +func testVMRecoveryPointDatasourceConfigWithVMRecoveryPoint(name, expirationTime string) string { + return testRecoveryPointsResourceConfigWithVMRecoveryPoints(name, expirationTime) + ` data "nutanix_vm_recovery_point_info_v2" "test" { recovery_point_ext_id = nutanix_recovery_points_v2.test.ext_id ext_id = nutanix_recovery_points_v2.test.vm_recovery_points[0].ext_id @@ -81,8 +81,8 @@ func testVmRecoveryPointDatasourceConfigWithVmRecoveryPoint(name, expirationTime ` } -func testVmRecoveryPointsDatasourceConfigWithAppConsProps(name, expirationTime string) string { - return testRecoveryPointsResourceConfigWithVmRecoveryPointsWithAppConsProps(name, expirationTime) + ` +func testVMRecoveryPointsDatasourceConfigWithAppConsProps(name, expirationTime string) string { + return testRecoveryPointsResourceConfigWithVMRecoveryPointsWithAppConsProps(name, expirationTime) + ` data "nutanix_vm_recovery_point_info_v2" "test" { recovery_point_ext_id = nutanix_recovery_points_v2.test.ext_id ext_id = nutanix_recovery_points_v2.test.vm_recovery_points[0].ext_id diff --git a/nutanix/services/dataprotectionv2/main_test.go b/nutanix/services/dataprotectionv2/main_test.go index 8b98885ff..7f043fdf9 100644 --- a/nutanix/services/dataprotectionv2/main_test.go +++ b/nutanix/services/dataprotectionv2/main_test.go @@ -9,7 +9,7 @@ import ( type TestConfig struct { DataProtection struct { - VmExtID []string `json:"vm_ext_id"` + VMExtID []string `json:"vm_ext_id"` PcExtID string `json:"pc_ext_id"` ClusterExtID string `json:"cluster_ext_id"` } `json:"data_protection"` diff --git a/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_replicate_v2_test.go b/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_replicate_v2_test.go index 545fe4150..b36d28b14 100644 --- a/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_replicate_v2_test.go +++ b/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_replicate_v2_test.go @@ -41,7 +41,7 @@ func TestAccNutanixRecoveryPointReplicateV2Resource_basic(t *testing.T) { } func testRecoveryPointReplicateResourceConfig(name, expirationTime string) string { - return testRecoveryPointsResourceConfigWithVmRecoveryPoints(name, expirationTime) + ` + return testRecoveryPointsResourceConfigWithVMRecoveryPoints(name, expirationTime) + ` resource "nutanix_recovery_point_replicate_v2" "test" { ext_id = nutanix_recovery_points_v2.test.id cluster_ext_id = local.data_protection.cluster_ext_id diff --git a/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_restore_v2.go b/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_restore_v2.go index e025bb66c..84a33f912 100644 --- a/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_restore_v2.go +++ b/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_restore_v2.go @@ -163,7 +163,7 @@ func ResourceNutanixRecoveryPointRestoreV2Create(ctx context.Context, d *schema. } func expandVolumeGroupRecoveryPointRestoreOverrides(vgRecoveryPoints interface{}) []config.VolumeGroupRecoveryPointRestoreOverride { - var volumeGroupRecoveryPointRestoreOverrides []config.VolumeGroupRecoveryPointRestoreOverride + volumeGroupRecoveryPointRestoreOverrides := make([]config.VolumeGroupRecoveryPointRestoreOverride, 0) for _, vgRecoveryPoint := range vgRecoveryPoints.([]interface{}) { vgRecoveryPoint := vgRecoveryPoint.(map[string]interface{}) volumeGroupRecoveryPointRestoreOverride := config.VolumeGroupRecoveryPointRestoreOverride{ @@ -186,7 +186,7 @@ func expandVolumeGroupOverrideSpec(volumeGroupSpec []interface{}) *config.Volume } func expandVMRecoveryPointRestoreOverrides(vmRecoveryPoints interface{}) []config.VmRecoveryPointRestoreOverride { - var vmRecoveryPointRestoreOverrides []config.VmRecoveryPointRestoreOverride + vmRecoveryPointRestoreOverrides := make([]config.VmRecoveryPointRestoreOverride, 0) for _, vmRecoveryPoint := range vmRecoveryPoints.([]interface{}) { vmRecoveryPoint := vmRecoveryPoint.(map[string]interface{}) vmRecoveryPointRestoreOverride := config.VmRecoveryPointRestoreOverride{ diff --git a/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_restore_v2_test.go b/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_restore_v2_test.go index 043f28869..5483c9b9d 100644 --- a/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_restore_v2_test.go +++ b/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_restore_v2_test.go @@ -26,7 +26,7 @@ func TestAccNutanixRecoveryPointRestoreV2Resource_basic(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVmConfig(vmName) + testVm2Config(vmName) + + Config: testVmConfig(vmName) + testVMConfig(vmName) + testRecoveryPointRestoreResourceConfig(name, expirationTimeFormatted), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceNameRecoveryPointRestore, "volume_group_ext_ids.#"), @@ -39,7 +39,7 @@ func TestAccNutanixRecoveryPointRestoreV2Resource_basic(t *testing.T) { } func testRecoveryPointRestoreResourceConfig(name, expirationTime string) string { - return testRecoveryPointsResourceConfigWithVolumeGroupRecoveryPointsWithMultipleVmAndVGs(name, expirationTime) + ` + return testRecoveryPointsResourceConfigWithVolumeGroupRecoveryPointsWithMultipleVMAndVGs(name, expirationTime) + ` resource "nutanix_recovery_point_restore_v2" "test" { ext_id = nutanix_recovery_points_v2.test.id cluster_ext_id = local.cluster_ext_id diff --git a/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_v2.go b/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_v2.go index 0e9d62e0c..330fdeb54 100644 --- a/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_v2.go +++ b/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_v2.go @@ -591,7 +591,7 @@ func expandVolumeGroupRecoveryPoints(volumeGroupRecoveryPoints []interface{}) [] log.Printf("[DEBUG] volume group recovery points is Empty") return nil } - var volumeGroupRecoveryPointsList []config.VolumeGroupRecoveryPoint + volumeGroupRecoveryPointsList := make([]config.VolumeGroupRecoveryPoint, 0) for _, volumeGroupRecoveryPoint := range volumeGroupRecoveryPoints { volumeGroupRecoveryPointMap := volumeGroupRecoveryPoint.(map[string]interface{}) volumeGroupRecoveryPointObj := config.VolumeGroupRecoveryPoint{} @@ -609,7 +609,7 @@ func expandVMRecoveryPoints(vmRecoveryPoints []interface{}) ([]config.VmRecovery log.Printf("[DEBUG] vm recovery points is Empty") return nil, nil } - var vmRecoveryPointsList []config.VmRecoveryPoint + vmRecoveryPointsList := make([]config.VmRecoveryPoint, 0) for _, vmRecoveryPoint := range vmRecoveryPoints { vmRecoveryPointMap := vmRecoveryPoint.(map[string]interface{}) vmRecoveryPointObj := config.VmRecoveryPoint{} diff --git a/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_v2_test.go b/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_v2_test.go index ac0a1b922..17f9eb592 100644 --- a/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_v2_test.go +++ b/nutanix/services/dataprotectionv2/resource_nutanix_recovery_points_v2_test.go @@ -35,7 +35,7 @@ func TestAccNutanixRecoveryPointsV2Resource_VmRecoveryPoints2(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVmConfig(vmName) + testRecoveryPointsResourceConfigWithVmRecoveryPoints(name, expirationTimeFormatted), + Config: testVmConfig(vmName) + testRecoveryPointsResourceConfigWithVMRecoveryPoints(name, expirationTimeFormatted), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceNameRecoveryPoints, "ext_id"), resource.TestCheckResourceAttr(resourceNameRecoveryPoints, "name", name), @@ -68,7 +68,7 @@ func TestAccNutanixRecoveryPointsV2Resource_VmRecoveryPointsWithAppConsProps(t * Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVmConfig(vmName) + testRecoveryPointsResourceConfigWithVmRecoveryPointsWithAppConsProps(name, expirationTimeFormatted), + Config: testVmConfig(vmName) + testRecoveryPointsResourceConfigWithVMRecoveryPointsWithAppConsProps(name, expirationTimeFormatted), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceNameRecoveryPoints, "ext_id"), resource.TestCheckResourceAttr(resourceNameRecoveryPoints, "name", name), @@ -100,8 +100,8 @@ func TestAccNutanixRecoveryPointsV2Resource_VmRecoveryPointsWithMultipleVms(t *t Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVmConfig(vmName) + testVm2Config(vmName) + - testRecoveryPointsResourceConfigWithVmRecoveryPointsWithMultipleVms(name, expirationTimeFormatted), + Config: testVmConfig(vmName) + testVMConfig(vmName) + + testRecoveryPointsResourceConfigWithVMRecoveryPointsWithMultipleVms(name, expirationTimeFormatted), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceNameRecoveryPoints, "ext_id"), resource.TestCheckResourceAttr(resourceNameRecoveryPoints, "name", name), @@ -188,8 +188,8 @@ func TestAccNutanixRecoveryPointsV2Resource_RecoveryPointWithMultipleVmAndVGs(t Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVmConfig(vmName) + testVm2Config(vmName) + - testRecoveryPointsResourceConfigWithVolumeGroupRecoveryPointsWithMultipleVmAndVGs(name, expirationTimeFormatted), + Config: testVmConfig(vmName) + testVMConfig(vmName) + + testRecoveryPointsResourceConfigWithVolumeGroupRecoveryPointsWithMultipleVMAndVGs(name, expirationTimeFormatted), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceNameRecoveryPoints, "ext_id"), resource.TestCheckResourceAttr(resourceNameRecoveryPoints, "name", name), @@ -224,7 +224,7 @@ func TestAccNutanixRecoveryPointsV2Resource_UpdateExpirationTime(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVmConfig(vmName) + testRecoveryPointsResourceConfigWithVmRecoveryPoints(name, expirationTimeFormatted), + Config: testVmConfig(vmName) + testRecoveryPointsResourceConfigWithVMRecoveryPoints(name, expirationTimeFormatted), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceNameRecoveryPoints, "ext_id"), resource.TestCheckResourceAttr(resourceNameRecoveryPoints, "name", name), @@ -235,7 +235,7 @@ func TestAccNutanixRecoveryPointsV2Resource_UpdateExpirationTime(t *testing.T) { ), }, { - Config: testVmConfig(vmName) + testRecoveryPointsResourceConfigWithVmRecoveryPoints(name, expirationTimeUpdateFormatted), + Config: testVmConfig(vmName) + testRecoveryPointsResourceConfigWithVMRecoveryPoints(name, expirationTimeUpdateFormatted), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceNameRecoveryPoints, "ext_id"), resource.TestCheckResourceAttr(resourceNameRecoveryPoints, "name", name), @@ -249,7 +249,7 @@ func TestAccNutanixRecoveryPointsV2Resource_UpdateExpirationTime(t *testing.T) { }) } -func testRecoveryPointsResourceConfigWithVmRecoveryPoints(name, expirationTime string) string { +func testRecoveryPointsResourceConfigWithVMRecoveryPoints(name, expirationTime string) string { return fmt.Sprintf(` resource "nutanix_recovery_points_v2" "test" { @@ -267,7 +267,7 @@ func testRecoveryPointsResourceConfigWithVmRecoveryPoints(name, expirationTime s }`, name, expirationTime) } -func testRecoveryPointsResourceConfigWithVmRecoveryPointsWithMultipleVms(name, expirationTime string) string { +func testRecoveryPointsResourceConfigWithVMRecoveryPointsWithMultipleVms(name, expirationTime string) string { return fmt.Sprintf(` resource "nutanix_recovery_points_v2" "test" { @@ -284,7 +284,7 @@ func testRecoveryPointsResourceConfigWithVmRecoveryPointsWithMultipleVms(name, e }`, name, expirationTime) } -func testRecoveryPointsResourceConfigWithVmRecoveryPointsWithAppConsProps(name, expirationTime string) string { +func testRecoveryPointsResourceConfigWithVMRecoveryPointsWithAppConsProps(name, expirationTime string) string { return fmt.Sprintf(` resource "nutanix_recovery_points_v2" "test" { @@ -337,7 +337,7 @@ func testRecoveryPointsResourceConfigWithVolumeGroupRecoveryPointsWithMultipleVG }`, name, expirationTime) } -func testRecoveryPointsResourceConfigWithVolumeGroupRecoveryPointsWithMultipleVmAndVGs(name, expirationTime string) string { +func testRecoveryPointsResourceConfigWithVolumeGroupRecoveryPointsWithMultipleVMAndVGs(name, expirationTime string) string { vg1 := testAccVolumeGroup1ResourceConfig("vg-1-"+name, "test volume group description") vg2 := testAccVolumeGroup2ResourceConfig("vg-2-"+name, "test volume group description") return vg1 + vg2 + fmt.Sprintf(` diff --git a/nutanix/services/iamv2/data_source_nutanix_directory_service_v2_test.go b/nutanix/services/iamv2/data_source_nutanix_directory_service_v2_test.go index 528f1534f..6ce3427b9 100644 --- a/nutanix/services/iamv2/data_source_nutanix_directory_service_v2_test.go +++ b/nutanix/services/iamv2/data_source_nutanix_directory_service_v2_test.go @@ -22,7 +22,7 @@ func TestAccNutanixDirectoryServiceV2Datasource_Basic(t *testing.T) { resource.TestCheckResourceAttr(datasourceNameDirectoryService, "name", testVars.Iam.DirectoryServices.Name), resource.TestCheckResourceAttr(datasourceNameDirectoryService, "domain_name", testVars.Iam.DirectoryServices.DomainName), resource.TestCheckResourceAttr(datasourceNameDirectoryService, "directory_type", "ACTIVE_DIRECTORY"), - resource.TestCheckResourceAttr(datasourceNameDirectoryService, "url", testVars.Iam.DirectoryServices.Url), + resource.TestCheckResourceAttr(datasourceNameDirectoryService, "url", testVars.Iam.DirectoryServices.URL), resource.TestCheckResourceAttr(datasourceNameDirectoryService, "service_account.0.username", testVars.Iam.DirectoryServices.ServiceAccount.Username), resource.TestCheckResourceAttrSet(datasourceNameDirectoryService, "service_account.0.password"), resource.TestCheckResourceAttr(datasourceNameDirectoryService, "white_listed_groups.0", testVars.Iam.DirectoryServices.WhiteListedGroups[0]), diff --git a/nutanix/services/iamv2/data_source_nutanix_directory_services_v2_test.go b/nutanix/services/iamv2/data_source_nutanix_directory_services_v2_test.go index b6dddaff6..a350fe3d9 100644 --- a/nutanix/services/iamv2/data_source_nutanix_directory_services_v2_test.go +++ b/nutanix/services/iamv2/data_source_nutanix_directory_services_v2_test.go @@ -41,7 +41,7 @@ func TestAccNutanixDirectoryServicesV2Datasource_WithFilter(t *testing.T) { resource.TestCheckResourceAttr(datasourceNameDirectoryServices, "directory_services.0.name", testVars.Iam.DirectoryServices.Name), resource.TestCheckResourceAttr(datasourceNameDirectoryServices, "directory_services.0.domain_name", testVars.Iam.DirectoryServices.DomainName), resource.TestCheckResourceAttr(datasourceNameDirectoryServices, "directory_services.0.directory_type", "ACTIVE_DIRECTORY"), - resource.TestCheckResourceAttr(datasourceNameDirectoryServices, "directory_services.0.url", testVars.Iam.DirectoryServices.Url), + resource.TestCheckResourceAttr(datasourceNameDirectoryServices, "directory_services.0.url", testVars.Iam.DirectoryServices.URL), resource.TestCheckResourceAttr(datasourceNameDirectoryServices, "directory_services.0.service_account.0.username", testVars.Iam.DirectoryServices.ServiceAccount.Username), resource.TestCheckResourceAttrSet(datasourceNameDirectoryServices, "directory_services.0.service_account.0.password"), resource.TestCheckResourceAttr(datasourceNameDirectoryServices, "directory_services.0.white_listed_groups.0", testVars.Iam.DirectoryServices.WhiteListedGroups[0]), diff --git a/nutanix/services/iamv2/data_source_nutanix_user_group_v2_test.go b/nutanix/services/iamv2/data_source_nutanix_user_group_v2_test.go index 402fde798..b855fcb34 100644 --- a/nutanix/services/iamv2/data_source_nutanix_user_group_v2_test.go +++ b/nutanix/services/iamv2/data_source_nutanix_user_group_v2_test.go @@ -20,7 +20,7 @@ func TestAccNutanixUserGroupsV2Datasource_GetUserGroupByExrId(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(datasourceNameUserGroup, "distinguished_name", testVars.Iam.UserGroups.DistinguishedName), resource.TestCheckResourceAttr(datasourceNameUserGroup, "name", testVars.Iam.UserGroups.Name), - resource.TestCheckResourceAttr(datasourceNameUserGroup, "idp_id", testVars.Iam.Users.DirectoryServiceId), + resource.TestCheckResourceAttr(datasourceNameUserGroup, "idp_id", testVars.Iam.Users.DirectoryServiceID), resource.TestCheckResourceAttr(datasourceNameUserGroup, "group_type", "LDAP"), ), }, diff --git a/nutanix/services/iamv2/data_source_nutanix_user_groups_v2_test.go b/nutanix/services/iamv2/data_source_nutanix_user_groups_v2_test.go index 0f8cc0881..a302c3bea 100644 --- a/nutanix/services/iamv2/data_source_nutanix_user_groups_v2_test.go +++ b/nutanix/services/iamv2/data_source_nutanix_user_groups_v2_test.go @@ -38,7 +38,7 @@ func TestAccNutanixUserGroupsV2Datasource_WithFilter(t *testing.T) { resource.TestCheckResourceAttr(datasourceNameUserGroups, "user_groups.#", "1"), resource.TestCheckResourceAttr(datasourceNameUserGroups, "user_groups.0.distinguished_name", testVars.Iam.UserGroups.DistinguishedName), resource.TestCheckResourceAttr(datasourceNameUserGroups, "user_groups.0.name", testVars.Iam.UserGroups.Name), - resource.TestCheckResourceAttr(datasourceNameUserGroups, "user_groups.0.idp_id", testVars.Iam.Users.DirectoryServiceId), + resource.TestCheckResourceAttr(datasourceNameUserGroups, "user_groups.0.idp_id", testVars.Iam.Users.DirectoryServiceID), resource.TestCheckResourceAttr(datasourceNameUserGroups, "user_groups.0.group_type", "LDAP"), ), }, diff --git a/nutanix/services/iamv2/datasource_nutanix_user_v2_test.go b/nutanix/services/iamv2/datasource_nutanix_user_v2_test.go index 358fa1566..fa21089b5 100644 --- a/nutanix/services/iamv2/datasource_nutanix_user_v2_test.go +++ b/nutanix/services/iamv2/datasource_nutanix_user_v2_test.go @@ -26,7 +26,7 @@ func TestAccNutanixUserV2Datasource_Basic(t *testing.T) { resource.TestCheckResourceAttr(datasourceNameUser, "first_name", "first-name-"+name), resource.TestCheckResourceAttr(datasourceNameUser, "middle_initial", "middle-initial-"+name), resource.TestCheckResourceAttr(datasourceNameUser, "last_name", "last-name-"+name), - resource.TestCheckResourceAttr(datasourceNameUser, "email_id", testVars.Iam.Users.EmailId), + resource.TestCheckResourceAttr(datasourceNameUser, "email_id", testVars.Iam.Users.EmailID), resource.TestCheckResourceAttr(datasourceNameUser, "locale", testVars.Iam.Users.Locale), resource.TestCheckResourceAttr(datasourceNameUser, "region", testVars.Iam.Users.Region), resource.TestCheckResourceAttr(datasourceNameUser, "display_name", "display-name-"+name), diff --git a/nutanix/services/iamv2/main_test.go b/nutanix/services/iamv2/main_test.go index d386dd63c..455586bb2 100644 --- a/nutanix/services/iamv2/main_test.go +++ b/nutanix/services/iamv2/main_test.go @@ -15,10 +15,10 @@ type TestConfig struct { } `json:"roles"` Users struct { Name string `json:"name"` - IdpId string `json:"idp_id"` - DirectoryServiceId string `json:"directory_service_id"` + IdpID string `json:"idp_id"` + DirectoryServiceID string `json:"directory_service_id"` DirectoryServiceUsername string `json:"directory_service_username"` - EmailId string `json:"email_id"` + EmailID string `json:"email_id"` Locale string `json:"locale"` Region string `json:"region"` Password string `json:"password"` @@ -39,16 +39,16 @@ type TestConfig struct { } `json:"auth_policies"` // Directory Services config IdentityProviders struct { - IdpMetadataUrl string `json:"idp_metadata_url"` + IdpMetadataURL string `json:"idp_metadata_url"` IdpMetadata struct { - EntityId string `json:"entity_id"` - LoginUrl string `json:"login_url"` - LogoutUrl string `json:"logout_url"` - ErrorUrl string `json:"error_url"` + EntityID string `json:"entity_id"` + LoginURL string `json:"login_url"` + LogoutURL string `json:"logout_url"` + ErrorURL string `json:"error_url"` Certificate string `json:"certificate"` - NameIdPolicyFormat string `json:"name_id_policy_format"` + NameIDPolicyFormat string `json:"name_id_policy_format"` } `json:"idp_metadata"` - IdpMetadataXml string `json:"idp_metadata_xml"` + IdpMetadataXML string `json:"idp_metadata_xml"` Name string `json:"name"` UsernameAttribute string `json:"username_attr"` EmailAttribute string `json:"email_attr"` @@ -61,7 +61,7 @@ type TestConfig struct { // Directory Services config DirectoryServices struct { Name string `json:"name"` - Url string `json:"url"` + URL string `json:"url"` SecondaryUrls []string `json:"secondary_urls"` DomainName string `json:"domain_name"` ServiceAccount struct { diff --git a/nutanix/services/iamv2/resource_nutanix_authorization_policies_v2_test.go b/nutanix/services/iamv2/resource_nutanix_authorization_policies_v2_test.go index 553fc36fd..a88865640 100644 --- a/nutanix/services/iamv2/resource_nutanix_authorization_policies_v2_test.go +++ b/nutanix/services/iamv2/resource_nutanix_authorization_policies_v2_test.go @@ -2,7 +2,6 @@ package iamv2_test import ( "fmt" - "os" "regexp" "strconv" "testing" @@ -19,7 +18,7 @@ func TestAccNutanixAuthorizationPolicyV2Resource_CreateACP(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAuthorizationPolicyResourceConfig(filepath), + Config: testAuthorizationPolicyResourceConfig(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceNameAuthorizationPolicy, "ext_id"), resource.TestCheckResourceAttr(resourceNameAuthorizationPolicy, "display_name", testVars.Iam.AuthPolicies.DisplayName), @@ -34,7 +33,7 @@ func TestAccNutanixAuthorizationPolicyV2Resource_CreateACP(t *testing.T) { }, // test update ac { - Config: testAuthorizationPolicyResourceUpdateConfig(filepath), + Config: testAuthorizationPolicyResourceUpdateConfig(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceNameAuthorizationPolicy, "ext_id"), resource.TestCheckResourceAttr(resourceNameAuthorizationPolicy, "description", testVars.Iam.AuthPolicies.Description+"_updated"), @@ -52,14 +51,12 @@ func TestAccNutanixAuthorizationPolicyV2Resource_CreateACP(t *testing.T) { } func TestAccNutanixAuthorizationPolicyV2Resource_WithNoDisplayName(t *testing.T) { - path, _ := os.Getwd() - filepath := path + "/../../../test_config_v2.json" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAuthorizationPolicyResourceWithoutDisplayNameConfig(filepath), + Config: testAuthorizationPolicyResourceWithoutDisplayNameConfig(), ExpectError: regexp.MustCompile("Missing required argument"), }, }, @@ -67,14 +64,12 @@ func TestAccNutanixAuthorizationPolicyV2Resource_WithNoDisplayName(t *testing.T) } func TestAccNutanixAuthorizationPolicyV2Resource_WithNoIdentities(t *testing.T) { - path, _ := os.Getwd() - filepath := path + "/../../../test_config_v2.json" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAuthorizationPolicyResourceWithoutIdentitiesConfig(filepath), + Config: testAuthorizationPolicyResourceWithoutIdentitiesConfig(), ExpectError: regexp.MustCompile("Insufficient identities blocks"), }, }, @@ -82,14 +77,12 @@ func TestAccNutanixAuthorizationPolicyV2Resource_WithNoIdentities(t *testing.T) } func TestAccNutanixAuthorizationPolicyV2Resource_WithNoEntities(t *testing.T) { - path, _ := os.Getwd() - filepath := path + "/../../../test_config_v2.json" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAuthorizationPolicyResourceWithoutEntitiesConfig(filepath), + Config: testAuthorizationPolicyResourceWithoutEntitiesConfig(), ExpectError: regexp.MustCompile("Insufficient entities blocks"), }, }, @@ -97,21 +90,19 @@ func TestAccNutanixAuthorizationPolicyV2Resource_WithNoEntities(t *testing.T) { } func TestAccNutanixAuthorizationPolicyV2Resource_WithNoRole(t *testing.T) { - path, _ := os.Getwd() - filepath := path + "/../../../test_config_v2.json" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAuthorizationPolicyResourceWithoutRoleConfig(filepath), + Config: testAuthorizationPolicyResourceWithoutRoleConfig(), ExpectError: regexp.MustCompile("Missing required argument"), }, }, }) } -func testAuthorizationPolicyResourceConfig(filepath string) string { +func testAuthorizationPolicyResourceConfig() string { return fmt.Sprintf(` locals{ @@ -155,7 +146,7 @@ func testAuthorizationPolicyResourceConfig(filepath string) string { }`, filepath) } -func testAuthorizationPolicyResourceUpdateConfig(filepath string) string { +func testAuthorizationPolicyResourceUpdateConfig() string { return fmt.Sprintf(` locals{ @@ -199,7 +190,7 @@ func testAuthorizationPolicyResourceUpdateConfig(filepath string) string { }`, filepath) } -func testAuthorizationPolicyResourceWithoutDisplayNameConfig(filepath string) string { +func testAuthorizationPolicyResourceWithoutDisplayNameConfig() string { return fmt.Sprintf(` locals{ @@ -224,7 +215,7 @@ func testAuthorizationPolicyResourceWithoutDisplayNameConfig(filepath string) st }`, filepath) } -func testAuthorizationPolicyResourceWithoutIdentitiesConfig(filepath string) string { +func testAuthorizationPolicyResourceWithoutIdentitiesConfig() string { return fmt.Sprintf(` locals{ @@ -247,7 +238,7 @@ func testAuthorizationPolicyResourceWithoutIdentitiesConfig(filepath string) str }`, filepath) } -func testAuthorizationPolicyResourceWithoutEntitiesConfig(filepath string) string { +func testAuthorizationPolicyResourceWithoutEntitiesConfig() string { return fmt.Sprintf(` locals{ @@ -267,7 +258,7 @@ func testAuthorizationPolicyResourceWithoutEntitiesConfig(filepath string) strin }`, filepath) } -func testAuthorizationPolicyResourceWithoutRoleConfig(filepath string) string { +func testAuthorizationPolicyResourceWithoutRoleConfig() string { return fmt.Sprintf(` locals{ diff --git a/nutanix/services/iamv2/resource_nutanix_directory_services_v2_test.go b/nutanix/services/iamv2/resource_nutanix_directory_services_v2_test.go index e6189be27..869d67868 100644 --- a/nutanix/services/iamv2/resource_nutanix_directory_services_v2_test.go +++ b/nutanix/services/iamv2/resource_nutanix_directory_services_v2_test.go @@ -24,7 +24,7 @@ func TestAccNutanixDirectoryServicesV2Resource_CreateACTIVE_DIRECTORYService(t * resource.TestCheckResourceAttr(resourceNameDirectoryServices, "name", testVars.Iam.DirectoryServices.Name), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "domain_name", testVars.Iam.DirectoryServices.DomainName), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "directory_type", "ACTIVE_DIRECTORY"), - resource.TestCheckResourceAttr(resourceNameDirectoryServices, "url", testVars.Iam.DirectoryServices.Url), + resource.TestCheckResourceAttr(resourceNameDirectoryServices, "url", testVars.Iam.DirectoryServices.URL), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "service_account.0.username", testVars.Iam.DirectoryServices.ServiceAccount.Username), resource.TestCheckResourceAttrSet(resourceNameDirectoryServices, "service_account.0.password"), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "white_listed_groups.0", testVars.Iam.DirectoryServices.WhiteListedGroups[0]), @@ -37,7 +37,7 @@ func TestAccNutanixDirectoryServicesV2Resource_CreateACTIVE_DIRECTORYService(t * resource.TestCheckResourceAttr(resourceNameDirectoryServices, "name", testVars.Iam.DirectoryServices.Name), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "domain_name", testVars.Iam.DirectoryServices.DomainName), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "directory_type", "ACTIVE_DIRECTORY"), - resource.TestCheckResourceAttr(resourceNameDirectoryServices, "url", testVars.Iam.DirectoryServices.Url), + resource.TestCheckResourceAttr(resourceNameDirectoryServices, "url", testVars.Iam.DirectoryServices.URL), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "service_account.0.username", testVars.Iam.DirectoryServices.ServiceAccount.Username), resource.TestCheckResourceAttrSet(resourceNameDirectoryServices, "service_account.0.password"), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "white_listed_groups.0", testVars.Iam.DirectoryServices.WhiteListedGroups[1]), @@ -63,7 +63,7 @@ func TestAccNutanixDirectoryServicesV2Resource_CreateOpenLDAPService(t *testing. resource.TestCheckResourceAttr(resourceNameDirectoryServices, "name", name), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "domain_name", testVars.Iam.DirectoryServices.DomainName), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "directory_type", "ACTIVE_DIRECTORY"), - resource.TestCheckResourceAttr(resourceNameDirectoryServices, "url", testVars.Iam.DirectoryServices.Url), + resource.TestCheckResourceAttr(resourceNameDirectoryServices, "url", testVars.Iam.DirectoryServices.URL), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "service_account.0.username", testVars.Iam.DirectoryServices.ServiceAccount.Username), resource.TestCheckResourceAttrSet(resourceNameDirectoryServices, "service_account.0.password"), ), @@ -84,7 +84,7 @@ func TestAccNutanixDirectoryServicesV2Resource_CreateACTIVE_DIRECTORYAlreadyExis resource.TestCheckResourceAttr(resourceNameDirectoryServices, "name", testVars.Iam.DirectoryServices.Name), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "domain_name", testVars.Iam.DirectoryServices.DomainName), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "directory_type", "ACTIVE_DIRECTORY"), - resource.TestCheckResourceAttr(resourceNameDirectoryServices, "url", testVars.Iam.DirectoryServices.Url), + resource.TestCheckResourceAttr(resourceNameDirectoryServices, "url", testVars.Iam.DirectoryServices.URL), resource.TestCheckResourceAttr(resourceNameDirectoryServices, "service_account.0.username", testVars.Iam.DirectoryServices.ServiceAccount.Username), resource.TestCheckResourceAttrSet(resourceNameDirectoryServices, "service_account.0.password"), ), @@ -116,7 +116,7 @@ func TestAccNutanixDirectoryServicesV2Resource_WithNoUrl(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testDirectoryServicesResourceWithoutUrlConfig(filepath), + Config: testDirectoryServicesResourceWithoutURLConfig(filepath), ExpectError: regexp.MustCompile("Missing required argument"), }, }, @@ -302,7 +302,7 @@ func testDirectoryServicesResourceWithoutNameConfig(filepath string) string { }`, filepath) } -func testDirectoryServicesResourceWithoutUrlConfig(filepath string) string { +func testDirectoryServicesResourceWithoutURLConfig(filepath string) string { return fmt.Sprintf(` locals{ diff --git a/nutanix/services/iamv2/resource_nutanix_saml_idp_v2_test.go b/nutanix/services/iamv2/resource_nutanix_saml_idp_v2_test.go index 508f15fc6..8543174b0 100644 --- a/nutanix/services/iamv2/resource_nutanix_saml_idp_v2_test.go +++ b/nutanix/services/iamv2/resource_nutanix_saml_idp_v2_test.go @@ -53,7 +53,7 @@ func TestAccNutanixIdentityProvidersV2ResourceWithNoEntityId(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testIdentityProvidersResourceWithoutEntityId(filepath), + Config: testIdentityProvidersResourceWithoutEntityID(filepath), ExpectError: regexp.MustCompile("Missing required argument"), }, }, @@ -104,7 +104,7 @@ func testIdentityProvidersResourceWithoutName(filepath string) string { }`, filepath) } -func testIdentityProvidersResourceWithoutEntityId(filepath string) string { +func testIdentityProvidersResourceWithoutEntityID(filepath string) string { return fmt.Sprintf(` locals{ diff --git a/nutanix/services/iamv2/resource_nutanix_user_groups_v2_test.go b/nutanix/services/iamv2/resource_nutanix_user_groups_v2_test.go index 40dbca988..06394da9e 100644 --- a/nutanix/services/iamv2/resource_nutanix_user_groups_v2_test.go +++ b/nutanix/services/iamv2/resource_nutanix_user_groups_v2_test.go @@ -20,7 +20,7 @@ func TestAccNutanixUserGroupsV2Resource_LDAPUserGroup(t *testing.T) { Config: testLDAPUserGroupsResourceConfig(filepath), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceNameUserGroups, "name", testVars.Iam.UserGroups.Name), - resource.TestCheckResourceAttr(resourceNameUserGroups, "idp_id", testVars.Iam.Users.DirectoryServiceId), + resource.TestCheckResourceAttr(resourceNameUserGroups, "idp_id", testVars.Iam.Users.DirectoryServiceID), resource.TestCheckResourceAttr(resourceNameUserGroups, "group_type", "LDAP"), resource.TestCheckResourceAttr(resourceNameUserGroups, "distinguished_name", testVars.Iam.UserGroups.DistinguishedName), ), @@ -42,7 +42,7 @@ func TestAccNutanixUserGroupsV2Resource_SAMLUserGroup(t *testing.T) { Config: testSAMLUserGroupsResourceConfig(filepath), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceNameUserGroups, "name", testVars.Iam.UserGroups.SAMLName), - resource.TestCheckResourceAttr(resourceNameUserGroups, "idp_id", testVars.Iam.Users.IdpId), + resource.TestCheckResourceAttr(resourceNameUserGroups, "idp_id", testVars.Iam.Users.IdpID), resource.TestCheckResourceAttr(resourceNameUserGroups, "group_type", "SAML"), ), }, @@ -73,7 +73,7 @@ func TestAccNutanixUserGroupsV2Resource_WithNoIdpId(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testUserGroupsResourceWithoutIdpIdConfig(filepath), + Config: testUserGroupsResourceWithoutIdpIDConfig(filepath), ExpectError: regexp.MustCompile("Missing required argument"), }, }, @@ -155,7 +155,7 @@ func testUserGroupsResourceWithoutGroupTypeConfig(filepath string) string { }`, filepath) } -func testUserGroupsResourceWithoutIdpIdConfig(filepath string) string { +func testUserGroupsResourceWithoutIdpIDConfig(filepath string) string { return fmt.Sprintf(` locals{ diff --git a/nutanix/services/iamv2/resource_nutanix_users_v2_test.go b/nutanix/services/iamv2/resource_nutanix_users_v2_test.go index cc0c96b74..29003eaf1 100644 --- a/nutanix/services/iamv2/resource_nutanix_users_v2_test.go +++ b/nutanix/services/iamv2/resource_nutanix_users_v2_test.go @@ -31,7 +31,7 @@ func TestAccNutanixUsersV2Resource_LocalActiveUser(t *testing.T) { resource.TestCheckResourceAttr(resourceNameUsers, "first_name", "first-name-"+name), resource.TestCheckResourceAttr(resourceNameUsers, "middle_initial", "middle-initial-"+name), resource.TestCheckResourceAttr(resourceNameUsers, "last_name", "last-name-"+name), - resource.TestCheckResourceAttr(resourceNameUsers, "email_id", testVars.Iam.Users.EmailId), + resource.TestCheckResourceAttr(resourceNameUsers, "email_id", testVars.Iam.Users.EmailID), resource.TestCheckResourceAttr(resourceNameUsers, "status", "ACTIVE"), ), }, @@ -46,7 +46,7 @@ func TestAccNutanixUsersV2Resource_LocalActiveUser(t *testing.T) { resource.TestCheckResourceAttr(resourceNameUsers, "first_name", fmt.Sprintf("%s_updated", "first-name-"+name)), resource.TestCheckResourceAttr(resourceNameUsers, "middle_initial", fmt.Sprintf("%s_updated", "middle-initial-"+name)), resource.TestCheckResourceAttr(resourceNameUsers, "last_name", fmt.Sprintf("%s_updated", "last-name-"+name)), - resource.TestCheckResourceAttr(resourceNameUsers, "email_id", fmt.Sprintf("updated_%s", testVars.Iam.Users.EmailId)), + resource.TestCheckResourceAttr(resourceNameUsers, "email_id", fmt.Sprintf("updated_%s", testVars.Iam.Users.EmailID)), ), }, }, @@ -121,7 +121,7 @@ func TestAccNutanixUsersV2Resource_SAMLUser(t *testing.T) { resource.TestCheckResourceAttrSet(resourceNameUsers, "ext_id"), resource.TestCheckResourceAttr(resourceNameUsers, "username", name), resource.TestCheckResourceAttr(resourceNameUsers, "user_type", "SAML"), - resource.TestCheckResourceAttr(resourceNameUsers, "idp_id", testVars.Iam.Users.IdpId), + resource.TestCheckResourceAttr(resourceNameUsers, "idp_id", testVars.Iam.Users.IdpID), ), }, }, @@ -140,7 +140,7 @@ func TestAccNutanixUsersV2Resource_LDAPUser(t *testing.T) { resource.TestCheckResourceAttrSet(resourceNameUsers, "ext_id"), resource.TestCheckResourceAttr(resourceNameUsers, "username", testVars.Iam.Users.Name), resource.TestCheckResourceAttr(resourceNameUsers, "user_type", "LDAP"), - resource.TestCheckResourceAttr(resourceNameUsers, "idp_id", testVars.Iam.Users.DirectoryServiceId), + resource.TestCheckResourceAttr(resourceNameUsers, "idp_id", testVars.Iam.Users.DirectoryServiceID), ), }, }, diff --git a/nutanix/services/networkingv2/main_test.go b/nutanix/services/networkingv2/main_test.go index 82f1b6138..0c604c089 100644 --- a/nutanix/services/networkingv2/main_test.go +++ b/nutanix/services/networkingv2/main_test.go @@ -10,7 +10,7 @@ import ( type TestConfig struct { Networking struct { FloatingIP struct { - VmNicReference string `json:"vm_nic_reference"` + VMNicReference string `json:"vm_nic_reference"` } `json:"floating_ip"` Subnets struct { ProjectID string `json:"project_id"` diff --git a/nutanix/services/networkingv2/resource_nutanix_vpcs_v2_test.go b/nutanix/services/networkingv2/resource_nutanix_vpcs_v2_test.go index 0fb38a794..c3af58903 100644 --- a/nutanix/services/networkingv2/resource_nutanix_vpcs_v2_test.go +++ b/nutanix/services/networkingv2/resource_nutanix_vpcs_v2_test.go @@ -13,7 +13,7 @@ const resourceNameVpc = "nutanix_vpc_v2.test" func TestAccNutanixVpcV2Resource_Basic(t *testing.T) { r := acctest.RandInt() - vlanId := acctest.RandIntRange(1, 999) + vlanID := acctest.RandIntRange(1, 999) name := fmt.Sprintf("tf-test-vpc-%d", r) desc := "test vpc description" updatedName := fmt.Sprintf("updated-vpc-%d", r) @@ -23,7 +23,7 @@ func TestAccNutanixVpcV2Resource_Basic(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVpcConfig(name, desc, vlanId), + Config: testVpcConfig(name, desc, vlanID), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceNameVpc, "name", name), resource.TestCheckResourceAttr(resourceNameVpc, "description", desc), @@ -33,7 +33,7 @@ func TestAccNutanixVpcV2Resource_Basic(t *testing.T) { ), }, { - Config: testVpcConfig(updatedName, updatedDesc, vlanId), + Config: testVpcConfig(updatedName, updatedDesc, vlanID), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceNameVpc, "name", updatedName), resource.TestCheckResourceAttr(resourceNameVpc, "description", updatedDesc), @@ -49,14 +49,14 @@ func TestAccNutanixVpcV2Resource_Basic(t *testing.T) { func TestAccNutanixVpcV2Resource_WithExternallyRoutablePrefixes(t *testing.T) { r := acctest.RandInt() name := fmt.Sprintf("tf-test-vpc-%d", r) - vlanId := acctest.RandIntRange(1, 999) + vlanID := acctest.RandIntRange(1, 999) desc := "test vpc description" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVpcConfigWithExtRoutablePrefix(name, desc, vlanId), + Config: testVpcConfigWithExtRoutablePrefix(name, desc, vlanID), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceNameVpc, "name", name), resource.TestCheckResourceAttr(resourceNameVpc, "description", desc), @@ -72,14 +72,14 @@ func TestAccNutanixVpcV2Resource_WithExternallyRoutablePrefixes(t *testing.T) { func TestAccNutanixVpcV2Resource_WithDHCP(t *testing.T) { r := acctest.RandInt() name := fmt.Sprintf("tf-test-vpc-%d", r) - vlanId := acctest.RandIntRange(1, 999) + vlanID := acctest.RandIntRange(1, 999) desc := "test vpc description" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVpcConfigWithDHCP(name, desc, vlanId), + Config: testVpcConfigWithDHCP(name, desc, vlanID), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceNameVpc, "name", name), resource.TestCheckResourceAttr(resourceNameVpc, "description", desc), @@ -96,14 +96,14 @@ func TestAccNutanixVpcV2Resource_WithDHCP(t *testing.T) { func TestAccNutanixVpcV2Resource_WithTransitType(t *testing.T) { r := acctest.RandInt() name := fmt.Sprintf("tf-test-vpc-%d", r) - vlanId := acctest.RandIntRange(1, 999) + vlanID := acctest.RandIntRange(1, 999) desc := "test vpc description" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testVpcConfigWithTransitType(name, desc, vlanId), + Config: testVpcConfigWithTransitType(name, desc, vlanID), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceNameVpc, "name", name), resource.TestCheckResourceAttr(resourceNameVpc, "description", desc), @@ -118,7 +118,7 @@ func TestAccNutanixVpcV2Resource_WithTransitType(t *testing.T) { }) } -func testVpcConfig(name, desc string, vlanId int) string { +func testVpcConfig(name, desc string, vlanID int) string { return fmt.Sprintf(` data "nutanix_clusters" "clusters" {} @@ -165,10 +165,10 @@ func testVpcConfig(name, desc string, vlanId int) string { } depends_on = [nutanix_subnet_v2.test] } -`, name, desc, vlanId) +`, name, desc, vlanID) } -func testVpcConfigWithExtRoutablePrefix(name, desc string, vlanId int) string { +func testVpcConfigWithExtRoutablePrefix(name, desc string, vlanID int) string { return fmt.Sprintf(` data "nutanix_clusters" "clusters" {} @@ -236,10 +236,10 @@ func testVpcConfigWithExtRoutablePrefix(name, desc string, vlanId int) string { } depends_on = [nutanix_subnet_v2.test] } -`, name, desc, vlanId) +`, name, desc, vlanID) } -func testVpcConfigWithDHCP(name, desc string, vlanId int) string { +func testVpcConfigWithDHCP(name, desc string, vlanID int) string { return fmt.Sprintf(` data "nutanix_clusters" "clusters" {} @@ -309,10 +309,10 @@ func testVpcConfigWithDHCP(name, desc string, vlanId int) string { depends_on = [nutanix_subnet_v2.test] } -`, name, desc, vlanId) +`, name, desc, vlanID) } -func testVpcConfigWithTransitType(name, desc string, vlanId int) string { +func testVpcConfigWithTransitType(name, desc string, vlanID int) string { return fmt.Sprintf(` data "nutanix_clusters" "clusters" {} @@ -360,5 +360,5 @@ func testVpcConfigWithTransitType(name, desc string, vlanId int) string { vpc_type = "TRANSIT" depends_on = [nutanix_subnet_v2.test] } -`, name, desc, vlanId) +`, name, desc, vlanID) } diff --git a/nutanix/services/storagecontainersv2/data_source_nutanix_storage_container_stats_test.go b/nutanix/services/storagecontainersv2/data_source_nutanix_storage_container_stats_test.go index 55e54b975..100356035 100644 --- a/nutanix/services/storagecontainersv2/data_source_nutanix_storage_container_stats_test.go +++ b/nutanix/services/storagecontainersv2/data_source_nutanix_storage_container_stats_test.go @@ -166,7 +166,7 @@ func TestAccNutanixStorageStatsInfoV2Datasource_MissingRequiredArgs(t *testing.T Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testStorageStatsDatasourceV2MissingExtId(startTimeFormatted, endTimeFormatted, "SUM"), + Config: testStorageStatsDatasourceV2MissingExtID(startTimeFormatted, endTimeFormatted, "SUM"), ExpectError: regexp.MustCompile("Missing required argument"), }, { @@ -293,7 +293,7 @@ func testStorageStatsDatasourceV2InvalidStatType(startTime, endTime, statType st `, startTime, endTime, statType) } -func testStorageStatsDatasourceV2MissingExtId(startTime, endTime, statType string) string { +func testStorageStatsDatasourceV2MissingExtID(startTime, endTime, statType string) string { return fmt.Sprintf(` data "nutanix_storage_container_stats_info_v2" "test" { diff --git a/nutanix/services/storagecontainersv2/data_source_nutanix_storge_container_test.go b/nutanix/services/storagecontainersv2/data_source_nutanix_storge_container_test.go index 1922b2295..63262cfac 100644 --- a/nutanix/services/storagecontainersv2/data_source_nutanix_storge_container_test.go +++ b/nutanix/services/storagecontainersv2/data_source_nutanix_storge_container_test.go @@ -11,7 +11,7 @@ import ( acc "github.com/terraform-providers/terraform-provider-nutanix/nutanix/acctest" ) -const datasourceName_StorageContainer = "data.nutanix_storage_container_v2.test" +const datasourceNameStorageContainer = "data.nutanix_storage_container_v2.test" func TestAccNutanixStorageContainerV2Datasource_Basic(t *testing.T) { r := acctest.RandInt() @@ -26,13 +26,13 @@ func TestAccNutanixStorageContainerV2Datasource_Basic(t *testing.T) { { Config: testStorageContainerV4Config(filepath, name), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet(datasourceName_StorageContainer, "container_ext_id"), - resource.TestCheckResourceAttr(datasourceName_StorageContainer, "name", name), - resource.TestCheckResourceAttr(datasourceName_StorageContainer, "logical_advertised_capacity_bytes", strconv.Itoa(testVars.StorageContainer.LogicalAdvertisedCapacityBytes)), - resource.TestCheckResourceAttr(datasourceName_StorageContainer, "logical_explicit_reserved_capacity_bytes", strconv.Itoa(testVars.StorageContainer.LogicalExplicitReservedCapacityBytes)), - resource.TestCheckResourceAttr(datasourceName_StorageContainer, "replication_factor", strconv.Itoa(testVars.StorageContainer.ReplicationFactor)), - resource.TestCheckResourceAttr(datasourceName_StorageContainer, "nfs_whitelist_addresses.0.ipv4.0.value", testVars.StorageContainer.NfsWhitelistAddresses.Ipv4.Value), - resource.TestCheckResourceAttr(datasourceName_StorageContainer, "nfs_whitelist_addresses.0.ipv4.0.prefix_length", strconv.Itoa(testVars.StorageContainer.NfsWhitelistAddresses.Ipv4.PrefixLength)), + resource.TestCheckResourceAttrSet(datasourceNameStorageContainer, "container_ext_id"), + resource.TestCheckResourceAttr(datasourceNameStorageContainer, "name", name), + resource.TestCheckResourceAttr(datasourceNameStorageContainer, "logical_advertised_capacity_bytes", strconv.Itoa(testVars.StorageContainer.LogicalAdvertisedCapacityBytes)), + resource.TestCheckResourceAttr(datasourceNameStorageContainer, "logical_explicit_reserved_capacity_bytes", strconv.Itoa(testVars.StorageContainer.LogicalExplicitReservedCapacityBytes)), + resource.TestCheckResourceAttr(datasourceNameStorageContainer, "replication_factor", strconv.Itoa(testVars.StorageContainer.ReplicationFactor)), + resource.TestCheckResourceAttr(datasourceNameStorageContainer, "nfs_whitelist_addresses.0.ipv4.0.value", testVars.StorageContainer.NfsWhitelistAddresses.Ipv4.Value), + resource.TestCheckResourceAttr(datasourceNameStorageContainer, "nfs_whitelist_addresses.0.ipv4.0.prefix_length", strconv.Itoa(testVars.StorageContainer.NfsWhitelistAddresses.Ipv4.PrefixLength)), ), }, }, diff --git a/nutanix/services/storagecontainersv2/resource_nutanix_storge_containers_test.go b/nutanix/services/storagecontainersv2/resource_nutanix_storge_containers_test.go index e03075e08..4a21e802a 100644 --- a/nutanix/services/storagecontainersv2/resource_nutanix_storge_containers_test.go +++ b/nutanix/services/storagecontainersv2/resource_nutanix_storge_containers_test.go @@ -61,7 +61,7 @@ func TestAccNutanixStorageContainersV2Resource_WithNoClusterExtId(t *testing.T) Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testStorageContainersResourceWithoutClusterExtIdConfig(filepath), + Config: testStorageContainersResourceWithoutClusterExtIDConfig(filepath), ExpectError: regexp.MustCompile("Missing required argument"), }, }, @@ -193,7 +193,7 @@ func testStorageContainersResourceWithoutNameConfig(filepath string) string { }`, filepath) } -func testStorageContainersResourceWithoutClusterExtIdConfig(filepath string) string { +func testStorageContainersResourceWithoutClusterExtIDConfig(filepath string) string { return fmt.Sprintf(` data "nutanix_clusters_v2" "clusters" {} diff --git a/nutanix/services/vmmv2/data_source_nutanix_virtual_machine_v2.go b/nutanix/services/vmmv2/data_source_nutanix_virtual_machine_v2.go index b1c511fa4..98ebc6e13 100644 --- a/nutanix/services/vmmv2/data_source_nutanix_virtual_machine_v2.go +++ b/nutanix/services/vmmv2/data_source_nutanix_virtual_machine_v2.go @@ -1558,7 +1558,6 @@ func flattenGuestCustomizationParams(gst *config.GuestCustomizationParams) []map func flattenOneOfGuestCustomizationParamsConfig(cfg *config.OneOfGuestCustomizationParamsConfig) []map[string]interface{} { if cfg != nil { - cfgList := make([]map[string]interface{}, 0) sysCfg := make(map[string]interface{}) sysCfgList := make([]map[string]interface{}, 0) cloudCfg := make(map[string]interface{}) @@ -1581,26 +1580,22 @@ func flattenOneOfGuestCustomizationParamsConfig(cfg *config.OneOfGuestCustomizat sysCfgList = append(sysCfgList, sysCfg) - cfgList = sysCfgList - } else { - cloudInitObj := make(map[string]interface{}) - cloudInitObjList := make([]map[string]interface{}, 0) - cloudObj := cfg.GetValue().(config.CloudInit) + return sysCfgList + } + cloudInitObj := make(map[string]interface{}) + cloudInitObjList := make([]map[string]interface{}, 0) + cloudObj := cfg.GetValue().(config.CloudInit) - cloudInitObj["datasource_type"] = flattenCloudInitDataSourceType(cloudObj.DatasourceType) - cloudInitObj["metadata"] = cloudObj.Metadata - cloudInitObj["cloud_init_script"] = flattenOneOfCloudInitCloudInitScript(cloudObj.CloudInitScript) + cloudInitObj["datasource_type"] = flattenCloudInitDataSourceType(cloudObj.DatasourceType) + cloudInitObj["metadata"] = cloudObj.Metadata + cloudInitObj["cloud_init_script"] = flattenOneOfCloudInitCloudInitScript(cloudObj.CloudInitScript) - cloudInitObjList = append(cloudInitObjList, cloudInitObj) - cloudCfg["cloud_init"] = cloudInitObjList + cloudInitObjList = append(cloudInitObjList, cloudInitObj) + cloudCfg["cloud_init"] = cloudInitObjList - cloudCfgList = append(cloudCfgList, cloudCfg) + cloudCfgList = append(cloudCfgList, cloudCfg) - cfgList = cloudCfgList - } - aJSON, _ := json.Marshal(cfgList) - log.Printf("[DEBUG] flattenOneOfGuestCustomizationParamsConfig: %s", string(aJSON)) - return cfgList + return cloudCfgList } return nil } @@ -1620,7 +1615,6 @@ func flattenInstallType(pr *config.InstallType) string { func flattenOneOfSysprepSysprepScript(cfg *config.OneOfSysprepSysprepScript) []map[string]interface{} { if cfg != nil { - cfgList := make([]map[string]interface{}, 0) unattendCfg := make(map[string]interface{}) unattendCfgList := make([]map[string]interface{}, 0) customKeyValCfg := make(map[string]interface{}) @@ -1639,23 +1633,19 @@ func flattenOneOfSysprepSysprepScript(cfg *config.OneOfSysprepSysprepScript) []m unattendCfgList = append(unattendCfgList, unattendCfg) - cfgList = unattendCfgList - } else { - customObj := make(map[string]interface{}) - customObjList := make([]map[string]interface{}, 0) - customCfg := cfg.GetValue().(config.CustomKeyValues) + return unattendCfgList + } + customObj := make(map[string]interface{}) + customObjList := make([]map[string]interface{}, 0) + customCfg := cfg.GetValue().(config.CustomKeyValues) - customObj["key_value_pairs"] = flattenCustomKVPair(customCfg.KeyValuePairs) + customObj["key_value_pairs"] = flattenCustomKVPair(customCfg.KeyValuePairs) - customObjList = append(customObjList, customObj) - customKeyValCfg["custom_key_values"] = customObjList + customObjList = append(customObjList, customObj) + customKeyValCfg["custom_key_values"] = customObjList - customKeyValCfgList = append(customKeyValCfgList, customKeyValCfg) - cfgList = customKeyValCfgList - } - aJSON, _ := json.Marshal(cfgList) - log.Printf("[DEBUG] flattenOneOfSysprepSysprepScript: %s", string(aJSON)) - return cfgList + customKeyValCfgList = append(customKeyValCfgList, customKeyValCfg) + return customKeyValCfgList } return nil } @@ -1772,7 +1762,6 @@ func flattenNgtCapability(pr []config.NgtCapability) []interface{} { func flattenOneOfVMBootConfig(pr *config.OneOfVmBootConfig) []map[string]interface{} { if pr != nil { - bootCfg := make([]map[string]interface{}, 0) legacyBootCfg := make(map[string]interface{}) legacyBootCfgList := make([]map[string]interface{}, 0) uefiBootCfg := make(map[string]interface{}) @@ -1803,8 +1792,7 @@ func flattenOneOfVMBootConfig(pr *config.OneOfVmBootConfig) []map[string]interfa uefiBootCfg["uefi_boot"] = uefiObjList uefiBootCfgList = append(uefiBootCfgList, uefiBootCfg) - bootCfg = uefiBootCfgList - return bootCfg + return uefiBootCfgList } return nil } @@ -2009,7 +1997,6 @@ func flattenDataSource(ref *config.DataSource) []map[string]interface{} { func flattenOneOfDataSourceReference(pr *config.OneOfDataSourceReference) []map[string]interface{} { if pr != nil { - refList := make([]map[string]interface{}, 0) vmDiskRef := make(map[string]interface{}) vmDiskRefList := make([]map[string]interface{}, 0) imageRef := make(map[string]interface{}) @@ -2028,21 +2015,19 @@ func flattenOneOfDataSourceReference(pr *config.OneOfDataSourceReference) []map[ vmDiskRef["vm_disk_reference"] = vmDiskObjList vmDiskRefList = append(vmDiskRefList, vmDiskRef) - refList = vmDiskRefList - } else { - imageObj := make(map[string]interface{}) - imageObjList := make([]map[string]interface{}, 0) - imageVal := pr.GetValue().(config.ImageReference) + return vmDiskRefList + } + imageObj := make(map[string]interface{}) + imageObjList := make([]map[string]interface{}, 0) + imageVal := pr.GetValue().(config.ImageReference) - imageObj["image_ext_id"] = imageVal.ImageExtId + imageObj["image_ext_id"] = imageVal.ImageExtId - imageObjList = append(imageObjList, imageObj) - imageRef["image_reference"] = imageObjList - imageRefList = append(imageRefList, imageRef) + imageObjList = append(imageObjList, imageObj) + imageRef["image_reference"] = imageObjList + imageRefList = append(imageRefList, imageRef) - refList = imageRefList - } - return refList + return imageRefList } return nil } @@ -2091,6 +2076,7 @@ func flattenVtpmConfig(pr *config.VtpmConfig) []map[string]interface{} { vtpm["version"] = pr.Version } vtpmList = append(vtpmList, vtpm) + return vtpmList } return nil } diff --git a/nutanix/services/vmmv2/resource_nutanix_image_placement_v2.go b/nutanix/services/vmmv2/resource_nutanix_image_placement_v2.go index e1ddf71dd..e3eb10126 100644 --- a/nutanix/services/vmmv2/resource_nutanix_image_placement_v2.go +++ b/nutanix/services/vmmv2/resource_nutanix_image_placement_v2.go @@ -471,9 +471,10 @@ func expandEntityFilter(pr interface{}) *import7.Filter { // entity_filter.ObjectType_ = utils.StringPtr("vmm.v4.r0.b1.images.config.Filter") if ftype, ok := val["type"]; ok { + const two, three = 2, 3 subMap := map[string]interface{}{ - "CATEGORIES_MATCH_ALL": 2, - "CATEGORIES_MATCH_ANY": 3, + "CATEGORIES_MATCH_ALL": two, + "CATEGORIES_MATCH_ANY": three, } pVal := subMap[ftype.(string)] p := import7.FilterMatchType(pVal.(int)) diff --git a/nutanix/services/vmmv2/resource_nutanix_image_v2.go b/nutanix/services/vmmv2/resource_nutanix_image_v2.go index 17f746b28..7f2b855c3 100644 --- a/nutanix/services/vmmv2/resource_nutanix_image_v2.go +++ b/nutanix/services/vmmv2/resource_nutanix_image_v2.go @@ -207,9 +207,10 @@ func ResourceNutanixImageV4Create(ctx context.Context, d *schema.ResourceData, m body.Description = utils.StringPtr(desc.(string)) } if types, ok := d.GetOk("type"); ok { + const two, three = 2, 3 subMap := map[string]interface{}{ - "DISK_IMAGE": 2, - "ISO_IMAGE": 3, + "DISK_IMAGE": two, + "ISO_IMAGE": three, } pVal := subMap[types.(string)] p := import5.ImageType(pVal.(int)) diff --git a/nutanix/services/vmmv2/resource_nutanix_template_deploy_v2.go b/nutanix/services/vmmv2/resource_nutanix_template_deploy_v2.go index 66316c5ed..1ed3886ed 100644 --- a/nutanix/services/vmmv2/resource_nutanix_template_deploy_v2.go +++ b/nutanix/services/vmmv2/resource_nutanix_template_deploy_v2.go @@ -347,10 +347,7 @@ func expandVMConfigOverride(pr interface{}) map[string]import5.VmConfigOverride } cfg["0"] = vmConfig - - res := make(map[string]import5.VmConfigOverride) - res = cfg - return res + return cfg } return nil } @@ -679,7 +676,7 @@ func expandOneOfSysprepSysprepScript(pr interface{}) *config.OneOfSysprepSysprep cVal := cI[0].(map[string]interface{}) if keyval, ok := cVal["key_value_pairs"]; ok { - ckey.KeyValuePairs = expandKVPair(keyval.([]interface{})) + ckey.KeyValuePairs = expandTemplateKVPairs(keyval.([]interface{})) } scripts.SetValue(*ckey) } @@ -688,28 +685,6 @@ func expandOneOfSysprepSysprepScript(pr interface{}) *config.OneOfSysprepSysprep return nil } -func expandKVPair(pr []interface{}) []import4.KVPair { - if len(pr) > 0 { - pairs := make([]import4.KVPair, len(pr)) - - for k, v := range pr { - pair := import4.KVPair{} - val := v.(map[string]interface{}) - - if name, ok := val["name"]; ok { - pair.Name = utils.StringPtr(name.(string)) - } - // if value, ok := val["value"]; ok { - // pair.Value = utils.StringPtr(value.(string)) - // } - - pairs[k] = pair - } - return pairs - } - return nil -} - func expandOneOfCloudInitCloudInitScript(pr interface{}) *config.OneOfCloudInitCloudInitScript { if len(pr.([]interface{})) > 0 { prI := pr.([]interface{}) @@ -732,7 +707,7 @@ func expandOneOfCloudInitCloudInitScript(pr interface{}) *config.OneOfCloudInitC cVal := cI[0].(map[string]interface{}) if keyval, ok := cVal["key_value_pairs"]; ok { - ckey.KeyValuePairs = expandKVPair(keyval.([]interface{})) + ckey.KeyValuePairs = expandTemplateKVPairs(keyval.([]interface{})) } cloudInit.SetValue(*ckey) } diff --git a/nutanix/services/vmmv2/resource_nutanix_template_v2_test.go b/nutanix/services/vmmv2/resource_nutanix_template_v2_test.go index 3c340770f..3ddb8bf7a 100644 --- a/nutanix/services/vmmv2/resource_nutanix_template_v2_test.go +++ b/nutanix/services/vmmv2/resource_nutanix_template_v2_test.go @@ -72,7 +72,7 @@ func TestAccNutanixTemplateV2Resource_Basic(t *testing.T) { }, //update the template name, description and vm config USING template_vm_reference { - Config: testTemplateV2UpdateWithTempVmRefConfig(name, desc, templateName+"-updated-2", templateDesc+"-updated-2"), + Config: testTemplateV2UpdateWithTempVMRefConfig(name, desc, templateName+"-updated-2", templateDesc+"-updated-2"), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceNameTemplate, "template_name", templateName+"-updated-2"), resource.TestCheckResourceAttr(resourceNameTemplate, "template_description", templateDesc+"-updated-2"), @@ -340,7 +340,7 @@ func testTemplateV2UpdateWithTempVersionRefConfig(name, desc, tempName, tempDesc `, name, desc, tempName, tempDesc) } -func testTemplateV2UpdateWithTempVmRefConfig(name, desc, tempName, tempDesc string) string { +func testTemplateV2UpdateWithTempVMRefConfig(name, desc, tempName, tempDesc string) string { return fmt.Sprintf(` data "nutanix_clusters_v2" "clusters" {} diff --git a/nutanix/services/vmmv2/resource_nutanix_vms_shutdown_actions_v2_test.go b/nutanix/services/vmmv2/resource_nutanix_vms_shutdown_actions_v2_test.go index 3909cef10..fd108ae5e 100644 --- a/nutanix/services/vmmv2/resource_nutanix_vms_shutdown_actions_v2_test.go +++ b/nutanix/services/vmmv2/resource_nutanix_vms_shutdown_actions_v2_test.go @@ -172,7 +172,10 @@ func testAccCheckNutanixVirtualMachineV2Destroy(s *terraform.State) error { if err == nil { // delete the vm fmt.Printf("Deleting VM with ID: %s\n", rs.Primary.ID) - _, err = conn.VmmAPI.VMAPIInstance.DeleteVmById(utils.StringPtr(rs.Primary.ID)) + _, errVM := conn.VmmAPI.VMAPIInstance.DeleteVmById(utils.StringPtr(rs.Primary.ID)) + if errVM != nil { + return errVM + } } } return nil diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_disk_v2_test.go b/nutanix/services/volumesv2/data_source_nutanix_volume_disk_v2_test.go index bfb27c27c..3eaee3bc6 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_disk_v2_test.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_disk_v2_test.go @@ -36,8 +36,8 @@ func TestAccNutanixVolumeGroupsDiskV2DataSource_Basic(t *testing.T) { } func testAccVolumeGroupsDiskDataSourceConfig(filepath, name, desc string) string { - return testAccVolumeGroupResourceConfig(filepath, name, desc) + - testAccVolumeGroupDiskResourceConfig(filepath, name, desc) + + return testAccVolumeGroupResourceConfig(name, desc) + + testAccVolumeGroupDiskResourceConfig(name, desc) + ` data "nutanix_volume_group_disk_v2" "test" { volume_group_ext_id = nutanix_volume_group_v2.test.id diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_disks_v2_test.go b/nutanix/services/volumesv2/data_source_nutanix_volume_disks_v2_test.go index fe91e28e7..d6f47f39a 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_disks_v2_test.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_disks_v2_test.go @@ -62,7 +62,7 @@ func TestAccNutanixVolumeGroupsDisksV2DataSource_WithLimit(t *testing.T) { } func testAccVolumeGroupsDisksDataSourceConfig(filepath, name, desc string) string { - return testAccVolumeGroupResourceConfig(filepath, name, desc) + testAccVolumeGroupDiskResourceConfig(filepath, name, desc) + + return testAccVolumeGroupResourceConfig(name, desc) + testAccVolumeGroupDiskResourceConfig(name, desc) + fmt.Sprintf(` @@ -98,7 +98,7 @@ func testAccVolumeGroupsDisksDataSourceConfig(filepath, name, desc string) strin } func testAccVolumeGroupsDisksDataSourceWithLimit(filepath, name, desc string, limit int) string { - return testAccVolumeGroupResourceConfig(filepath, name, desc) + testAccVolumeGroupDiskResourceConfig(filepath, name, desc) + + return testAccVolumeGroupResourceConfig(name, desc) + testAccVolumeGroupDiskResourceConfig(name, desc) + fmt.Sprintf(` resource "nutanix_volume_group_disk_v2" "test-2" { diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_group_iscsi_clients_v2_test.go b/nutanix/services/volumesv2/data_source_nutanix_volume_group_iscsi_clients_v2_test.go index 9d347a065..4f30b278f 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_group_iscsi_clients_v2_test.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_group_iscsi_clients_v2_test.go @@ -34,7 +34,7 @@ func TestAccNutanixVolumeGroupIscsiClientsV2Datasource_Basic(t *testing.T) { } func testAccVolumeGroupIscsiClientsV2Config(filepath, name, desc string) string { - return testAccVolumeGroupResourceConfig(filepath, name, desc) + ` + return testAccVolumeGroupResourceConfig(name, desc) + ` data "nutanix_volume_iscsi_clients_v2" "test" {} resource "nutanix_volume_group_iscsi_client_v2" "vg_iscsi_test" { diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_group_v2_test.go b/nutanix/services/volumesv2/data_source_nutanix_volume_group_v2_test.go index 5167a6293..029eb6c88 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_group_v2_test.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_group_v2_test.go @@ -39,7 +39,7 @@ func TestAccNutanixVolumeGroupV2DataSource_Basic(t *testing.T) { } func testAccVolumeGroupDataSourceConfig(filepath, name, desc string) string { - return testAccVolumeGroupResourceConfig(filepath, name, desc) + ` + return testAccVolumeGroupResourceConfig(name, desc) + ` data "nutanix_volume_group_v2" "test" { ext_id = resource.nutanix_volume_group_v2.test.id depends_on = [resource.nutanix_volume_group_v2.test] diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_group_vms_v2_test.go b/nutanix/services/volumesv2/data_source_nutanix_volume_group_vms_v2_test.go index 02c474ddd..bf0c8c485 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_group_vms_v2_test.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_group_vms_v2_test.go @@ -2,7 +2,6 @@ package volumesv2_test import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" @@ -16,14 +15,12 @@ func TestAccNutanixVolumeGroupVmsAttachmentsV2DataSource_Basic(t *testing.T) { r := acctest.RandInt() name := fmt.Sprintf("terraform-test-volume-group-disk-%d", r) desc := "terraform test volume group disk description" - path, _ := os.Getwd() - filepath := path + "/../../../test_config_v2.json" resource.Test(t, resource.TestCase{ PreCheck: func() { acc.TestAccPreCheck(t) }, Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccVolumeGroupVmsAttachmentsDataSourceConfig(filepath, name, desc), + Config: testAccVolumeGroupVmsAttachmentsDataSourceConfig(name, desc), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(dataSourceVolumeGroupsVmsAttachments, "vms_attachments.#"), resource.TestCheckResourceAttrSet(dataSourceVolumeGroupsVmsAttachments, "vms_attachments.0.ext_id"), @@ -33,8 +30,8 @@ func TestAccNutanixVolumeGroupVmsAttachmentsV2DataSource_Basic(t *testing.T) { }) } -func testAccVolumeGroupVmsAttachmentsDataSourceConfig(filepath, name, desc string) string { - return testAccVolumeGroupResourceConfig(filepath, name, desc) + fmt.Sprintf(` +func testAccVolumeGroupVmsAttachmentsDataSourceConfig(name, desc string) string { + return testAccVolumeGroupResourceConfig(name, desc) + fmt.Sprintf(` resource "nutanix_virtual_machine_v2" "test"{ name= "tf-test-vg-vm-%[1]s" description = "%[2]s" diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_groups_v2_test.go b/nutanix/services/volumesv2/data_source_nutanix_volume_groups_v2_test.go index 233478dc0..1519d5361 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_groups_v2_test.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_groups_v2_test.go @@ -80,7 +80,7 @@ func TestAccNutanixVolumeGroupsV4DataSource_WithLimit(t *testing.T) { } func testAccVolumeGroupsDataSourceConfig(filepath, name, desc string) string { - return testAccVolumeGroupResourceConfig(filepath, name, desc) + ` + return testAccVolumeGroupResourceConfig(name, desc) + ` data "nutanix_volume_groups_v2" "test" { depends_on = [resource.nutanix_volume_group_v2.test] } @@ -88,7 +88,7 @@ func testAccVolumeGroupsDataSourceConfig(filepath, name, desc string) string { } func testAccVolumeGroupsDataSourceWithFilter(filepath, name, desc string) string { - return testAccVolumeGroupResourceConfig(filepath, name, desc) + fmt.Sprintf(` + return testAccVolumeGroupResourceConfig(name, desc) + fmt.Sprintf(` data "nutanix_volume_groups_v2" "test" { filter = "name eq '%s'" depends_on = [resource.nutanix_volume_group_v2.test] diff --git a/nutanix/services/volumesv2/helpers_test.go b/nutanix/services/volumesv2/helpers_test.go index f5bc8ec67..7e8e85b90 100644 --- a/nutanix/services/volumesv2/helpers_test.go +++ b/nutanix/services/volumesv2/helpers_test.go @@ -19,7 +19,7 @@ func testAccCheckResourceAttrListNotEmpty(resourceName, attrName, subAttr string resourceInstance := s.RootModule().Resources[resourceName] if resourceInstance == nil { - return fmt.Errorf("Resource %s not found", resourceName) + return fmt.Errorf("resource %s not found", resourceName) } prefix := attrName + "." @@ -79,7 +79,7 @@ func testAndCheckComputedValues(resourceName string) resource.TestCheckFunc { // VolumeGroup Resource -func testAccVolumeGroupResourceConfig(filepath, name, desc string) string { +func testAccVolumeGroupResourceConfig(name, desc string) string { return fmt.Sprintf(` data "nutanix_clusters_v2" "clusters" {} @@ -117,7 +117,7 @@ func testAccVolumeGroupResourceConfig(filepath, name, desc string) string { `, filepath, name, desc) } -func testAccVolumeGroupDiskResourceConfig(filepath, name, desc string) string { +func testAccVolumeGroupDiskResourceConfig(name, desc string) string { return fmt.Sprintf(` data "nutanix_storage_containers_v2" "test" { diff --git a/nutanix/services/volumesv2/main_test.go b/nutanix/services/volumesv2/main_test.go index 790d56eba..798c0f56d 100644 --- a/nutanix/services/volumesv2/main_test.go +++ b/nutanix/services/volumesv2/main_test.go @@ -10,7 +10,7 @@ import ( type TestConfig struct { // Volumes config Volumes struct { - VolumeGroupExtIdWithCategory string `json:"vg_ext_id_with_category"` + VolumeGroupExtIDWithCategory string `json:"vg_ext_id_with_category"` } `json:"volumes"` } diff --git a/nutanix/services/volumesv2/resource_nutanix_volume_group_disk_v2_test.go b/nutanix/services/volumesv2/resource_nutanix_volume_group_disk_v2_test.go index a9f2b3002..810f4f5b7 100644 --- a/nutanix/services/volumesv2/resource_nutanix_volume_group_disk_v2_test.go +++ b/nutanix/services/volumesv2/resource_nutanix_volume_group_disk_v2_test.go @@ -35,6 +35,6 @@ func TestAccNutanixVolumeGroupDiskV2Resource_Basic(t *testing.T) { } func testAccVolumeGroupsDiskResourceConfig(filepath, name, desc string) string { - return testAccVolumeGroupResourceConfig(filepath, name, desc) + - testAccVolumeGroupDiskResourceConfig(filepath, name, desc) + return testAccVolumeGroupResourceConfig(name, desc) + + testAccVolumeGroupDiskResourceConfig(name, desc) } diff --git a/nutanix/services/volumesv2/resource_nutanix_volume_group_iscsi_client_v2_test.go b/nutanix/services/volumesv2/resource_nutanix_volume_group_iscsi_client_v2_test.go index 159a88783..327b002bc 100644 --- a/nutanix/services/volumesv2/resource_nutanix_volume_group_iscsi_client_v2_test.go +++ b/nutanix/services/volumesv2/resource_nutanix_volume_group_iscsi_client_v2_test.go @@ -21,7 +21,7 @@ func TestAccNutanixVolumeGroupIscsiClientV2Resource_Basic(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccVolumeGroupResourceConfig(filepath, name, desc) + testAccVolumeGroupIscsiClientResourceConfig(), + Config: testAccVolumeGroupResourceConfig(name, desc) + testAccVolumeGroupIscsiClientResourceConfig(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceVolumeGroupIscsiClient, "ext_id"), ), diff --git a/nutanix/services/volumesv2/resource_nutanix_volume_group_v2_test.go b/nutanix/services/volumesv2/resource_nutanix_volume_group_v2_test.go index 1a6299e38..a39f7359f 100644 --- a/nutanix/services/volumesv2/resource_nutanix_volume_group_v2_test.go +++ b/nutanix/services/volumesv2/resource_nutanix_volume_group_v2_test.go @@ -24,7 +24,7 @@ func TestAccNutanixVolumeGroupV2Resource_Basic(t *testing.T) { // CheckDestroy: testAccCheckNutanixVolumeGroupV4Destroy, Steps: []resource.TestStep{ { - Config: testAccVolumeGroupResourceConfig(filepath, name, desc), + Config: testAccVolumeGroupResourceConfig(name, desc), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceNameVolumeGroup, "name", name), resource.TestCheckResourceAttr(resourceNameVolumeGroup, "description", desc), diff --git a/nutanix/services/volumesv2/resource_nutanix_volume_group_vm_v2_test.go b/nutanix/services/volumesv2/resource_nutanix_volume_group_vm_v2_test.go index 081cb684f..7b3ce5c9c 100644 --- a/nutanix/services/volumesv2/resource_nutanix_volume_group_vm_v2_test.go +++ b/nutanix/services/volumesv2/resource_nutanix_volume_group_vm_v2_test.go @@ -23,7 +23,7 @@ func TestAccNutanixVolumeGroupVmV2Resource_Basic(t *testing.T) { Providers: acc.TestAccProviders, Steps: []resource.TestStep{ { - Config: testAccVolumeGroupVmConfig(filepath, name, desc), + Config: resourceVolumeGroupVM(filepath, name, desc), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(resourceVolumeGroupVm, "vm_ext_id"), ), @@ -32,8 +32,8 @@ func TestAccNutanixVolumeGroupVmV2Resource_Basic(t *testing.T) { }) } -func testAccVolumeGroupVmConfig(filepath, name, desc string) string { - return testAccVolumeGroupResourceConfig(filepath, name, desc) + fmt.Sprintf(` +func resourceVolumeGroupVM(filepath, name, desc string) string { + return testAccVolumeGroupResourceConfig(name, desc) + fmt.Sprintf(` resource "nutanix_virtual_machine_v2" "test"{ name= "tf-test-vg-vm-%[1]s" description = "%[2]s"