diff --git a/.golangci.yml b/.golangci.yml index 4c5b3bf66..a003b1d8a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -53,6 +53,7 @@ linters: - unused - staticcheck - deadcode + - ifElseChain issues: exclude: diff --git a/nutanix/provider/provider.go b/nutanix/provider/provider.go index 52341f30c..25a8d713a 100644 --- a/nutanix/provider/provider.go +++ b/nutanix/provider/provider.go @@ -363,7 +363,7 @@ func Provider() *schema.Provider { "nutanix_volume_group_v2": volumesv2.ResourceNutanixVolumeGroupV2(), "nutanix_volume_group_disk_v2": volumesv2.ResourceNutanixVolumeGroupDiskV2(), "nutanix_volume_group_iscsi_client_v2": volumesv2.ResourceNutanixVolumeGroupIscsiClientV2(), - "nutanix_volume_group_vm_v2": volumesv2.ResourceNutanixVolumeAttachVmToVolumeGroupV2(), + "nutanix_volume_group_vm_v2": volumesv2.ResourceNutanixVolumeAttachVMToVolumeGroupV2(), "nutanix_recovery_points_v2": dataprotectionv2.ResourceNutanixRecoveryPointsV2(), "nutanix_recovery_point_replicate_v2": dataprotectionv2.ResourceNutanixRecoveryPointReplicateV2(), "nutanix_recovery_point_restore_v2": dataprotectionv2.ResourceNutanixRecoveryPointRestoreV2(), diff --git a/nutanix/services/clustersv2/data_source_nutanix_cluster_entity_v2.go b/nutanix/services/clustersv2/data_source_nutanix_cluster_entity_v2.go index 3e3664475..b10a35254 100644 --- a/nutanix/services/clustersv2/data_source_nutanix_cluster_entity_v2.go +++ b/nutanix/services/clustersv2/data_source_nutanix_cluster_entity_v2.go @@ -897,13 +897,10 @@ func flattenProxyTypes(proxyTypes []import1.HttpProxyType) []interface{} { switch v { case HTTP: types[k] = "HTTP" - break case HTTPS: types[k] = "HTTPS" - break case SOCKS: types[k] = "SOCKS" - break default: types[k] = "UNKNOWN" } @@ -1015,13 +1012,10 @@ func flattenSMTPServerRef(pr *import1.SmtpServerRef) []map[string]interface{} { switch *pr.Type { case PLAIN: s["type"] = "PLAIN" - break case STARTTLS: s["type"] = "STARTTLS" - break case SSL: s["type"] = "SSL" - break default: s["type"] = "UNKNOWN" } diff --git a/nutanix/services/clustersv2/resource_nutanix_cluster_entity_add_node_v2.go b/nutanix/services/clustersv2/resource_nutanix_cluster_entity_add_node_v2.go index 95037d925..d37e45391 100644 --- a/nutanix/services/clustersv2/resource_nutanix_cluster_entity_add_node_v2.go +++ b/nutanix/services/clustersv2/resource_nutanix_cluster_entity_add_node_v2.go @@ -1023,13 +1023,13 @@ func expandDetails(pr interface{}) *config.UserInfo { func expandHypervisorType(hypervisorType interface{}) *config.HypervisorType { if hypervisorType != nil && hypervisorType != "" { - + const two, three, four, five, six = 2, 3, 4, 5, 6 subMap := map[string]interface{}{ - "AHV": 2, - "ESX": 3, - "HYPERV": 4, - "XEN": 5, - "NATIVEHOST": 6, + "AHV": two, + "ESX": three, + "HYPERV": four, + "XEN": five, + "NATIVEHOST": six, } pVal := subMap[hypervisorType.(string)] if pVal == nil { diff --git a/nutanix/services/clustersv2/resource_nutanix_cluster_entity_v2.go b/nutanix/services/clustersv2/resource_nutanix_cluster_entity_v2.go index 1976e18b9..b730555c6 100644 --- a/nutanix/services/clustersv2/resource_nutanix_cluster_entity_v2.go +++ b/nutanix/services/clustersv2/resource_nutanix_cluster_entity_v2.go @@ -24,6 +24,10 @@ import ( "github.com/terraform-providers/terraform-provider-nutanix/utils" ) +const ( + CANCELED = "CANCELLED" +) + func ResourceNutanixClusterV2() *schema.Resource { return &schema.Resource{ CreateContext: ResourceNutanixClusterV2Create, @@ -980,6 +984,9 @@ func ResourceNutanixClusterV2Update(ctx context.Context, d *schema.ResourceData, } resourceUUID, err := taskconn.TaskRefAPI.GetTaskById(taskUUID, nil) + if err != nil { + return diag.Errorf("error while updating clusters : %v", err) + } if _, errWaitTask := stateConf.WaitForStateContext(ctx); errWaitTask != nil { return diag.Errorf("error waiting for cluster (%s) to update: %s", utils.StringValue(taskUUID), errWaitTask) @@ -1166,7 +1173,7 @@ func expandUpgradeStatus(upgradeStatus interface{}) *config.UpgradeStatus { "UPGRADING": six, "SUCCEEDED": seven, "FAILED": eight, - "CANCELLED": nine, + CANCELED: nine, "SCHEDULED": ten, } if subMap[upgradeStatus.(string)] != nil { @@ -1406,9 +1413,10 @@ func expandClusterConfigReference(pr interface{}, d *schema.ResourceData) *confi clsConf.RedundancyFactor = utils.Int64Ptr(int64(redundancyFactor.(int))) } if clusterArch, ok := val["cluster_arch"]; ok && d.HasChange("config.0.cluster_arch") { + const two, three = 2, 3 subMap := map[string]interface{}{ - "X86_64": 2, - "PPC64LE": 3, + "X86_64": two, + "PPC64LE": three, } if subMap[clusterArch.(string)] != nil { pVal := subMap[clusterArch.(string)] @@ -1420,12 +1428,13 @@ func expandClusterConfigReference(pr interface{}, d *schema.ResourceData) *confi clsConf.FaultToleranceState = expandFaultToleranceState(faultToleranceState) } if operationMode, ok := val["operation_mode"]; ok && d.HasChange("config.0.operation_mode") { + const two, three, four, five, six = 2, 3, 4, 5, 6 subMap := map[string]interface{}{ - "NORMAL": 2, - "READ_ONLY": 3, - "STAND_ALONE": 4, - "SWITCH_TO_TWO_NODE": 5, - "OVERRIDE": 6, + "NORMAL": two, + "READ_ONLY": three, + "STAND_ALONE": four, + "SWITCH_TO_TWO_NODE": five, + "OVERRIDE": six, } if subMap[operationMode.(string)] != nil { pVal := subMap[operationMode.(string)] @@ -1434,9 +1443,10 @@ func expandClusterConfigReference(pr interface{}, d *schema.ResourceData) *confi } } if encryptionInTransitStatus, ok := val["encryption_in_transit_status"]; ok && d.HasChange("config.0.encryption_in_transit_status") { + const two, three = 2, 3 subMap := map[string]interface{}{ - "ENABLED": 2, - "DISABLED": 3, + "ENABLED": two, + "DISABLED": three, } if subMap[encryptionInTransitStatus.(string)] != nil { @@ -1595,10 +1605,11 @@ func expandSMTPServerRef(pr interface{}) *config.SmtpServerRef { smtp.Server = expandSMTPNetwork(server.([]interface{})) } if smtpType, ok := val["type"]; ok { + const two, three, four = 2, 3, 4 subMap := map[string]interface{}{ - "PLAIN": 2, - "STARTTLS": 3, - "SSL": 4, + "PLAIN": two, + "STARTTLS": three, + "SSL": four, } if subMap[smtpType.(string)] != nil { pVal := subMap[smtpType.(string)] @@ -1647,16 +1658,16 @@ func expandManagementServerRef(pr interface{}) *config.ManagementServerRef { val := prI[0].(map[string]interface{}) if ip, ok := val["ip"]; ok { - log.Printf("[DEBUG] managment server ip") + log.Printf("[DEBUG] management server ip") mgm.Ip = expandIPAddress(ip.([]interface{})) } if mgmType, ok := val["type"]; ok { + const two = 2 switch mgmType.(string) { case "VCENTER": - p := config.ManagementServerType(2) + p := config.ManagementServerType(two) mgm.Type = &p log.Printf("[DEBUG] mgmType : VCENTER case") - break default: log.Printf("[DEBUG] mgmType : default case") mgm.Type = nil @@ -1776,11 +1787,12 @@ func expandFaultToleranceState(pr interface{}) *config.FaultToleranceState { val := prI[0].(map[string]interface{}) if domainAwarenessLevel, ok := val["domain_awareness_level"]; ok { + const two, three, four, five = 2, 3, 4, 5 subMap := map[string]interface{}{ - "NODE": 2, - "BLOCK": 3, - "RACK": 4, - "DISK": 5, + "NODE": two, + "BLOCK": three, + "RACK": four, + "DISK": five, } if subMap[domainAwarenessLevel.(string)] != nil { pVal := subMap[domainAwarenessLevel.(string)] @@ -1790,11 +1802,12 @@ func expandFaultToleranceState(pr interface{}) *config.FaultToleranceState { } if currentClusterFaultTolerance, ok := val["current_cluster_fault_tolerance"]; ok { + const two, three, four, five = 2, 3, 4, 5 subMap := map[string]interface{}{ - "CFT_0N_AND_0D": 2, - "CFT_1N_OR_1D": 3, - "CFT_2N_OR_2D": 4, - "CFT_1N_AND_1D": 5, + "CFT_0N_AND_0D": two, + "CFT_1N_OR_1D": three, + "CFT_2N_OR_2D": four, + "CFT_1N_AND_1D": five, } if subMap[currentClusterFaultTolerance.(string)] != nil { pVal := subMap[currentClusterFaultTolerance.(string)] @@ -1804,12 +1817,12 @@ func expandFaultToleranceState(pr interface{}) *config.FaultToleranceState { } if desiredClusterFaultTolerance, ok := val["desired_cluster_fault_tolerance"]; ok { - + const two, three, four, five = 2, 3, 4, 5 subMap := map[string]interface{}{ - "CFT_0N_AND_0D": 2, - "CFT_1N_OR_1D": 3, - "CFT_2N_OR_2D": 4, - "CFT_1N_AND_1D": 5, + "CFT_0N_AND_0D": two, + "CFT_1N_OR_1D": three, + "CFT_2N_OR_2D": four, + "CFT_1N_AND_1D": five, } if subMap[desiredClusterFaultTolerance.(string)] != nil { pVal := subMap[desiredClusterFaultTolerance.(string)] diff --git a/nutanix/services/clustersv2/resource_nutanix_pc_registration_v2.go b/nutanix/services/clustersv2/resource_nutanix_pc_registration_v2.go index fd80a5ee3..e8626730d 100644 --- a/nutanix/services/clustersv2/resource_nutanix_pc_registration_v2.go +++ b/nutanix/services/clustersv2/resource_nutanix_pc_registration_v2.go @@ -577,7 +577,7 @@ func ResourceNutanixClusterPCRegistrationV2Create(ctx context.Context, d *schema rUUID := resourceUUID.Data.GetValue().(prismConfig.Task) aJson, _ = json.Marshal(rUUID) - log.Printf("[DEBUG] PC Regestration Task Details: %s", string(aJson)) + log.Printf("[DEBUG] PC Registration Task Details: %s", string(aJson)) d.SetId(pcExtID) return ResourceNutanixClusterPCRegistrationV2Read(ctx, d, meta) 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 3dd396e17..dd509c540 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 @@ -12,7 +12,6 @@ import ( ) const resourceNameRecoveryPointReplicate = "nutanix_recovery_point_replicate_v2.test" -const resourceNameCluster = "nutanix_cluster_v2.test" func TestAccNutanixRecoveryPointReplicateV2Resource_basic(t *testing.T) { r := acctest.RandInt() diff --git a/nutanix/services/iamv2/data_source_nutanix_operation_v2.go b/nutanix/services/iamv2/data_source_nutanix_operation_v2.go index 61813e570..613004a98 100644 --- a/nutanix/services/iamv2/data_source_nutanix_operation_v2.go +++ b/nutanix/services/iamv2/data_source_nutanix_operation_v2.go @@ -130,13 +130,14 @@ func DatasourceNutanixOperationV4Read(ctx context.Context, d *schema.ResourceDat func flattenOperationType(pr *import1.OperationType) string { if pr != nil { - if *pr == import1.OperationType(2) { + const two, three, four = 2, 3, 4 + if *pr == import1.OperationType(two) { return "INTERNAL" } - if *pr == import1.OperationType(3) { + if *pr == import1.OperationType(three) { return "SYSTEM_DEFINED_ONLY" } - if *pr == import1.OperationType(4) { + if *pr == import1.OperationType(four) { return "EXTERNAL" } } diff --git a/nutanix/services/iamv2/data_source_nutanix_roles_v2.go b/nutanix/services/iamv2/data_source_nutanix_roles_v2.go index 824112915..c03c6842b 100644 --- a/nutanix/services/iamv2/data_source_nutanix_roles_v2.go +++ b/nutanix/services/iamv2/data_source_nutanix_roles_v2.go @@ -29,19 +29,16 @@ func DatasourceNutanixRolesV2() *schema.Resource { Optional: true, }, "filter": { - Description: "A URL query parameter that allows clients to filter a collection of resources. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response. Expression specified with the $filter must conform to the OData V4.01 URL conventions. For example, filter '$filter=name eq 'karbon-ntnx-1.0' would filter the result on cluster name 'karbon-ntnx1.0', filter '$filter=startswith(name, 'C')' would filter on cluster name starting with 'C'. The filter can be applied to the following fields: clientName, createdBy, createdTime, displayName, extId, isSystemDefined, lastUpdatedTime", - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, }, "order_by": { - Description: "A URL query parameter that allows clients to specify the sort criteria for the returned list of objects. Resources can be sorted in ascending order using asc or descending order using desc. If asc or desc are not specified, the resources will be sorted in ascending order by default. For example, '$orderby=templateName desc' would get all templates sorted by templateName in descending order. The orderby can be applied to the following fields: clientName, displayName, extId, lastUpdatedTime", - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, }, "select": { - Description: "A URL query parameter that allows clients to request a specific set of properties for each entity or complex type. Expression specified with the $select must conform to the OData V4.01 URL conventions. If a $select expression consists of a single select item that is an asterisk (i.e., *), then all properties on the matching resource will be returned. The select can be applied to the following fields: accessibleClients, accessibleEntityTypes, assignedUserGroupsCount, assignedUsersCount, clientName, createdBy, createdTime, description, displayName, extId, isSystemDefined, lastUpdatedTime, links, operations, tenantId", - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, }, "roles": { Type: schema.TypeList, diff --git a/nutanix/services/iamv2/data_source_nutanix_user_group_v2.go b/nutanix/services/iamv2/data_source_nutanix_user_group_v2.go index e92cc3a29..c24a322d6 100644 --- a/nutanix/services/iamv2/data_source_nutanix_user_group_v2.go +++ b/nutanix/services/iamv2/data_source_nutanix_user_group_v2.go @@ -105,10 +105,11 @@ func DatasourceNutanixUserGroupV4Read(ctx context.Context, d *schema.ResourceDat func flattenGroupType(pr *import1.GroupType) string { if pr != nil { - if *pr == import1.GroupType(2) { + const two, three = 2, 3 + if *pr == import1.GroupType(two) { return "SAML" } - if *pr == import1.GroupType(3) { + if *pr == import1.GroupType(three) { return "LDAP" } } diff --git a/nutanix/services/storagecontainersv2/data_source_nutanix_storage_container_stats.go b/nutanix/services/storagecontainersv2/data_source_nutanix_storage_container_stats.go index 72304d13a..4f482507e 100644 --- a/nutanix/services/storagecontainersv2/data_source_nutanix_storage_container_stats.go +++ b/nutanix/services/storagecontainersv2/data_source_nutanix_storage_container_stats.go @@ -132,16 +132,16 @@ func DatasourceNutanixStorageStatsInfoV2Read(ctx context.Context, d *schema.Reso return diag.Errorf("sampling_interval should be greater than 0") } - const seven = 7 + const two, three, four, five, six, seven = 2, 3, 4, 5, 6, 7 statType := clsstats.DownSamplingOperator(seven) // Default value is LAST, Aggregation containing only the last recorded value. subMap := map[string]interface{}{ - "SUM": 2, - "MIN": 3, - "MAX": 4, - "AVG": 5, - "COUNT": 6, - "LAST": 7, + "SUM": two, + "MIN": three, + "MAX": four, + "AVG": five, + "COUNT": six, + "LAST": seven, } pVal := subMap[d.Get("stat_type").(string)] if pVal != nil { diff --git a/nutanix/services/storagecontainersv2/resource_nutanix_storge_containers_v2.go b/nutanix/services/storagecontainersv2/resource_nutanix_storge_containers_v2.go index 56dbf222e..6253ff31a 100644 --- a/nutanix/services/storagecontainersv2/resource_nutanix_storge_containers_v2.go +++ b/nutanix/services/storagecontainersv2/resource_nutanix_storge_containers_v2.go @@ -238,7 +238,7 @@ func ResourceNutanixStorageContainersV2Create(ctx context.Context, d *schema.Res body.IsInlineEcEnabled = utils.BoolPtr(bool(isInlineEcEnabled.(bool))) } if hasHigherEcFaultDomainPreference, ok := d.GetOk("has_higher_ec_fault_domain_preference"); ok { - body.HasHigherEcFaultDomainPreference = utils.BoolPtr(bool(hasHigherEcFaultDomainPreference.(bool))) + body.HasHigherEcFaultDomainPreference = utils.BoolPtr(hasHigherEcFaultDomainPreference.(bool)) } if erasureCodeDelaySecs, ok := d.GetOk("erasure_code_delay_secs"); ok { body.ErasureCodeDelaySecs = utils.IntPtr(int(erasureCodeDelaySecs.(int))) @@ -264,7 +264,7 @@ func ResourceNutanixStorageContainersV2Create(ctx context.Context, d *schema.Res body.OnDiskDedup = &p } if isCompressionEnabled, ok := d.GetOk("is_compression_enabled"); ok { - body.IsCompressionEnabled = utils.BoolPtr(bool(isCompressionEnabled.(bool))) + body.IsCompressionEnabled = utils.BoolPtr(isCompressionEnabled.(bool)) } if compressionDelaySecs, ok := d.GetOk("compression_delay_secs"); ok { body.CompressionDelaySecs = utils.IntPtr(int(compressionDelaySecs.(int))) @@ -273,7 +273,7 @@ func ResourceNutanixStorageContainersV2Create(ctx context.Context, d *schema.Res body.IsInternal = utils.BoolPtr(bool(isInternal.(bool))) } if isSoftwareEncryptionEnabled, ok := d.GetOk("is_software_encryption_enabled"); ok { - body.IsSoftwareEncryptionEnabled = utils.BoolPtr(bool(isSoftwareEncryptionEnabled.(bool))) + body.IsSoftwareEncryptionEnabled = utils.BoolPtr(isSoftwareEncryptionEnabled.(bool)) } if affinityHostExtId, ok := d.GetOk("affinity_host_ext_id"); ok { body.AffinityHostExtId = utils.StringPtr(affinityHostExtId.(string)) @@ -665,20 +665,21 @@ func taskStateRefreshPrismTaskGroupFunc(ctx context.Context, client *prism.Clien } func getTaskStatus(pr *prismConfig.TaskStatus) string { + const two, three, five, six, seven = 2, 3, 5, 6, 7 if pr != nil { - if *pr == prismConfig.TaskStatus(6) { + if *pr == prismConfig.TaskStatus(six) { return "FAILED" } - if *pr == prismConfig.TaskStatus(7) { + if *pr == prismConfig.TaskStatus(seven) { return "CANCELED" } - if *pr == prismConfig.TaskStatus(2) { + if *pr == prismConfig.TaskStatus(two) { return "QUEUED" } - if *pr == prismConfig.TaskStatus(3) { + if *pr == prismConfig.TaskStatus(three) { return "RUNNING" } - if *pr == prismConfig.TaskStatus(5) { + if *pr == prismConfig.TaskStatus(five) { return "SUCCEEDED" } } diff --git a/nutanix/services/vmmv2/data_source_nutanix_image_v2.go b/nutanix/services/vmmv2/data_source_nutanix_image_v2.go index 859258855..63d08f72c 100644 --- a/nutanix/services/vmmv2/data_source_nutanix_image_v2.go +++ b/nutanix/services/vmmv2/data_source_nutanix_image_v2.go @@ -298,7 +298,7 @@ func flattenOneOfImageSource(pr *import5.OneOfImageSource) []map[string]interfac urlSrcObj["url"] = urlSrc.Url } if urlSrc.BasicAuth != nil { - urlSrcObj["basic_auth"] = flattenUrlBasicAuth(urlSrc.BasicAuth) + urlSrcObj["basic_auth"] = flattenURLBasicAuth(urlSrc.BasicAuth) } if urlSrc.ShouldAllowInsecureUrl != nil { urlSrcObj["should_allow_insecure_url"] = urlSrc.ShouldAllowInsecureUrl @@ -353,7 +353,7 @@ func flattenOneOfImageSource(pr *import5.OneOfImageSource) []map[string]interfac return nil } -func flattenUrlBasicAuth(pr *import5.UrlBasicAuth) []map[string]interface{} { +func flattenURLBasicAuth(pr *import5.UrlBasicAuth) []map[string]interface{} { if pr != nil { auths := make([]map[string]interface{}, 0) diff --git a/nutanix/services/vmmv2/data_source_nutanix_template_v2.go b/nutanix/services/vmmv2/data_source_nutanix_template_v2.go index 9698efbf8..2293dea91 100644 --- a/nutanix/services/vmmv2/data_source_nutanix_template_v2.go +++ b/nutanix/services/vmmv2/data_source_nutanix_template_v2.go @@ -128,7 +128,7 @@ func DatasourceNutanixTemplateV2Read(ctx context.Context, d *schema.ResourceData if err := d.Set("tenant_id", getResp.TenantId); err != nil { return diag.FromErr(err) } - if err := d.Set("links", flattenApiLink(getResp.Links)); err != nil { + if err := d.Set("links", flattenAPILink(getResp.Links)); err != nil { return diag.FromErr(err) } if err := d.Set("ext_id", getResp.ExtId); err != nil { @@ -386,7 +386,7 @@ func flattenTemplateVersionSpec(pr *import5.TemplateVersionSpec) []map[string]in tmp["ext_id"] = pr.ExtId } if pr.Links != nil { - tmp["links"] = flattenApiLink(pr.Links) + tmp["links"] = flattenAPILink(pr.Links) } if pr.VersionName != nil { tmp["version_name"] = pr.VersionName @@ -395,7 +395,7 @@ func flattenTemplateVersionSpec(pr *import5.TemplateVersionSpec) []map[string]in tmp["version_description"] = pr.VersionDescription } if pr.VmSpec != nil { - tmp["vm_spec"] = flattenVm(pr.VmSpec) + tmp["vm_spec"] = flattenVM(pr.VmSpec) } if pr.CreateTime != nil { t := pr.CreateTime @@ -440,7 +440,7 @@ func flattenTemplateVersionSource(versionSource *import5.OneOfTemplateVersionSpe versionReference := versionSource.GetValue().(import5.TemplateVersionReference) tempVersionReferenceMap["version_id"] = versionReference.VersionId - tempVersionReferenceMap["override_vm_config"] = flattenTemplateVmRefOverrideVmConfig(versionReference.OverrideVmConfig) + tempVersionReferenceMap["override_vm_config"] = flattenTemplateVMRefOverrideVMConfig(versionReference.OverrideVmConfig) tmp["template_version_reference"] = []map[string]interface{}{tempVersionReferenceMap} } @@ -531,7 +531,7 @@ func flattenTemplateVersionSource(versionSource *import5.OneOfTemplateVersionSpe // return nil //} -func flattenTemplateVmRefOverrideVmConfig(vmConfig *import5.VmConfigOverride) []map[string]interface{} { +func flattenTemplateVMRefOverrideVMConfig(vmConfig *import5.VmConfigOverride) []map[string]interface{} { if vmConfig != nil { vmConfigMap := make(map[string]interface{}) if vmConfig.Name != nil { @@ -690,7 +690,7 @@ func SchemaForCreateByAndUpdateByUser() *schema.Schema { } } -func flattenVm(v *import6.Vm) []map[string]interface{} { +func flattenVM(v *import6.Vm) []map[string]interface{} { if v != nil { vmList := make([]map[string]interface{}, 0) vm := make(map[string]interface{}) @@ -699,7 +699,7 @@ func flattenVm(v *import6.Vm) []map[string]interface{} { vm["tenant_id"] = v.TenantId } if v.Links != nil { - vm["links"] = flattenApiLink(v.Links) + vm["links"] = flattenAPILink(v.Links) } if v.ExtId != nil { vm["ext_id"] = v.ExtId @@ -719,7 +719,7 @@ func flattenVm(v *import6.Vm) []map[string]interface{} { vm["update_time"] = t.String() } if v.Source != nil { - vm["source"] = flattenVmSourceReference(v.Source) + vm["source"] = flattenVMSourceReference(v.Source) } if v.NumSockets != nil { vm["num_sockets"] = v.NumSockets @@ -743,7 +743,7 @@ func flattenVm(v *import6.Vm) []map[string]interface{} { vm["is_cpu_passthrough_enabled"] = v.IsCpuPassthroughEnabled } if v.EnabledCpuFeatures != nil { - vm["enabled_cpu_features"] = flattenCpuFeature(v.EnabledCpuFeatures) + vm["enabled_cpu_features"] = flattenCPUFeature(v.EnabledCpuFeatures) } if v.IsMemoryOvercommitEnabled != nil { vm["is_memory_overcommit_enabled"] = v.IsMemoryOvercommitEnabled @@ -782,7 +782,7 @@ func flattenVm(v *import6.Vm) []map[string]interface{} { vm["is_branding_enabled"] = v.IsBrandingEnabled } if v.BootConfig != nil { - vm["boot_config"] = flattenOneOfVmBootConfig(v.BootConfig) + vm["boot_config"] = flattenOneOfVMBootConfig(v.BootConfig) } if v.IsVgaConsoleEnabled != nil { vm["is_vga_console_enabled"] = v.IsVgaConsoleEnabled diff --git a/nutanix/services/vmmv2/data_source_nutanix_templates_v2.go b/nutanix/services/vmmv2/data_source_nutanix_templates_v2.go index 5c020bbb2..3c94099b0 100644 --- a/nutanix/services/vmmv2/data_source_nutanix_templates_v2.go +++ b/nutanix/services/vmmv2/data_source_nutanix_templates_v2.go @@ -102,7 +102,7 @@ func flattenTemplatesEntities(pr []import5.Template) []interface{} { temp := make(map[string]interface{}) temp["tenant_id"] = v.TenantId - temp["links"] = flattenApiLink(v.Links) + temp["links"] = flattenAPILink(v.Links) temp["ext_id"] = v.ExtId temp["template_name"] = v.TemplateName temp["template_description"] = v.TemplateDescription 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 e4fc943cd..4222a6cfb 100644 --- a/nutanix/services/vmmv2/data_source_nutanix_virtual_machine_v2.go +++ b/nutanix/services/vmmv2/data_source_nutanix_virtual_machine_v2.go @@ -1274,7 +1274,7 @@ func DatasourceNutanixVirtualMachineV4Read(ctx context.Context, d *schema.Resour return diag.FromErr(err) } } - if err := d.Set("source", flattenVmSourceReference(getResp.Source)); err != nil { + if err := d.Set("source", flattenVMSourceReference(getResp.Source)); err != nil { return diag.FromErr(err) } if err := d.Set("num_sockets", getResp.NumSockets); err != nil { @@ -1298,7 +1298,7 @@ func DatasourceNutanixVirtualMachineV4Read(ctx context.Context, d *schema.Resour if err := d.Set("is_cpu_passthrough_enabled", getResp.IsCpuPassthroughEnabled); err != nil { return diag.FromErr(err) } - if err := d.Set("enabled_cpu_features", flattenCpuFeature(getResp.EnabledCpuFeatures)); err != nil { + if err := d.Set("enabled_cpu_features", flattenCPUFeature(getResp.EnabledCpuFeatures)); err != nil { return diag.FromErr(err) } if err := d.Set("is_memory_overcommit_enabled", getResp.IsMemoryOvercommitEnabled); err != nil { @@ -1343,7 +1343,7 @@ func DatasourceNutanixVirtualMachineV4Read(ctx context.Context, d *schema.Resour if err := d.Set("is_branding_enabled", getResp.IsBrandingEnabled); err != nil { return diag.FromErr(err) } - if err := d.Set("boot_config", flattenOneOfVmBootConfig(getResp.BootConfig)); err != nil { + if err := d.Set("boot_config", flattenOneOfVMBootConfig(getResp.BootConfig)); err != nil { return diag.FromErr(err) } if err := d.Set("is_vga_console_enabled", getResp.IsVgaConsoleEnabled); err != nil { @@ -1401,7 +1401,7 @@ func DatasourceNutanixVirtualMachineV4Read(ctx context.Context, d *schema.Resour return nil } -func flattenVmSourceReference(ref *config.VmSourceReference) []map[string]interface{} { +func flattenVMSourceReference(ref *config.VmSourceReference) []map[string]interface{} { if ref != nil { refList := make([]map[string]interface{}, 0) @@ -1433,7 +1433,7 @@ func flattenVmSourceReferenceEntityType(ent *config.VmSourceReferenceEntityType) return "UNKNOWN" } -func flattenCpuFeature(cfg []config.CpuFeature) []interface{} { +func flattenCPUFeature(cfg []config.CpuFeature) []interface{} { if len(cfg) > 0 { cfgList := make([]interface{}, len(cfg)) @@ -1550,8 +1550,8 @@ func flattenGuestCustomizationParams(gst *config.GuestCustomizationParams) []map } gstList = append(gstList, gsts) - aJson, _ := json.Marshal(gstList) - log.Printf("[DEBUG] flattenGuestCustomizationParams[config]: %s", string(aJson)) + aJSON, _ := json.Marshal(gstList) + log.Printf("[DEBUG] flattenGuestCustomizationParams[config]: %s", string(aJSON)) return gstList } return nil @@ -1574,8 +1574,8 @@ func flattenOneOfGuestCustomizationParamsConfig(cfg *config.OneOfGuestCustomizat sysprepObj["sysprep_script"] = flattenOneOfSysprepSysprepScript(sysObj.SysprepScript) - aJson, _ := json.Marshal(sysprepObj) - log.Printf("[DEBUG] flattenOneOfGuestCustomizationParamsConfig sysprep: %s", string(aJson)) + aJSON, _ := json.Marshal(sysprepObj) + log.Printf("[DEBUG] flattenOneOfGuestCustomizationParamsConfig sysprep: %s", string(aJSON)) sysprepObjList = append(sysprepObjList, sysprepObj) sysCfg["sysprep"] = sysprepObjList @@ -1599,8 +1599,8 @@ func flattenOneOfGuestCustomizationParamsConfig(cfg *config.OneOfGuestCustomizat cfgList = cloudCfgList } - aJson, _ := json.Marshal(cfgList) - log.Printf("[DEBUG] flattenOneOfGuestCustomizationParamsConfig: %s", string(aJson)) + aJSON, _ := json.Marshal(cfgList) + log.Printf("[DEBUG] flattenOneOfGuestCustomizationParamsConfig: %s", string(aJSON)) return cfgList } return nil @@ -1628,15 +1628,15 @@ func flattenOneOfSysprepSysprepScript(cfg *config.OneOfSysprepSysprepScript) []m customKeyValCfgList := make([]map[string]interface{}, 0) if *cfg.ObjectType_ == "vmm.v4.ahv.config.Unattendxml" { - unattendXMl := make(map[string]interface{}) - unattendXMlList := make([]map[string]interface{}, 0) + unattendXML := make(map[string]interface{}) + unattendXMLList := make([]map[string]interface{}, 0) xmlCfg := cfg.GetValue().(config.Unattendxml) - unattendXMl["value"] = xmlCfg.Value + unattendXML["value"] = xmlCfg.Value - unattendXMlList = append(unattendXMlList, unattendXMl) + unattendXMLList = append(unattendXMLList, unattendXML) - unattendCfg["unattend_xml"] = unattendXMlList + unattendCfg["unattend_xml"] = unattendXMLList unattendCfgList = append(unattendCfgList, unattendCfg) @@ -1771,7 +1771,7 @@ func flattenNgtCapability(pr []config.NgtCapability) []interface{} { return nil } -func flattenOneOfVmBootConfig(pr *config.OneOfVmBootConfig) []map[string]interface{} { +func flattenOneOfVMBootConfig(pr *config.OneOfVmBootConfig) []map[string]interface{} { if pr != nil { bootCfg := make([]map[string]interface{}, 0) legacyBootCfg := make(map[string]interface{}) @@ -1792,20 +1792,19 @@ func flattenOneOfVmBootConfig(pr *config.OneOfVmBootConfig) []map[string]interfa legacyObjList = append(legacyObjList, legacyBootCfg) return legacyObjList - } else { - uefiObj := make(map[string]interface{}) - uefiObjList := make([]map[string]interface{}, 0) - uefiVals := pr.GetValue().(config.UefiBoot) + } + uefiObj := make(map[string]interface{}) + uefiObjList := make([]map[string]interface{}, 0) + uefiVals := pr.GetValue().(config.UefiBoot) - uefiObj["is_secure_boot_enabled"] = uefiVals.IsSecureBootEnabled - uefiObj["nvram_device"] = flattenNvramDevice(uefiVals.NvramDevice) + uefiObj["is_secure_boot_enabled"] = uefiVals.IsSecureBootEnabled + uefiObj["nvram_device"] = flattenNvramDevice(uefiVals.NvramDevice) - uefiObjList = append(uefiObjList, uefiObj) - uefiBootCfg["uefi_boot"] = uefiObjList - uefiBootCfgList = append(uefiBootCfgList, uefiBootCfg) + uefiObjList = append(uefiObjList, uefiObj) + uefiBootCfg["uefi_boot"] = uefiObjList + uefiBootCfgList = append(uefiBootCfgList, uefiBootCfg) - bootCfg = uefiBootCfgList - } + bootCfg = uefiBootCfgList return bootCfg } return nil @@ -1833,20 +1832,19 @@ func flattenOneOfLegacyBootBootDevice(cfg *config.OneOfLegacyBootBootDevice) []m deviceDisk["boot_device_disk"] = deviceDiskObjList deviceDiskList = append(deviceDiskList, deviceDisk) return deviceDiskList - } else { - deviceNicObj := make(map[string]interface{}) - deviceNicObjList := make([]map[string]interface{}, 0) - deviceNicVal := cfg.GetValue().(config.BootDeviceNic) + } + deviceNicObj := make(map[string]interface{}) + deviceNicObjList := make([]map[string]interface{}, 0) + deviceNicVal := cfg.GetValue().(config.BootDeviceNic) - deviceNicObj["mac_address"] = deviceNicVal.MacAddress - deviceNicObjList = append(deviceNicObjList, deviceNicObj) + deviceNicObj["mac_address"] = deviceNicVal.MacAddress + deviceNicObjList = append(deviceNicObjList, deviceNicObj) - deviceNic["boot_device_nic"] = deviceNicObjList + deviceNic["boot_device_nic"] = deviceNicObjList - deviceNicList = append(deviceNicList, deviceNic) + deviceNicList = append(deviceNicList, deviceNic) - return deviceNicList - } + return deviceNicList // return bootDeviceList } return nil @@ -1872,20 +1870,21 @@ func flattenDiskAddress(pr *config.DiskAddress) []map[string]interface{} { } func flattenDiskBusType(pr *config.DiskBusType) string { + const two, three, four, five, six = 2, 3, 4, 5, 6 if pr != nil { - if *pr == config.DiskBusType(2) { + if *pr == config.DiskBusType(two) { return "SCSI" } - if *pr == config.DiskBusType(3) { + if *pr == config.DiskBusType(three) { return "IDE" } - if *pr == config.DiskBusType(4) { + if *pr == config.DiskBusType(four) { return "PCI" } - if *pr == config.DiskBusType(5) { + if *pr == config.DiskBusType(five) { return "SATA" } - if *pr == config.DiskBusType(6) { + if *pr == config.DiskBusType(six) { return "SPAPR" } } @@ -1895,17 +1894,17 @@ func flattenDiskBusType(pr *config.DiskBusType) string { func flattenBootDeviceType(pr []config.BootDeviceType) []interface{} { if len(pr) > 0 { bootDeviceList := make([]interface{}, len(pr)) - + const two, three, four = 2, 3, 4 for k, v := range pr { ss := new(string) - if v == config.BootDeviceType(2) { + if v == config.BootDeviceType(two) { ss = utils.StringPtr("CDROM") } - if v == config.BootDeviceType(3) { + if v == config.BootDeviceType(three) { ss = utils.StringPtr("DISK") } - if v == config.BootDeviceType(4) { + if v == config.BootDeviceType(four) { ss = utils.StringPtr("NETWORK") } bootDeviceList[k] = ss @@ -1922,7 +1921,7 @@ func flattenNvramDevice(pr *config.NvramDevice) []map[string]interface{} { rams := make(map[string]interface{}) if pr.BackingStorageInfo != nil { - rams["backing_storage_info"] = flattenVmDisk(pr.BackingStorageInfo) + rams["backing_storage_info"] = flattenVMDisk(pr.BackingStorageInfo) } ramList = append(ramList, rams) return ramList @@ -1930,7 +1929,7 @@ func flattenNvramDevice(pr *config.NvramDevice) []map[string]interface{} { return nil } -func flattenVmDisk(pr *config.VmDisk) []map[string]interface{} { +func flattenVMDisk(pr *config.VmDisk) []map[string]interface{} { if pr != nil { vmDiskList := make([]map[string]interface{}, 0) @@ -1940,10 +1939,10 @@ func flattenVmDisk(pr *config.VmDisk) []map[string]interface{} { disks["disk_size_bytes"] = pr.DiskSizeBytes } if pr.StorageContainer != nil { - disks["storage_container"] = flattenVmDiskContainerReference(pr.StorageContainer) + disks["storage_container"] = flattenVMDiskContainerReference(pr.StorageContainer) } if pr.StorageConfig != nil { - disks["storage_config"] = flattenVmDiskStorageConfig(pr.StorageConfig) + disks["storage_config"] = flattenVMDiskStorageConfig(pr.StorageConfig) } if pr.DataSource != nil { disks["data_source"] = flattenDataSource(pr.DataSource) @@ -1961,7 +1960,7 @@ func flattenVmDisk(pr *config.VmDisk) []map[string]interface{} { return nil } -func flattenVmDiskContainerReference(ref *config.VmDiskContainerReference) []map[string]interface{} { +func flattenVMDiskContainerReference(ref *config.VmDiskContainerReference) []map[string]interface{} { if ref != nil { refList := make([]map[string]interface{}, 0) @@ -1977,7 +1976,7 @@ func flattenVmDiskContainerReference(ref *config.VmDiskContainerReference) []map return nil } -func flattenVmDiskStorageConfig(ref *config.VmDiskStorageConfig) []map[string]interface{} { +func flattenVMDiskStorageConfig(ref *config.VmDiskStorageConfig) []map[string]interface{} { if ref != nil { refList := make([]map[string]interface{}, 0) @@ -2024,7 +2023,7 @@ func flattenOneOfDataSourceReference(pr *config.OneOfDataSourceReference) []map[ vmDiskObj["disk_address"] = flattenDiskAddress(vmDiskVal.DiskAddress) vmDiskObj["disk_ext_id"] = vmDiskVal.DiskExtId - vmDiskObj["vm_reference"] = flattenVmReference(vmDiskVal.VmReference) + vmDiskObj["vm_reference"] = flattenVMReference(vmDiskVal.VmReference) vmDiskObjList = append(vmDiskObjList, vmDiskObj) vmDiskRef["vm_disk_reference"] = vmDiskObjList @@ -2049,7 +2048,7 @@ func flattenOneOfDataSourceReference(pr *config.OneOfDataSourceReference) []map[ return nil } -func flattenVmReference(ref *config.VmReference) []map[string]interface{} { +func flattenVMReference(ref *config.VmReference) []map[string]interface{} { if ref != nil { refList := make([]map[string]interface{}, 0) @@ -2105,7 +2104,7 @@ func flattenApcConfig(pr *config.ApcConfig) []map[string]interface{} { cfg["is_apc_enabled"] = pr.IsApcEnabled } if pr.CpuModel != nil { - cfg["cpu_model"] = flattenCpuModelReference(pr.CpuModel) + cfg["cpu_model"] = flattenCPUModelReference(pr.CpuModel) } cfgList = append(cfgList, cfg) @@ -2114,7 +2113,7 @@ func flattenApcConfig(pr *config.ApcConfig) []map[string]interface{} { return nil } -func flattenCpuModelReference(ref *config.CpuModelReference) []map[string]interface{} { +func flattenCPUModelReference(ref *config.CpuModelReference) []map[string]interface{} { if ref != nil { refList := make([]map[string]interface{}, 0) @@ -2178,7 +2177,7 @@ func flattenDisk(pr []config.Disk) []interface{} { disk["tenant_id"] = v.TenantId } if v.Links != nil { - disk["links"] = flattenApiLink(v.Links) + disk["links"] = flattenAPILink(v.Links) } if v.ExtId != nil { disk["ext_id"] = v.ExtId @@ -2218,10 +2217,10 @@ func flattenOneOfDiskBackingInfo(pr *config.OneOfDiskBackingInfo) []map[string]i vmDiskObj["disk_size_bytes"] = vmDiskVal.DiskSizeBytes } if vmDiskVal.StorageContainer != nil { - vmDiskObj["storage_container"] = flattenVmDiskContainerReference(vmDiskVal.StorageContainer) + vmDiskObj["storage_container"] = flattenVMDiskContainerReference(vmDiskVal.StorageContainer) } if vmDiskVal.StorageConfig != nil { - vmDiskObj["storage_config"] = flattenVmDiskStorageConfig(vmDiskVal.StorageConfig) + vmDiskObj["storage_config"] = flattenVMDiskStorageConfig(vmDiskVal.StorageConfig) } if vmDiskVal.DataSource != nil { vmDiskObj["data_source"] = flattenDataSource(vmDiskVal.DataSource) @@ -2240,22 +2239,21 @@ func flattenOneOfDiskBackingInfo(pr *config.OneOfDiskBackingInfo) []map[string]i backingInfoList = append(backingInfoList, backingInfoObj) return backingInfoList - } else { - volumeGroupObj := make(map[string]interface{}) - volumeGroupObjList := make([]map[string]interface{}, 0) - volumeGroupVal := pr.GetValue().(config.ADSFVolumeGroupReference) + } + volumeGroupObj := make(map[string]interface{}) + volumeGroupObjList := make([]map[string]interface{}, 0) + volumeGroupVal := pr.GetValue().(config.ADSFVolumeGroupReference) - if volumeGroupVal.VolumeGroupExtId != nil { - volumeGroupObj["volume_group_ext_id"] = volumeGroupVal.VolumeGroupExtId - } + if volumeGroupVal.VolumeGroupExtId != nil { + volumeGroupObj["volume_group_ext_id"] = volumeGroupVal.VolumeGroupExtId + } - volumeGroupObjList = append(volumeGroupObjList, volumeGroupObj) + volumeGroupObjList = append(volumeGroupObjList, volumeGroupObj) - volumeGroupInfo["adfs_volume_group_reference"] = volumeGroupObjList - volumeGroupInfoList = append(volumeGroupInfoList, volumeGroupInfo) + volumeGroupInfo["adfs_volume_group_reference"] = volumeGroupObjList + volumeGroupInfoList = append(volumeGroupInfoList, volumeGroupInfo) - backingInfoList = volumeGroupInfoList - } + backingInfoList = volumeGroupInfoList return backingInfoList } return nil @@ -2272,7 +2270,7 @@ func flattenCdRom(pr []config.CdRom) []interface{} { cd["tenant_id"] = v.TenantId } if v.Links != nil { - cd["links"] = flattenApiLink(v.Links) + cd["links"] = flattenAPILink(v.Links) } if v.ExtId != nil { cd["ext_id"] = v.ExtId @@ -2281,7 +2279,7 @@ func flattenCdRom(pr []config.CdRom) []interface{} { cd["disk_address"] = flattenCdRomAddress(v.DiskAddress) } if v.BackingInfo != nil { - cd["backing_info"] = flattenVmDisk(v.BackingInfo) + cd["backing_info"] = flattenVMDisk(v.BackingInfo) } if v.IsoType != nil { cd["iso_type"] = flattenIsoType(v.IsoType) @@ -2347,7 +2345,7 @@ func flattenNic(nic []config.Nic) []interface{} { nics["tenant_id"] = v.TenantId } if v.Links != nil { - nics["links"] = flattenApiLink(v.Links) + nics["links"] = flattenAPILink(v.Links) } if v.ExtId != nil { nics["ext_id"] = v.ExtId @@ -2442,16 +2440,17 @@ func flattenNicNetworkInfo(pr *config.NicNetworkInfo) []map[string]interface{} { func flattenNicType(pr *config.NicType) string { if pr != nil { - if *pr == config.NicType(2) { + const two, three, four, five = 2, 3, 4, 5 + if *pr == config.NicType(two) { return "NORMAL_NIC" } - if *pr == config.NicType(3) { + if *pr == config.NicType(three) { return "DIRECT_NIC" } - if *pr == config.NicType(4) { + if *pr == config.NicType(four) { return "NETWORK_FUNCTION_NIC" } - if *pr == config.NicType(5) { + if *pr == config.NicType(five) { return "SPAN_DESTINATION_NIC" } } @@ -2476,13 +2475,14 @@ func flattenNetworkFunctionChainReference(ref *config.NetworkFunctionChainRefere func flattenNetworkFunctionNicType(pr *config.NetworkFunctionNicType) string { if pr != nil { - if *pr == config.NetworkFunctionNicType(2) { + const two, three, four = 2, 3, 4 + if *pr == config.NetworkFunctionNicType(two) { return "INGRESS" } - if *pr == config.NetworkFunctionNicType(3) { + if *pr == config.NetworkFunctionNicType(three) { return "EGRESS" } - if *pr == config.NetworkFunctionNicType(4) { + if *pr == config.NetworkFunctionNicType(four) { return "TAP" } } @@ -2507,10 +2507,11 @@ func flattenSubnetReference(ref *config.SubnetReference) []map[string]interface{ func flattenVlanMode(pr *config.VlanMode) string { if pr != nil { - if *pr == config.VlanMode(2) { + const two, three = 2, 3 + if *pr == config.VlanMode(two) { return "ACCESS" } - if *pr == config.VlanMode(3) { + if *pr == config.VlanMode(three) { return "TRUNK" } } @@ -2602,7 +2603,7 @@ func flattenGpu(pr []config.Gpu) []interface{} { gpu["tenant_id"] = v.TenantId } if v.Links != nil { - gpu["links"] = flattenApiLink(v.Links) + gpu["links"] = flattenAPILink(v.Links) } if v.ExtId != nil { gpu["ext_id"] = v.ExtId @@ -2658,13 +2659,14 @@ func flattenGpuMode(pr *config.GpuMode) string { func flattenGpuVendor(pr *config.GpuVendor) string { if pr != nil { - if *pr == config.GpuVendor(2) { + const two, three, four = 2, 3, 4 + if *pr == config.GpuVendor(two) { return "NVIDIA" } - if *pr == config.GpuVendor(3) { + if *pr == config.GpuVendor(three) { return "INTEL" } - if *pr == config.GpuVendor(4) { + if *pr == config.GpuVendor(four) { return "AMD" } } @@ -2706,7 +2708,7 @@ func flattenSerialPort(pr []config.SerialPort) []interface{} { port["tenant_id"] = v.TenantId } if v.Links != nil { - port["links"] = flattenApiLink(v.Links) + port["links"] = flattenAPILink(v.Links) } if v.ExtId != nil { port["ext_id"] = v.ExtId @@ -2726,13 +2728,14 @@ func flattenSerialPort(pr []config.SerialPort) []interface{} { func flattenProtectionType(pr *config.ProtectionType) string { if pr != nil { - if *pr == config.ProtectionType(2) { + const two, three, four = 2, 3, 4 + if *pr == config.ProtectionType(two) { return "UNPROTECTED" } - if *pr == config.ProtectionType(3) { + if *pr == config.ProtectionType(three) { return "PD_PROTECTED" } - if *pr == config.ProtectionType(4) { + if *pr == config.ProtectionType(four) { return "RULE_PROTECTED" } } @@ -2770,7 +2773,7 @@ func flattenPolicyReference(ref *config.PolicyReference) []map[string]interface{ return nil } -func flattenApiLink(pr []response.ApiLink) []interface{} { +func flattenAPILink(pr []response.ApiLink) []interface{} { if len(pr) > 0 { links := make([]interface{}, len(pr)) diff --git a/nutanix/services/vmmv2/data_source_nutanix_virtual_machines_v2.go b/nutanix/services/vmmv2/data_source_nutanix_virtual_machines_v2.go index c060614ff..db6e2bf51 100644 --- a/nutanix/services/vmmv2/data_source_nutanix_virtual_machines_v2.go +++ b/nutanix/services/vmmv2/data_source_nutanix_virtual_machines_v2.go @@ -1342,7 +1342,7 @@ func flattenVMEntities(vms []config.Vm) []interface{} { vm["update_time"] = t.String() } if v.Source != nil { - vm["source"] = flattenVmSourceReference(v.Source) + vm["source"] = flattenVMSourceReference(v.Source) } if v.NumSockets != nil { vm["num_sockets"] = v.NumSockets @@ -1366,7 +1366,7 @@ func flattenVMEntities(vms []config.Vm) []interface{} { vm["is_cpu_passthrough_enabled"] = v.IsCpuPassthroughEnabled } if v.EnabledCpuFeatures != nil { - vm["enabled_cpu_features"] = flattenCpuFeature(v.EnabledCpuFeatures) + vm["enabled_cpu_features"] = flattenCPUFeature(v.EnabledCpuFeatures) } if v.IsMemoryOvercommitEnabled != nil { vm["is_memory_overcommit_enabled"] = v.IsMemoryOvercommitEnabled @@ -1411,7 +1411,7 @@ func flattenVMEntities(vms []config.Vm) []interface{} { vm["is_branding_enabled"] = v.IsBrandingEnabled } if v.BootConfig != nil { - vm["boot_config"] = flattenOneOfVmBootConfig(v.BootConfig) + vm["boot_config"] = flattenOneOfVMBootConfig(v.BootConfig) } if v.IsVgaConsoleEnabled != nil { vm["is_vga_console_enabled"] = v.IsVgaConsoleEnabled diff --git a/nutanix/services/vmmv2/resource_nutanix_image_placement_v2.go b/nutanix/services/vmmv2/resource_nutanix_image_placement_v2.go index 6cae769c4..10783fbf6 100644 --- a/nutanix/services/vmmv2/resource_nutanix_image_placement_v2.go +++ b/nutanix/services/vmmv2/resource_nutanix_image_placement_v2.go @@ -472,7 +472,7 @@ func expandEntityFilter(pr interface{}) *import7.Filter { prI := pr.([]interface{}) val := prI[0].(map[string]interface{}) - entity_filter := &import7.Filter{} + entityFilter := &import7.Filter{} // entity_filter.ObjectType_ = utils.StringPtr("vmm.v4.r0.b1.images.config.Filter") @@ -483,19 +483,19 @@ func expandEntityFilter(pr interface{}) *import7.Filter { } pVal := subMap[ftype.(string)] p := import7.FilterMatchType(pVal.(int)) - entity_filter.Type = &p + entityFilter.Type = &p } - if category_ext_ids, ok := val["category_ext_ids"]; ok { - categoriesList := category_ext_ids.([]interface{}) + if categoryExtIds, ok := val["category_ext_ids"]; ok { + categoriesList := categoryExtIds.([]interface{}) categories := make([]string, len(categoriesList)) for k, v := range categoriesList { categories[k] = v.(string) } - entity_filter.CategoryExtIds = categories + entityFilter.CategoryExtIds = categories } - return entity_filter + return entityFilter } return nil } diff --git a/nutanix/services/vmmv2/resource_nutanix_image_v2.go b/nutanix/services/vmmv2/resource_nutanix_image_v2.go index 07b4a0b4d..bd8cc79c9 100644 --- a/nutanix/services/vmmv2/resource_nutanix_image_v2.go +++ b/nutanix/services/vmmv2/resource_nutanix_image_v2.go @@ -506,7 +506,7 @@ func expandOneOfImageSource(pr interface{}) *import5.OneOfImageSource { urlSrcInput.ShouldAllowInsecureUrl = utils.BoolPtr(shouldAllow.(bool)) } if basicAuth, ok := urlMap["basic_auth"]; ok && len(basicAuth.([]interface{})) > 0 { - urlSrcInput.BasicAuth = expandUrlBasicAuth(basicAuth) + urlSrcInput.BasicAuth = expandURLBasicAuth(basicAuth) } imgSrc.SetValue(*urlSrcInput) } @@ -535,7 +535,7 @@ func expandOneOfImageSource(pr interface{}) *import5.OneOfImageSource { return nil } -func expandUrlBasicAuth(pr interface{}) *import5.UrlBasicAuth { +func expandURLBasicAuth(pr interface{}) *import5.UrlBasicAuth { if pr != nil { prI := pr.([]interface{}) val := prI[0].(map[string]interface{}) diff --git a/nutanix/services/vmmv2/resource_nutanix_ngt_installation_v2.go b/nutanix/services/vmmv2/resource_nutanix_ngt_installation_v2.go index b4bac7a97..91a3ba47a 100644 --- a/nutanix/services/vmmv2/resource_nutanix_ngt_installation_v2.go +++ b/nutanix/services/vmmv2/resource_nutanix_ngt_installation_v2.go @@ -168,12 +168,12 @@ func ResourceNutanixNGTInstallationV2() *schema.Resource { func ResourceNutanixNGTInstallationV4Create(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).VmmAPI - vmmExtId := utils.StringPtr(d.Get("ext_id").(string)) + vmmExtID := utils.StringPtr(d.Get("ext_id").(string)) - log.Printf("[DEBUG] vmmExtId : %s", *vmmExtId) + log.Printf("[DEBUG] vmmExtId : %s", *vmmExtID) body := &vmmConfig.GuestToolsInstallConfig{} - readResp, err := conn.VMAPIInstance.GetGuestToolsById(vmmExtId) + readResp, err := conn.VMAPIInstance.GetGuestToolsById(vmmExtID) if err != nil { return diag.Errorf("error while fetching Vm NGT Configuration : %v", err) } @@ -236,7 +236,7 @@ func ResourceNutanixNGTInstallationV4Create(ctx context.Context, d *schema.Resou aJSON, _ := json.Marshal(body) log.Printf("[DEBUG] Installing NGT Request Body: %s", aJSON) - installResp, err := conn.VMAPIInstance.InstallVmGuestTools(vmmExtId, body, args) + installResp, err := conn.VMAPIInstance.InstallVmGuestTools(vmmExtID, body, args) if err != nil { return diag.Errorf("error while installing gest tools : %v", err) } diff --git a/nutanix/services/vmmv2/resource_nutanix_template_deploy_v2.go b/nutanix/services/vmmv2/resource_nutanix_template_deploy_v2.go index 49532bf46..7ed4167de 100644 --- a/nutanix/services/vmmv2/resource_nutanix_template_deploy_v2.go +++ b/nutanix/services/vmmv2/resource_nutanix_template_deploy_v2.go @@ -260,7 +260,7 @@ func ResourceNutanixTemplateDeployV2Create(ctx context.Context, d *schema.Resour body.ClusterReference = utils.StringPtr(clsRef.(string)) } if overrideCfg, ok := d.GetOk("override_vm_config_map"); ok { - body.OverrideVmConfigMap = expandVmConfigOverride(overrideCfg) + body.OverrideVmConfigMap = expandVMConfigOverride(overrideCfg) } resp, err := conn.TemplatesAPIInstance.DeployTemplate(utils.StringPtr(extID.(string)), body) @@ -311,7 +311,7 @@ func ResourceNutanixTemplateDeployV2Delete(ctx context.Context, d *schema.Resour return nil } -func expandVmConfigOverride(pr interface{}) map[string]import5.VmConfigOverride { +func expandVMConfigOverride(pr interface{}) map[string]import5.VmConfigOverride { if len(pr.([]interface{})) > 0 { // vmcfg := import5.VmConfigOverride{} @@ -480,9 +480,9 @@ func expandIPv4Info(ipv4Info interface{}) *config.Ipv4Info { ipv4InfoObj := &config.Ipv4Info{} ipv4InfoData := ipv4Info.([]interface{})[0].(map[string]interface{}) - if learnedIpAddresses, ok := ipv4InfoData["learned_ip_addresses"]; ok { - ipAddressesList := make([]import4.IPv4Address, len(learnedIpAddresses.([]interface{}))) - for i, learnedIp := range learnedIpAddresses.([]interface{}) { + if learnedIPAddresses, ok := ipv4InfoData["learned_ip_addresses"]; ok { + ipAddressesList := make([]import4.IPv4Address, len(learnedIPAddresses.([]interface{}))) + for i, learnedIp := range learnedIPAddresses.([]interface{}) { learnedIpData := learnedIp.(map[string]interface{}) ipAddressesList[i] = import4.IPv4Address{ Value: utils.StringPtr(learnedIpData["value"].(string)), diff --git a/nutanix/services/vmmv2/resource_nutanix_template_v2.go b/nutanix/services/vmmv2/resource_nutanix_template_v2.go index 37dbea66e..931b7a75c 100644 --- a/nutanix/services/vmmv2/resource_nutanix_template_v2.go +++ b/nutanix/services/vmmv2/resource_nutanix_template_v2.go @@ -242,7 +242,7 @@ func ResourceNutanixTemplatesV2Read(ctx context.Context, d *schema.ResourceData, if err := d.Set("tenant_id", getResp.TenantId); err != nil { return diag.FromErr(err) } - if err := d.Set("links", flattenApiLink(getResp.Links)); err != nil { + if err := d.Set("links", flattenAPILink(getResp.Links)); err != nil { return diag.FromErr(err) } if err := d.Set("ext_id", getResp.ExtId); err != nil { @@ -366,9 +366,8 @@ func ResourceNutanixTemplatesV2Update(ctx context.Context, d *schema.ResourceDat if versionId != nil || utils.StringValue(versionId) != "" { log.Printf("[DEBUG] Template version Id provided in tf configuration") - break } - log.Printf("[DEBUG] Template version Id not provided in tf configuration, will use the latest version as defualt") + log.Printf("[DEBUG] Template version Id not provided in tf configuration, will use the latest version as default") templateVersions, errTempVersion := conn.TemplatesAPIInstance.ListTemplateVersions(utils.StringPtr(d.Id()), nil, nil, nil, nil, nil) if errTempVersion != nil { return diag.Errorf("error while fetching template versions : %v", errTempVersion) @@ -389,6 +388,10 @@ func ResourceNutanixTemplatesV2Update(ctx context.Context, d *schema.ResourceDat if errVs != nil { return diag.Errorf("error while setting version source : %v", err) } + case vmmContent.TemplateVmReference: + log.Printf("[DEBUG] Template vm reference type, no need to set version id") + default: + log.Printf("[DEBUG] Template version reference type not found") } } diff --git a/nutanix/services/vmmv2/resource_nutanix_virtual_machine_v2.go b/nutanix/services/vmmv2/resource_nutanix_virtual_machine_v2.go index c24c9c9d4..b31c663f4 100644 --- a/nutanix/services/vmmv2/resource_nutanix_virtual_machine_v2.go +++ b/nutanix/services/vmmv2/resource_nutanix_virtual_machine_v2.go @@ -1696,7 +1696,7 @@ func ResourceNutanixVirtualMachineV2Read(ctx context.Context, d *schema.Resource return diag.FromErr(err) } } - if err := d.Set("source", flattenVmSourceReference(getResp.Source)); err != nil { + if err := d.Set("source", flattenVMSourceReference(getResp.Source)); err != nil { return diag.FromErr(err) } if err := d.Set("num_sockets", getResp.NumSockets); err != nil { @@ -1720,7 +1720,7 @@ func ResourceNutanixVirtualMachineV2Read(ctx context.Context, d *schema.Resource if err := d.Set("is_cpu_passthrough_enabled", getResp.IsCpuPassthroughEnabled); err != nil { return diag.FromErr(err) } - if err := d.Set("enabled_cpu_features", flattenCpuFeature(getResp.EnabledCpuFeatures)); err != nil { + if err := d.Set("enabled_cpu_features", flattenCPUFeature(getResp.EnabledCpuFeatures)); err != nil { return diag.FromErr(err) } if err := d.Set("is_memory_overcommit_enabled", getResp.IsMemoryOvercommitEnabled); err != nil { @@ -1768,7 +1768,7 @@ func ResourceNutanixVirtualMachineV2Read(ctx context.Context, d *schema.Resource if err := d.Set("is_branding_enabled", getResp.IsBrandingEnabled); err != nil { return diag.FromErr(err) } - if err := d.Set("boot_config", flattenOneOfVmBootConfig(getResp.BootConfig)); err != nil { + if err := d.Set("boot_config", flattenOneOfVMBootConfig(getResp.BootConfig)); err != nil { return diag.FromErr(err) } if err := d.Set("is_vga_console_enabled", getResp.IsVgaConsoleEnabled); err != nil { diff --git a/nutanix/services/vmmv2/resource_nutanix_vms_clone_v2.go b/nutanix/services/vmmv2/resource_nutanix_vms_clone_v2.go index 7c9d7b025..3605d9592 100644 --- a/nutanix/services/vmmv2/resource_nutanix_vms_clone_v2.go +++ b/nutanix/services/vmmv2/resource_nutanix_vms_clone_v2.go @@ -1429,10 +1429,10 @@ func ResourceNutanixVmCloneV2Read(ctx context.Context, d *schema.ResourceData, m if err := d.Set("guest_customization", flattenGuestCustomizationParams(getResp.GuestCustomization)); err != nil { return diag.FromErr(err) } - if err := d.Set("boot_config", flattenOneOfVmBootConfig(getResp.BootConfig)); err != nil { + if err := d.Set("boot_config", flattenOneOfVMBootConfig(getResp.BootConfig)); err != nil { return diag.FromErr(err) } - if err := d.Set("links", flattenApiLink(getResp.Links)); err != nil { + if err := d.Set("links", flattenAPILink(getResp.Links)); err != nil { return diag.FromErr(err) } if err := d.Set("description", getResp.Description); err != nil { @@ -1450,7 +1450,7 @@ func ResourceNutanixVmCloneV2Read(ctx context.Context, d *schema.ResourceData, m return diag.FromErr(err) } } - if err := d.Set("source", flattenVmSourceReference(getResp.Source)); err != nil { + if err := d.Set("source", flattenVMSourceReference(getResp.Source)); err != nil { return diag.FromErr(err) } if err := d.Set("num_numa_nodes", getResp.NumNumaNodes); err != nil { @@ -1462,7 +1462,7 @@ func ResourceNutanixVmCloneV2Read(ctx context.Context, d *schema.ResourceData, m if err := d.Set("is_cpu_passthrough_enabled", getResp.IsCpuPassthroughEnabled); err != nil { return diag.FromErr(err) } - if err := d.Set("enabled_cpu_features", flattenCpuFeature(getResp.EnabledCpuFeatures)); err != nil { + if err := d.Set("enabled_cpu_features", flattenCPUFeature(getResp.EnabledCpuFeatures)); err != nil { return diag.FromErr(err) } if err := d.Set("is_memory_overcommit_enabled", getResp.IsMemoryOvercommitEnabled); err != nil { diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_category_details_v2.go b/nutanix/services/volumesv2/data_source_nutanix_volume_category_details_v2.go index 24a9c36c3..3113f7c07 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_category_details_v2.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_category_details_v2.go @@ -18,7 +18,7 @@ func DatasourceNutanixVolumeCategoryDetailsV2() *schema.Resource { return &schema.Resource{ ReadContext: DatasourceNutanixVolumeCategoryDetailsV2Read, - Description: "Query the category details that are associated with the Volume Group identified by {volumeGroupExtId}.", + Description: "Query the category details that are associated with the Volume Group identified by {volumeGroupExtID}.", Schema: map[string]*schema.Schema{ "ext_id": { Description: "The external identifier of the Volume Group.", @@ -77,7 +77,7 @@ func DatasourceNutanixVolumeCategoryDetailsV2Read(ctx context.Context, d *schema var page, limit *int - volumeGroupExtId := d.Get("ext_id") + volumeGroupExtID := d.Get("ext_id") // initialize the query parameters if pagef, ok := d.GetOk("page"); ok { @@ -92,7 +92,7 @@ func DatasourceNutanixVolumeCategoryDetailsV2Read(ctx context.Context, d *schema } // get the volume groups response - resp, err := conn.VolumeAPIInstance.ListCategoryAssociationsByVolumeGroupId(utils.StringPtr(volumeGroupExtId.(string)), page, limit) + resp, err := conn.VolumeAPIInstance.ListCategoryAssociationsByVolumeGroupId(utils.StringPtr(volumeGroupExtID.(string)), page, limit) if err != nil { var errordata map[string]interface{} diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_disk_v2.go b/nutanix/services/volumesv2/data_source_nutanix_volume_disk_v2.go index 25dcf44d0..05187a937 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_disk_v2.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_disk_v2.go @@ -15,7 +15,7 @@ import ( // Get the details of a Volume Disk. func DatasourceNutanixVolumeDiskV2() *schema.Resource { return &schema.Resource{ - Description: "Query the Volume Disk identified by {extId} in the Volume Group identified by {volumeGroupExtId}.", + Description: "Query the Volume Disk identified by {extId} in the Volume Group identified by {volumeGroupExtID}.", ReadContext: DatasourceNutanixVolumeDiskV2Read, Schema: map[string]*schema.Schema{ "ext_id": { @@ -134,10 +134,10 @@ func DatasourceNutanixVolumeDiskV2() *schema.Resource { func DatasourceNutanixVolumeDiskV2Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).VolumeAPI - volumeGroupExtId := d.Get("volume_group_ext_id") + volumeGroupExtID := d.Get("volume_group_ext_id") volumeDiskExtID := d.Get("ext_id") - resp, err := conn.VolumeAPIInstance.GetVolumeDiskById(utils.StringPtr(volumeGroupExtId.(string)), utils.StringPtr(volumeDiskExtID.(string))) + resp, err := conn.VolumeAPIInstance.GetVolumeDiskById(utils.StringPtr(volumeGroupExtID.(string)), utils.StringPtr(volumeDiskExtID.(string))) if err != nil { var errordata map[string]interface{} diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_disks_v2.go b/nutanix/services/volumesv2/data_source_nutanix_volume_disks_v2.go index 4687e3adf..f6d4e39da 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_disks_v2.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_disks_v2.go @@ -37,9 +37,8 @@ func DatasourceNutanixVolumeDisksV2() *schema.Resource { Optional: true, }, "filter": { - Description: "A URL query parameter that allows clients to filter a collection of resources. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response. Expression specified with the $filter must conform to the OData V4.01 URL conventions. For example, filter '$filter=name eq 'karbon-ntnx-1.0' would filter the result on cluster name 'karbon-ntnx1.0', filter '$filter=startswith(name, 'C')' would filter on cluster name starting with 'C'. The filter can be applied to the following fields: storageContainerId", - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, }, "orderby": { Description: "A URL query parameter that allows clients to specify the sort criteria for the returned list of objects. Resources can be sorted in ascending order using asc or descending order using desc. If asc or desc are not specified, the resources will be sorted in ascending order by default. For example, '$orderby=templateName desc' would get all templates sorted by templateName in descending order. The orderby can be applied to the following fields: diskSizeBytes", @@ -169,7 +168,6 @@ func DatasourceNutanixVolumeDisksV2() *schema.Resource { } func DatasourceNutanixVolumeDisksV2Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { - conn := meta.(*conns.Client).VolumeAPI var filter, orderBy, selects *string diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_group_iscsi_clients_v2.go b/nutanix/services/volumesv2/data_source_nutanix_volume_group_iscsi_clients_v2.go index 42e1ca58d..18cf44c09 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_group_iscsi_clients_v2.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_group_iscsi_clients_v2.go @@ -35,7 +35,6 @@ func DatasourceNutanixVolumeGroupIscsiClientsV2() *schema.Resource { Optional: true, }, "filter": { - Description: "A URL query parameter that allows clients to filter a collection of resources. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response. Expression specified with the $filter must conform to the OData V4.01 URL conventions. For example, filter '$filter=name eq 'karbon-ntnx-1.0' would filter the result on cluster name 'karbon-ntnx1.0', filter '$filter=startswith(name, 'C')' would filter on cluster name starting with 'C'. The filter can be applied to the following fields: clusterReference, extId", Type: schema.TypeString, Optional: true, }, @@ -45,9 +44,8 @@ func DatasourceNutanixVolumeGroupIscsiClientsV2() *schema.Resource { Optional: true, }, "expand": { - Description: "A URL query parameter that allows clients to request related resources when a resource that satisfies a particular request is retrieved. Each expanded item is evaluated relative to the entity containing the property being expanded. Other query options can be applied to an expanded property by appending a semicolon-separated list of query options, enclosed in parentheses, to the property name. Permissible system query options are $filter, $select and $orderby. The following expansion keys are supported. The expand can be applied to the following fields: iscsiClient", - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, }, "select": { Description: "A URL query parameter that allows clients to request a specific set of properties for each entity or complex type. Expression specified with the $select must conform to the OData V4.01 URL conventions. If a $select expression consists of a single select item that is an asterisk (i.e., *), then all properties on the matching resource will be returned. The select can be applied to the following fields: clusterReference, extId", @@ -160,7 +158,6 @@ func DatasourceNutanixVolumeGroupIscsiClientsV2Read(ctx context.Context, d *sche // extract the volume groups data from the response if diskResp != nil { - // set the volume groups iscsi clients data in the terraform resource if err := d.Set("iscsi_clients", flattenVolumeIscsiClientsEntities(diskResp.GetValue().([]volumesClient.IscsiClientAttachment))); err != nil { return diag.FromErr(err) @@ -187,7 +184,6 @@ func flattenVolumeIscsiClientsEntities(iscsiClientAttachments []volumesClient.Is } iscsiClientList[k] = iscsiClient - } return iscsiClientList } diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_group_vms_v2.go b/nutanix/services/volumesv2/data_source_nutanix_volume_group_vms_v2.go index 130af789c..22bef274b 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_group_vms_v2.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_group_vms_v2.go @@ -2,7 +2,6 @@ package volumesv2 import ( "context" - "encoding/json" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -36,9 +35,8 @@ func DataSourceNutanixVolumeGroupVmsV2() *schema.Resource { Optional: true, }, "filter": { - Description: "A URL query parameter that allows clients to filter a collection of resources. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response. Expression specified with the $filter must conform to the OData V4.01 URL conventions. For example, filter '$filter=name eq 'karbon-ntnx-1.0' would filter the result on cluster name 'karbon-ntnx1.0', filter '$filter=startswith(name, 'C')' would filter on cluster name starting with 'C'. The filter can be applied to the following fields: extId", - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, }, "orderby": { Description: "A URL query parameter that allows clients to specify the sort criteria for the returned list of objects. Resources can be sorted in ascending order using asc or descending order using desc. If asc or desc are not specified, the resources will be sorted in ascending order by default. For example, '$orderby=templateName desc' would get all templates sorted by templateName in descending order. The orderby can be applied to the following fields: extId", @@ -120,17 +118,8 @@ func DataSourceNutanixVolumeGroupVmsV4Read(ctx context.Context, d *schema.Resour // get the volume groups response resp, err := conn.VolumeAPIInstance.ListVmAttachmentsByVolumeGroupId(utils.StringPtr(volumeGroupExtID.(string)), page, limit, filter, orderBy) - if err != nil { - var errordata map[string]interface{} - e := json.Unmarshal([]byte(err.Error()), &errordata) - if e != nil { - return diag.FromErr(e) - } - data := errordata["data"].(map[string]interface{}) - errorList := data["error"].([]interface{}) - errorMessage := errorList[0].(map[string]interface{}) - return diag.Errorf("error while fetching volumes : %v", errorMessage["message"]) + return diag.Errorf("error while fetching volumes : %v", err) } vmsAttachmentsResp := resp.Data @@ -153,7 +142,6 @@ func DataSourceNutanixVolumeGroupVmsV4Read(ctx context.Context, d *schema.Resour func flattenVolumeGroupVmsEntities(vms []volumesClient.VmAttachment) []interface{} { if len(vms) > 0 { vmAttachmentList := make([]interface{}, len(vms)) - for k, v := range vms { vmAttachment := make(map[string]interface{}) @@ -161,7 +149,6 @@ func flattenVolumeGroupVmsEntities(vms []volumesClient.VmAttachment) []interface vmAttachment["ext_id"] = v.ExtId } vmAttachmentList[k] = vmAttachment - } return vmAttachmentList } 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 6a9ab26d5..16426e306 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,10 +2,11 @@ package volumesv2_test import ( "fmt" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "os" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" acc "github.com/terraform-providers/terraform-provider-nutanix/nutanix/acctest" diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_groups_v2.go b/nutanix/services/volumesv2/data_source_nutanix_volume_groups_v2.go index c3dde6e3b..caa075f8d 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_groups_v2.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_groups_v2.go @@ -31,9 +31,8 @@ func DatasourceNutanixVolumeGroupsV2() *schema.Resource { Optional: true, }, "filter": { - Description: "A URL query parameter that allows clients to filter a collection of resources. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response. Expression specified with the $filter must conform to the OData V4.01 URL conventions. For example, filter '$filter=name eq 'karbon-ntnx-1.0' would filter the result on cluster name 'karbon-ntnx1.0', filter '$filter=startswith(name, 'C')' would filter on cluster name starting with 'C'. The filter can be applied to the following fields: clusterReference, extId, name", - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, }, "orderby": { Description: "A URL query parameter that allows clients to specify the sort criteria for the returned list of objects. Resources can be sorted in ascending order using asc or descending order using desc. If asc or desc are not specified, the resources will be sorted in ascending order by default. For example, '$orderby=templateName desc' would get all templates sorted by templateName in descending order. The orderby can be applied to the following fields: clusterReference, extId, name", @@ -41,9 +40,8 @@ func DatasourceNutanixVolumeGroupsV2() *schema.Resource { Optional: true, }, "expand": { - Description: "A URL query parameter that allows clients to request related resources when a resource that satisfies a particular request is retrieved. Each expanded item is evaluated relative to the entity containing the property being expanded. Other query options can be applied to an expanded property by appending a semicolon-separated list of query options, enclosed in parentheses, to the property name. Permissible system query options are $filter, $select and $orderby. The following expansion keys are supported. The expand can be applied to the following fields: clusterReference, metadata", - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, }, "select": { Description: "A URL query parameter that allows clients to request a specific set of properties for each entity or complex type. Expression specified with the $select must conform to the OData V4.01 URL conventions. If a $select expression consists of a single select item that is an asterisk (i.e., *), then all properties on the matching resource will be returned. The select can be applied to the following fields: clusterReference, extId, name", diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_iscsi_client_v2.go b/nutanix/services/volumesv2/data_source_nutanix_volume_iscsi_client_v2.go index fc13298d9..e4c052464 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_iscsi_client_v2.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_iscsi_client_v2.go @@ -2,7 +2,6 @@ package volumesv2 import ( "context" - "encoding/json" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -59,7 +58,7 @@ func DatasourceNutanixVolumeIscsiClientV2() *schema.Resource { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "ipv4": SchemaForIpV4ValuePrefixLength(), + "ipv4": SchemaForIPV4ValuePrefixLength(), "ipv6": SchemaForIpV6ValuePrefixLength(), "fqdn": { Description: "A fully qualified domain name that specifies its exact location in the tree hierarchy of the Domain Name System.", @@ -120,21 +119,13 @@ func DatasourceNutanixVolumeIscsiClientV2() *schema.Resource { func DatasourceNutanixVolumeIscsiClientV2Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).VolumeAPI - extId := d.Get("ext_id") + extID := d.Get("ext_id") // get the volume group iscsi clients - resp, err := conn.IscsiClientAPIInstance.GetIscsiClientById(utils.StringPtr(extId.(string))) + resp, err := conn.IscsiClientAPIInstance.GetIscsiClientById(utils.StringPtr(extID.(string))) if err != nil { - var errordata map[string]interface{} - e := json.Unmarshal([]byte(err.Error()), &errordata) - if e != nil { - return diag.FromErr(e) - } - data := errordata["data"].(map[string]interface{}) - errorList := data["error"].([]interface{}) - errorMessage := errorList[0].(map[string]interface{}) - return diag.Errorf("error while fetching Iscsi Client : %v", errorMessage["message"]) + return diag.Errorf("error while fetching Iscsi Client : %v", err) } getResp := resp.Data.GetValue().(volumesClient.IscsiClient) @@ -148,7 +139,7 @@ func DatasourceNutanixVolumeIscsiClientV2Read(ctx context.Context, d *schema.Res if err := d.Set("iscsi_initiator_name", getResp.IscsiInitiatorName); err != nil { return diag.FromErr(err) } - if err := d.Set("iscsi_initiator_network_id", flattenIscsiInitiatorNetworkId(getResp.IscsiInitiatorNetworkId)); err != nil { + if err := d.Set("iscsi_initiator_network_id", flattenIscsiInitiatorNetworkID(getResp.IscsiInitiatorNetworkId)); err != nil { return diag.FromErr(err) } if err := d.Set("enabled_authentications", getResp.EnabledAuthentications); err != nil { diff --git a/nutanix/services/volumesv2/data_source_nutanix_volume_iscsi_clients_v2.go b/nutanix/services/volumesv2/data_source_nutanix_volume_iscsi_clients_v2.go index bf9b14a48..fb2a68eff 100644 --- a/nutanix/services/volumesv2/data_source_nutanix_volume_iscsi_clients_v2.go +++ b/nutanix/services/volumesv2/data_source_nutanix_volume_iscsi_clients_v2.go @@ -2,7 +2,6 @@ package volumesv2 import ( "context" - "encoding/json" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -31,9 +30,8 @@ func DatasourceNutanixVolumeIscsiClientsV2() *schema.Resource { Optional: true, }, "filter": { - Description: "A URL query parameter that allows clients to filter a collection of resources. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response. Expression specified with the $filter must conform to the OData V4.01 URL conventions. For example, filter '$filter=name eq 'karbon-ntnx-1.0' would filter the result on cluster name 'karbon-ntnx1.0', filter '$filter=startswith(name, 'C')' would filter on cluster name starting with 'C'. The filter can be applied to the following fields: clusterReference, extId", - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, }, "orderby": { Description: "A URL query parameter that allows clients to specify the sort criteria for the returned list of objects. Resources can be sorted in ascending order using asc or descending order using desc. If asc or desc are not specified, the resources will be sorted in ascending order by default. For example, '$orderby=templateName desc' would get all templates sorted by templateName in descending order. The orderby can be applied to the following fields: clusterReference, extId", @@ -41,9 +39,8 @@ func DatasourceNutanixVolumeIscsiClientsV2() *schema.Resource { Optional: true, }, "expand": { - Description: "A URL query parameter that allows clients to request related resources when a resource that satisfies a particular request is retrieved. Each expanded item is evaluated relative to the entity containing the property being expanded. Other query options can be applied to an expanded property by appending a semicolon-separated list of query options, enclosed in parentheses, to the property name. Permissible system query options are $filter, $select and $orderby. The following expansion keys are supported. The expand can be applied to the following fields: cluster", - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, }, "select": { Description: "A URL query parameter that allows clients to request a specific set of properties for each entity or complex type. Expression specified with the $select must conform to the OData V4.01 URL conventions. If a $select expression consists of a single select item that is an asterisk (i.e., *), then all properties on the matching resource will be returned. The select can be applied to the following fields: clusterReference, extId", @@ -96,7 +93,7 @@ func DatasourceNutanixVolumeIscsiClientsV2() *schema.Resource { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "ipv4": SchemaForIpV4ValuePrefixLength(), + "ipv4": SchemaForIPV4ValuePrefixLength(), "ipv6": SchemaForIpV6ValuePrefixLength(), "fqdn": { Description: "A fully qualified domain name that specifies its exact location in the tree hierarchy of the Domain Name System.", @@ -200,15 +197,7 @@ func DatasourceNutanixVolumeIscsiClientsV2Read(ctx context.Context, d *schema.Re resp, err := conn.IscsiClientAPIInstance.ListIscsiClients(page, limit, filter, orderBy, expand, selects) if err != nil { - var errordata map[string]interface{} - e := json.Unmarshal([]byte(err.Error()), &errordata) - if e != nil { - return diag.FromErr(e) - } - data := errordata["data"].(map[string]interface{}) - errorList := data["error"].([]interface{}) - errorMessage := errorList[0].(map[string]interface{}) - return diag.Errorf("error while fetching Iscsi Clients : %v", errorMessage["message"]) + return diag.Errorf("error while fetching Iscsi Clients : %v", err) } // // Check if resp is nil before accessing its data @@ -229,7 +218,6 @@ func DatasourceNutanixVolumeIscsiClientsV2Read(ctx context.Context, d *schema.Re // extract the volume groups data from the response if iscsiClientsResp != nil { - // set the volume groups iscsi clients data in the terraform resource if err := d.Set("iscsi_clients", flattenIscsiClientsEntities(iscsiClientsResp.GetValue().([]volumesClient.IscsiClient))); err != nil { return diag.FromErr(err) @@ -242,47 +230,47 @@ func DatasourceNutanixVolumeIscsiClientsV2Read(ctx context.Context, d *schema.Re func flattenIscsiClientsEntities(pr []volumesClient.IscsiClient) []interface{} { if len(pr) > 0 { - iscsi_clients := make([]interface{}, len(pr)) + iscsiClients := make([]interface{}, len(pr)) for k, v := range pr { - iscsi_client := make(map[string]interface{}) + iscsiClient := make(map[string]interface{}) if v.TenantId != nil { - iscsi_client["tenant_id"] = v.TenantId + iscsiClient["tenant_id"] = v.TenantId } if v.ExtId != nil { - iscsi_client["ext_id"] = v.ExtId + iscsiClient["ext_id"] = v.ExtId } if v.Links != nil { - iscsi_client["links"] = flattenLinks(v.Links) + iscsiClient["links"] = flattenLinks(v.Links) } if v.IscsiInitiatorName != nil { - iscsi_client["iscsi_initiator_name"] = v.IscsiInitiatorName + iscsiClient["iscsi_initiator_name"] = v.IscsiInitiatorName } if v.IscsiInitiatorNetworkId != nil { - iscsi_client["iscsi_initiator_network_id"] = flattenIscsiInitiatorNetworkId(v.IscsiInitiatorNetworkId) + iscsiClient["iscsi_initiator_network_id"] = flattenIscsiInitiatorNetworkID(v.IscsiInitiatorNetworkId) } if v.EnabledAuthentications != nil { - iscsi_client["enabled_authentications"] = flattenEnabledAuthentications(v.EnabledAuthentications) + iscsiClient["enabled_authentications"] = flattenEnabledAuthentications(v.EnabledAuthentications) } if v.AttachedTargets != nil { - iscsi_client["attached_targets"] = flattenAttachedTargets(v.AttachedTargets) + iscsiClient["attached_targets"] = flattenAttachedTargets(v.AttachedTargets) } if v.AttachmentSite != nil { - iscsi_client["attachment_site"] = flattenAttachmentSite(v.AttachmentSite) + iscsiClient["attachment_site"] = flattenAttachmentSite(v.AttachmentSite) } if v.ClusterReference != nil { - iscsi_client["cluster_reference"] = v.ClusterReference + iscsiClient["cluster_reference"] = v.ClusterReference } // Attribute not present in the response of GA SDK // if v.TargetParams != nil { // iscsi_client["attached_targets"] = flattenAttachedTargets(v.TargetParams) // } - iscsi_clients[k] = iscsi_client + iscsiClients[k] = iscsiClient } - return iscsi_clients + return iscsiClients } return nil } @@ -319,14 +307,14 @@ func flattenAttachedTargets(targetParam []volumesClient.TargetParam) []interface return nil } -func flattenIscsiInitiatorNetworkId(iPAddressOrFQDN *config.IPAddressOrFQDN) []interface{} { +func flattenIscsiInitiatorNetworkID(iPAddressOrFQDN *config.IPAddressOrFQDN) []interface{} { if iPAddressOrFQDN != nil { ipAddressOrFQDN := make(map[string]interface{}) if iPAddressOrFQDN.Ipv4 != nil { - ipAddressOrFQDN["ipv4"] = flattenIp4Address(iPAddressOrFQDN.Ipv4) + ipAddressOrFQDN["ipv4"] = flattenIP4Address(iPAddressOrFQDN.Ipv4) } if iPAddressOrFQDN.Ipv6 != nil { - ipAddressOrFQDN["ipv6"] = flattenIp6Address(iPAddressOrFQDN.Ipv6) + ipAddressOrFQDN["ipv6"] = flattenIP6Address(iPAddressOrFQDN.Ipv6) } if iPAddressOrFQDN.Fqdn != nil { ipAddressOrFQDN["fqdn"] = flattenFQDN(iPAddressOrFQDN.Fqdn) @@ -336,7 +324,7 @@ func flattenIscsiInitiatorNetworkId(iPAddressOrFQDN *config.IPAddressOrFQDN) []i return nil } -func flattenIp6Address(iPv6Address *config.IPv6Address) []interface{} { +func flattenIP6Address(iPv6Address *config.IPv6Address) []interface{} { if iPv6Address != nil { ipv6 := make([]interface{}, 0) @@ -352,7 +340,7 @@ func flattenIp6Address(iPv6Address *config.IPv6Address) []interface{} { return nil } -func flattenIp4Address(iPv4Address *config.IPv4Address) []interface{} { +func flattenIP4Address(iPv4Address *config.IPv4Address) []interface{} { if iPv4Address != nil { ipv4 := make([]interface{}, 0) diff --git a/nutanix/services/volumesv2/resource_nutanix_volume_group_disk_v2.go b/nutanix/services/volumesv2/resource_nutanix_volume_group_disk_v2.go index f40c96c53..acca65c1b 100644 --- a/nutanix/services/volumesv2/resource_nutanix_volume_group_disk_v2.go +++ b/nutanix/services/volumesv2/resource_nutanix_volume_group_disk_v2.go @@ -118,7 +118,7 @@ func ResourceNutanixVolumeGroupDiskV2() *schema.Resource { func ResourceNutanixVolumeGroupDiskV2Create(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).VolumeAPI - volumeGroupExtId := d.Get("volume_group_ext_id") + volumeGroupExtID := d.Get("volume_group_ext_id") body := volumesClient.VolumeDisk{} @@ -140,7 +140,7 @@ func ResourceNutanixVolumeGroupDiskV2Create(ctx context.Context, d *schema.Resou } log.Printf("[DEBUG] Volume Disk Body body.DiskDataSourceReference.Uris : %v", body.DiskDataSourceReference.Uris) - resp, err := conn.VolumeAPIInstance.CreateVolumeDisk(utils.StringPtr(volumeGroupExtId.(string)), &body) + resp, err := conn.VolumeAPIInstance.CreateVolumeDisk(utils.StringPtr(volumeGroupExtID.(string)), &body) if err != nil { return diag.Errorf("error while creating Volume Disk : %v", err) @@ -181,11 +181,11 @@ func ResourceNutanixVolumeGroupDiskV2Create(ctx context.Context, d *schema.Resou func ResourceNutanixVolumeGroupDiskV2Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).VolumeAPI - volumeGroupExtId := d.Get("volume_group_ext_id") + volumeGroupExtID := d.Get("volume_group_ext_id") volumeDiskExtID := d.Id() // d.Id gives volume_group_ext_id not volume_disk_ext_id - resp, err := conn.VolumeAPIInstance.GetVolumeDiskById(utils.StringPtr(volumeGroupExtId.(string)), utils.StringPtr(volumeDiskExtID)) + resp, err := conn.VolumeAPIInstance.GetVolumeDiskById(utils.StringPtr(volumeGroupExtID.(string)), utils.StringPtr(volumeDiskExtID)) if err != nil { return diag.Errorf("error while fetching volume Disk : %v", err) @@ -218,10 +218,10 @@ func ResourceNutanixVolumeGroupDiskV2Read(ctx context.Context, d *schema.Resourc func ResourceNutanixVolumeGroupDiskV2Update(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).VolumeAPI - volumeGroupExtId := d.Get("volume_group_ext_id") + volumeGroupExtID := d.Get("volume_group_ext_id") volumeDiskExtID := d.Id() - resp, err := conn.VolumeAPIInstance.GetVolumeDiskById(utils.StringPtr(volumeGroupExtId.(string)), utils.StringPtr(volumeDiskExtID)) + resp, err := conn.VolumeAPIInstance.GetVolumeDiskById(utils.StringPtr(volumeGroupExtID.(string)), utils.StringPtr(volumeDiskExtID)) if err != nil { var errordata map[string]interface{} @@ -261,7 +261,7 @@ func ResourceNutanixVolumeGroupDiskV2Update(ctx context.Context, d *schema.Resou updateSpec.DiskDataSourceReference = nil } - updateResp, err := conn.VolumeAPIInstance.UpdateVolumeDiskById(utils.StringPtr(volumeGroupExtId.(string)), utils.StringPtr(volumeDiskExtID), &updateSpec) + updateResp, err := conn.VolumeAPIInstance.UpdateVolumeDiskById(utils.StringPtr(volumeGroupExtID.(string)), utils.StringPtr(volumeDiskExtID), &updateSpec) if err != nil { var errordata map[string]interface{} @@ -299,10 +299,10 @@ func ResourceNutanixVolumeGroupDiskV2Update(ctx context.Context, d *schema.Resou func ResourceNutanixVolumeGroupDiskV2Delete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).VolumeAPI - volumeGroupExtId := d.Get("volume_group_ext_id") + volumeGroupExtID := d.Get("volume_group_ext_id") volumeDiskExtID := d.Get("ext_id") - resp, err := conn.VolumeAPIInstance.DeleteVolumeDiskById(utils.StringPtr(volumeGroupExtId.(string)), utils.StringPtr(volumeDiskExtID.(string))) + resp, err := conn.VolumeAPIInstance.DeleteVolumeDiskById(utils.StringPtr(volumeGroupExtID.(string)), utils.StringPtr(volumeDiskExtID.(string))) if err != nil { return diag.Errorf("error while fetching volume Disk : %v", err) @@ -350,8 +350,8 @@ func expandDiskDataSourceReference(entityReference interface{}) *config.EntityRe diskDataSourceReference := config.EntityReference{} - if extId, ok := val["ext_id"]; ok { - diskDataSourceReference.ExtId = utils.StringPtr(extId.(string)) + if extID, ok := val["ext_id"]; ok { + diskDataSourceReference.ExtId = utils.StringPtr(extID.(string)) } if name, ok := val["name"]; ok { diskDataSourceReference.Name = utils.StringPtr(name.(string)) diff --git a/nutanix/services/volumesv2/resource_nutanix_volume_group_iscsi_client_v2.go b/nutanix/services/volumesv2/resource_nutanix_volume_group_iscsi_client_v2.go index ddd7bc937..14d4d2179 100644 --- a/nutanix/services/volumesv2/resource_nutanix_volume_group_iscsi_client_v2.go +++ b/nutanix/services/volumesv2/resource_nutanix_volume_group_iscsi_client_v2.go @@ -39,7 +39,7 @@ func ResourceNutanixVolumeGroupIscsiClientV2() *schema.Resource { Computed: true, }, "iscsi_initiator_name": { - Description: "iSCSI initiator name. During the attach operation, exactly one of iscsiInitiatorName and iscsiInitiatorNetworkId must be specified. This field is immutable.", + Description: "iSCSI initiator name. During the attach operation, exactly one of iscsiInitiatorName and iscsiInitiatorNetworkID must be specified. This field is immutable.", Type: schema.TypeString, Optional: true, }, @@ -49,7 +49,7 @@ func ResourceNutanixVolumeGroupIscsiClientV2() *schema.Resource { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "ipv4": SchemaForIpV4ValuePrefixLength(), + "ipv4": SchemaForIPV4ValuePrefixLength(), "ipv6": SchemaForIpV6ValuePrefixLength(), "fqdn": { Description: "A fully qualified domain name that specifies its exact location in the tree hierarchy of the Domain Name System.", @@ -96,7 +96,7 @@ func ResourceNutanixVolumeGroupIscsiClientV2() *schema.Resource { } } -func SchemaForIpV4ValuePrefixLength() *schema.Schema { +func SchemaForIPV4ValuePrefixLength() *schema.Schema { return &schema.Schema{ Description: "An unique address that identifies a device on the internet or a local network in IPv4 format.", Type: schema.TypeList, @@ -157,8 +157,8 @@ func ResourceNutanixVolumeGroupIscsiClientV2Create(ctx context.Context, d *schem if iscsiInitiatorName, ok := d.GetOk("iscsi_initiator_name"); ok { body.IscsiInitiatorName = utils.StringPtr(iscsiInitiatorName.(string)) } - if iscsiInitiatorNetworkId, ok := d.GetOk("iscsi_initiator_network_id"); ok { - body.IscsiInitiatorNetworkId = expandIscsiInitiatorNetworkId(iscsiInitiatorNetworkId.([]interface{})) + if iscsiInitiatorNetworkID, ok := d.GetOk("iscsi_initiator_network_id"); ok { + body.IscsiInitiatorNetworkId = expandiscsiInitiatorNetworkID(iscsiInitiatorNetworkID.([]interface{})) } if clientSecret, ok := d.GetOk("client_secret"); ok { body.ClientSecret = utils.StringPtr(clientSecret.(string)) @@ -255,8 +255,8 @@ func ResourceNutanixVVolumeGroupIscsiClientV2Delete(ctx context.Context, d *sche body := volumesClient.IscsiClientAttachment{} - if extId, ok := d.GetOk("ext_id"); ok { - body.ExtId = utils.StringPtr(extId.(string)) + if extID, ok := d.GetOk("ext_id"); ok { + body.ExtId = utils.StringPtr(extID.(string)) } resp, err := conn.VolumeAPIInstance.DetachIscsiClient(utils.StringPtr(volumeGroupExtId.(string)), &body) @@ -315,17 +315,17 @@ func ResourceNutanixVVolumeGroupIscsiClientV2Delete(ctx context.Context, d *sche return nil } -func expandIscsiInitiatorNetworkId(ipAddressOrFQDN interface{}) *config.IPAddressOrFQDN { +func expandiscsiInitiatorNetworkID(ipAddressOrFQDN interface{}) *config.IPAddressOrFQDN { if ipAddressOrFQDN != nil { fip := &config.IPAddressOrFQDN{} prI := ipAddressOrFQDN.([]interface{}) val := prI[0].(map[string]interface{}) if ipv4, ok := val["ipv4"]; ok { - fip.Ipv4 = expandFloatingIPv4Address(ipv4) + fip.Ipv4 = expandFloatingIPV4Address(ipv4) } if ipv6, ok := val["ipv6"]; ok { - fip.Ipv6 = expandFloatingIPv6Address(ipv6) + fip.Ipv6 = expandFloatingIPV6Address(ipv6) } if fqdn, ok := val["fqdn"]; ok { fip.Fqdn = expandFQDN(fqdn) @@ -336,7 +336,7 @@ func expandIscsiInitiatorNetworkId(ipAddressOrFQDN interface{}) *config.IPAddres return nil } -func expandFloatingIPv4Address(IPv4I interface{}) *config.IPv4Address { +func expandFloatingIPV4Address(IPv4I interface{}) *config.IPv4Address { if IPv4I != nil { ipv4 := &config.IPv4Address{} prI := IPv4I.([]interface{}) @@ -353,7 +353,7 @@ func expandFloatingIPv4Address(IPv4I interface{}) *config.IPv4Address { return nil } -func expandFloatingIPv6Address(IPv6I interface{}) *config.IPv6Address { +func expandFloatingIPV6Address(IPv6I interface{}) *config.IPv6Address { if IPv6I != nil { ipv6 := &config.IPv6Address{} prI := IPv6I.([]interface{}) @@ -370,10 +370,10 @@ func expandFloatingIPv6Address(IPv6I interface{}) *config.IPv6Address { return nil } -func expandFQDN(FQDNI interface{}) *config.FQDN { - if FQDNI != nil { +func expandFQDN(fqdnObj interface{}) *config.FQDN { + if fqdnObj != nil { fqdn := &config.FQDN{} - prI := FQDNI.([]interface{}) + prI := fqdnObj.([]interface{}) val := prI[0].(map[string]interface{}) if value, ok := val["value"]; ok { diff --git a/nutanix/services/volumesv2/resource_nutanix_volume_group_v2.go b/nutanix/services/volumesv2/resource_nutanix_volume_group_v2.go index 020137888..cd1430d71 100644 --- a/nutanix/services/volumesv2/resource_nutanix_volume_group_v2.go +++ b/nutanix/services/volumesv2/resource_nutanix_volume_group_v2.go @@ -155,8 +155,8 @@ func ResourceNutanixVolumeGroupV2Create(ctx context.Context, d *schema.ResourceD if desc, ok := d.GetOk("description"); ok { body.Description = utils.StringPtr(desc.(string)) } - if shouldLoadBalanceVmAttachments, ok := d.GetOk("should_load_balance_vm_attachments"); ok { - body.ShouldLoadBalanceVmAttachments = utils.BoolPtr(shouldLoadBalanceVmAttachments.(bool)) + if shouldLoadBalanceVMAttachments, ok := d.GetOk("should_load_balance_vm_attachments"); ok { + body.ShouldLoadBalanceVmAttachments = utils.BoolPtr(shouldLoadBalanceVMAttachments.(bool)) } if sharingStatus, ok := d.GetOk("sharing_status"); ok { sharingStatusMap := map[string]interface{}{ @@ -349,10 +349,10 @@ func ResourceNutanixVolumeGroupV2Delete(ctx context.Context, d *schema.ResourceD return nil } -func expandIscsiFeatures(IscsiFeaturesList interface{}) *volumesClient.IscsiFeatures { - if len(IscsiFeaturesList.([]interface{})) > 0 { +func expandIscsiFeatures(iscsiFeaturesList interface{}) *volumesClient.IscsiFeatures { + if len(iscsiFeaturesList.([]interface{})) > 0 { iscsiFeature := &volumesClient.IscsiFeatures{} - iscsiFeaturesI := IscsiFeaturesList.([]interface{}) + iscsiFeaturesI := iscsiFeaturesList.([]interface{}) if iscsiFeaturesI[0] == nil { return nil } diff --git a/nutanix/services/volumesv2/resource_nutanix_volume_group_vm_v2.go b/nutanix/services/volumesv2/resource_nutanix_volume_group_vm_v2.go index 26e5622cc..b91e384ff 100644 --- a/nutanix/services/volumesv2/resource_nutanix_volume_group_vm_v2.go +++ b/nutanix/services/volumesv2/resource_nutanix_volume_group_vm_v2.go @@ -15,14 +15,14 @@ import ( "github.com/terraform-providers/terraform-provider-nutanix/utils" ) -// ResourceNutanixVolumeAttachVmToVolumeGroupV2 Attach an AHV VM to the given Volume Group. -func ResourceNutanixVolumeAttachVmToVolumeGroupV2() *schema.Resource { +// ResourceNutanixVolumeAttachVMToVolumeGroupV2 Attach an AHV VM to the given Volume Group. +func ResourceNutanixVolumeAttachVMToVolumeGroupV2() *schema.Resource { return &schema.Resource{ Description: "Attaches VM to a Volume Group identified by {extId}.", - CreateContext: ResourceNutanixVolumeAttachVmToVolumeGroupV2Create, - ReadContext: ResourceNutanixVolumeAttachVmToVolumeGroupV2Read, - UpdateContext: ResourceNutanixVolumeAttachVmToVolumeGroupV2Update, - DeleteContext: ResourceNutanixVolumeAttachVmToVolumeGroupV2Delete, + CreateContext: ResourceNutanixVolumeAttachVMToVolumeGroupV2Create, + ReadContext: ResourceNutanixVolumeAttachVMToVolumeGroupV2Read, + UpdateContext: ResourceNutanixVolumeAttachVMToVolumeGroupV2Update, + DeleteContext: ResourceNutanixVolumeAttachVMToVolumeGroupV2Delete, Schema: map[string]*schema.Schema{ "volume_group_ext_id": { @@ -49,7 +49,7 @@ func ResourceNutanixVolumeAttachVmToVolumeGroupV2() *schema.Resource { } } -func ResourceNutanixVolumeAttachVmToVolumeGroupV2Create(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func ResourceNutanixVolumeAttachVMToVolumeGroupV2Create(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).VolumeAPI volumeGroupExtId := d.Get("volume_group_ext_id") @@ -118,23 +118,23 @@ func ResourceNutanixVolumeAttachVmToVolumeGroupV2Create(ctx context.Context, d * return nil } -func ResourceNutanixVolumeAttachVmToVolumeGroupV2Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func ResourceNutanixVolumeAttachVMToVolumeGroupV2Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { return nil } -func ResourceNutanixVolumeAttachVmToVolumeGroupV2Update(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func ResourceNutanixVolumeAttachVMToVolumeGroupV2Update(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { return nil } -func ResourceNutanixVolumeAttachVmToVolumeGroupV2Delete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { +func ResourceNutanixVolumeAttachVMToVolumeGroupV2Delete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.Client).VolumeAPI volumeGroupExtId := d.Get("volume_group_ext_id") body := volumesClient.VmAttachment{} - if vmExtId, ok := d.GetOk("vm_ext_id"); ok { - body.ExtId = utils.StringPtr(vmExtId.(string)) + if vmExtID, ok := d.GetOk("vm_ext_id"); ok { + body.ExtId = utils.StringPtr(vmExtID.(string)) } if index, ok := d.GetOk("index"); ok {