Skip to content

Commit

Permalink
golint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimutant committed Dec 10, 2024
1 parent 3931163 commit a9eec5a
Show file tree
Hide file tree
Showing 50 changed files with 214 additions and 260 deletions.
26 changes: 13 additions & 13 deletions nutanix/services/clustersv2/data_source_nutanix_host_entity_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand All @@ -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"
}
}
Expand Down Expand Up @@ -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"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
},
},
Expand All @@ -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"),
},
},
Expand All @@ -65,15 +65,15 @@ func testHostEntityDatasourceV4Config() string {
`
}

func testHostEntityDatasourceV4WithoutClsExtIdConfig() string {
func testHostEntityDatasourceV4WithoutClsExtIDConfig() string {
return `
data "nutanix_host_v2" "test" {
ext_id = "00000000-0000-0000-0000-000000000000"
}
`
}

func testHostEntityDatasourceV4WithoutHostExtIdConfig() string {
func testHostEntityDatasourceV4WithoutHostExtIDConfig() string {
return `
data "nutanix_host_v2" "test" {
cluster_ext_id = "00000000-0000-0000-0000-000000000000"
Expand Down
2 changes: 1 addition & 1 deletion nutanix/services/clustersv2/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,16 @@ 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)
}

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")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),

Expand Down Expand Up @@ -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),
),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,16 @@ 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)
}

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")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestAccNutanixPePcRegistrationV2Resource_ValidationsDomainManagerRemoteClus
Providers: acc.TestAccProviders,
Steps: []resource.TestStep{
{
Config: testAccClusterResourceDomainManagerRemoteClusterSpecInvalidConfigWithoutPcExtId(),
Config: testAccClusterResourceDomainManagerRemoteClusterSpecInvalidConfigWithoutPcExtID(),
ExpectError: regexp.MustCompile("Missing required argument"),
},
{
Expand Down Expand Up @@ -61,15 +61,15 @@ func TestAccNutanixPePcRegistrationV2Resource_ValidationsClusterReference(t *tes
Providers: acc.TestAccProviders,
Steps: []resource.TestStep{
{
Config: testAccClusterResourceClusterReferenceInvalidConfigWithoutClusterExtId(),
Config: testAccClusterResourceClusterReferenceInvalidConfigWithoutClusterExtID(),
ExpectError: regexp.MustCompile("Missing required argument"),
},
},
})
}

// Invalid Configs for DomainManagerRemoteClusterSpec
func testAccClusterResourceDomainManagerRemoteClusterSpecInvalidConfigWithoutPcExtId() string {
func testAccClusterResourceDomainManagerRemoteClusterSpecInvalidConfigWithoutPcExtID() string {
return `
resource "nutanix_pc_registration_v2" "test" {
remote_cluster {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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" {
Expand Down Expand Up @@ -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"{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"),
),
},
},
Expand All @@ -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"),
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nutanix/services/dataprotectionv2/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.#"),
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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{}
Expand Down
Loading

0 comments on commit a9eec5a

Please sign in to comment.