Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimutant committed Feb 29, 2024
1 parent 80aaffd commit 6beec05
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 40 deletions.
14 changes: 7 additions & 7 deletions nutanix/sdks/v4/networking/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
)

type NetworkingClient struct {

Check failure on line 9 in nutanix/sdks/v4/networking/networking.go

View workflow job for this annotation

GitHub Actions / tests

type name will be used as networking.NetworkingClient by other packages, and that stutters; consider calling this Client (golint)
SubnetApiInstance *api.SubnetApi
VpcApiInstance *api.VpcApi
FloatingIpApiInstance *api.FloatingIpApi
SubnetAPIInstance *api.SubnetApi
VpcAPIInstance *api.VpcApi
FloatingIPAPIInstance *api.FloatingIpApi
}

func NewNetworkingClient(credentials client.Credentials) (*NetworkingClient, error) {
func NewNetworkingClient(credentials client.Credentials) (*NetworkingClient, error) { //nolint:all
var baseClient *network.ApiClient

// check if all required fields are present. Else create an empty client
Expand All @@ -29,9 +29,9 @@ func NewNetworkingClient(credentials client.Credentials) (*NetworkingClient, err
}

f := &NetworkingClient{
SubnetApiInstance: api.NewSubnetApi(baseClient),
VpcApiInstance: api.NewVpcApi(baseClient),
FloatingIpApiInstance: api.NewFloatingIpApi(baseClient),
SubnetAPIInstance: api.NewSubnetApi(baseClient),
VpcAPIInstance: api.NewVpcApi(baseClient),
FloatingIPAPIInstance: api.NewFloatingIpApi(baseClient),
}

return f, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func DatasourceNutanixFloatingIPV4Read(ctx context.Context, d *schema.ResourceDa
conn := meta.(*conns.Client).NetworkingAPI

extID := d.Get("ext_id")
resp, err := conn.FloatingIpApiInstance.GetFloatingIp(utils.StringPtr(extID.(string)))
resp, err := conn.FloatingIPAPIInstance.GetFloatingIp(utils.StringPtr(extID.(string)))
if err != nil {
var errordata map[string]interface{}
e := json.Unmarshal([]byte(err.Error()), &errordata)
Expand Down Expand Up @@ -208,7 +208,7 @@ func DatasourceNutanixFloatingIPV4Read(ctx context.Context, d *schema.ResourceDa
if err := d.Set("vpc", flattenVpc(getResp.Vpc)); err != nil {
return diag.FromErr(err)
}
if err := d.Set("vm_nic", flattenVmNic(getResp.VmNic)); err != nil {
if err := d.Set("vm_nic", flattenVMNic(getResp.VmNic)); err != nil {
return diag.FromErr(err)
}

Expand Down Expand Up @@ -294,7 +294,7 @@ func flattenVpc(pr *import1.Vpc) []map[string]interface{} {
return nil
}

func flattenVmNic(pr *import1.VmNic) []map[string]interface{} {
func flattenVMNic(pr *import1.VmNic) []map[string]interface{} {
if pr != nil {
nics := make([]map[string]interface{}, 0)
nic := make(map[string]interface{})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func DatasourceNutanixFloatingIPsV4() *schema.Resource {
func datasourceNutanixFloatingIPsV4Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
conn := meta.(*conns.Client).NetworkingAPI

// initialise query params
// initialize query params
var filter, orderBy, expand *string
var page, limit *int

Expand Down Expand Up @@ -78,7 +78,7 @@ func datasourceNutanixFloatingIPsV4Read(ctx context.Context, d *schema.ResourceD
expand = nil
}

resp, err := conn.FloatingIpApiInstance.ListFloatingIp(page, limit, filter, orderBy, expand)
resp, err := conn.FloatingIPAPIInstance.ListFloatingIp(page, limit, filter, orderBy, expand)
if err != nil {
var errordata map[string]interface{}
e := json.Unmarshal([]byte(err.Error()), &errordata)
Expand Down Expand Up @@ -121,7 +121,7 @@ func flattenFloatingIPsEntities(pr []import1.FloatingIp) []map[string]interface{
fip["vpc_reference"] = v.VpcReference
fip["vm_nic_reference"] = v.VmNicReference
fip["vpc"] = flattenVpc(v.Vpc)
fip["vm_nic"] = flattenVmNic(v.VmNic)
fip["vm_nic"] = flattenVMNic(v.VmNic)
fip["links"] = flattenLinks(v.Links)
fip["tenant_id"] = v.TenantId
fip["metadata"] = flattenMetadata(v.Metadata)
Expand Down
26 changes: 14 additions & 12 deletions nutanix/services/v2/networking/data_source_nutanix_subnet_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func dataSourceNutanixSubnetv4Read(ctx context.Context, d *schema.ResourceData,
conn := meta.(*conns.Client).NetworkingAPI

extID := d.Get("ext_id")
resp, err := conn.SubnetApiInstance.GetSubnet(utils.StringPtr(extID.(string)))
resp, err := conn.SubnetAPIInstance.GetSubnet(utils.StringPtr(extID.(string)))
if err != nil {
var errordata map[string]interface{}
e := json.Unmarshal([]byte(err.Error()), &errordata)
Expand Down Expand Up @@ -879,7 +879,7 @@ func flattenDhcpOptions(pr *import1.DhcpOptions) []interface{} {
if pr != nil {
dhcpOps := make([]interface{}, 0)

dhcp := make(map[string]interface{}, 0)
dhcp := make(map[string]interface{})

dhcp["domain_name_servers"] = flattenNtpServer(pr.DomainNameServers)
dhcp["domain_name"] = pr.DomainName
Expand Down Expand Up @@ -916,7 +916,7 @@ func flattenIPv4(pr *config.IPv4Address) []interface{} {
if pr != nil {
ipv4 := make([]interface{}, 0)

ip := make(map[string]interface{}, 0)
ip := make(map[string]interface{})

ip["value"] = pr.Value
ip["prefix_length"] = pr.PrefixLength
Expand All @@ -932,7 +932,7 @@ func flattenIPv6(pr *config.IPv6Address) []interface{} {
if pr != nil {
ipv6 := make([]interface{}, 0)

ip := make(map[string]interface{}, 0)
ip := make(map[string]interface{})

ip["value"] = pr.Value
ip["prefix_length"] = pr.PrefixLength
Expand Down Expand Up @@ -1060,11 +1060,12 @@ func flattenIpv6Config(pr *import1.IPv6Config) []interface{} {
}

func flattenSubnetType(sb *import1.SubnetType) string {
const two, three = 2, 3
if sb != nil {
if *sb == import1.SubnetType(2) {
if *sb == import1.SubnetType(two) {
return "OVERLAY"
}
if *sb == import1.SubnetType(3) {
if *sb == import1.SubnetType(three) {
return "VLAN"
}
}
Expand Down Expand Up @@ -1116,17 +1117,18 @@ func flattenVirtualSwitch(vs *import1.VirtualSwitch) []map[string]interface{} {
}

func flattenBondMode(pr *import1.BondModeType) string {
const two, three, four, five = 2, 3, 4, 5
if pr != nil {
if *pr == import1.BondModeType(2) {
if *pr == import1.BondModeType(two) {
return "ACTIVE_BACKUP"
}
if *pr == import1.BondModeType(3) {
if *pr == import1.BondModeType(three) {
return "BALANCE_SLB"
}
if *pr == import1.BondModeType(4) {
if *pr == import1.BondModeType(four) {
return "BALANCE_TCP"
}
if *pr == import1.BondModeType(5) {
if *pr == import1.BondModeType(five) {
return "NONE"
}
}
Expand Down Expand Up @@ -1300,15 +1302,15 @@ func flattenIPUsage(pr *import1.IPUsage) []map[string]interface{} {
ip["num_macs"] = pr.NumMacs
ip["num_free_ips"] = pr.NumFreeIPs
ip["num_assigned_ips"] = pr.NumAssignedIPs
ip["ip_pool_usages"] = flattenIpPoolUsages(pr.IpPoolUsages)
ip["ip_pool_usages"] = flattenIPPoolUsages(pr.IpPoolUsages)

usage = append(usage, ip)
return usage
}
return nil
}

func flattenIpPoolUsages(pr []import1.IPPoolUsage) []map[string]interface{} {
func flattenIPPoolUsages(pr []import1.IPPoolUsage) []map[string]interface{} {
if len(pr) > 0 {
ips := make([]map[string]interface{}, len(pr))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func DataSourceNutanixSubnetsv4() *schema.Resource {
func dataSourceNutanixSubnetsv4Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
conn := meta.(*conns.Client).NetworkingAPI

// initialise query params
// initialize query params
var filter, orderBy, expand, selects *string
var page, limit *int

Expand Down Expand Up @@ -87,7 +87,7 @@ func dataSourceNutanixSubnetsv4Read(ctx context.Context, d *schema.ResourceData,
selects = nil
}

resp, err := conn.SubnetApiInstance.ListSubnets(page, limit, filter, orderBy, expand, selects)
resp, err := conn.SubnetAPIInstance.ListSubnets(page, limit, filter, orderBy, expand, selects)
if err != nil {
var errordata map[string]interface{}
e := json.Unmarshal([]byte(err.Error()), &errordata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func dataSourceNutanixVPCv4Read(ctx context.Context, d *schema.ResourceData, met
conn := meta.(*conns.Client).NetworkingAPI

extID := d.Get("ext_id")
resp, err := conn.VpcApiInstance.GetVpc(utils.StringPtr(extID.(string)))
resp, err := conn.VpcAPIInstance.GetVpc(utils.StringPtr(extID.(string)))
if err != nil {
var errordata map[string]interface{}
e := json.Unmarshal([]byte(err.Error()), &errordata)
Expand Down
4 changes: 2 additions & 2 deletions nutanix/services/v2/networking/data_source_nutanix_vpcs_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func DataSourceNutanixVPCsv4() *schema.Resource {
func dataSourceNutanixVPCsv4Read(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
conn := meta.(*conns.Client).NetworkingAPI

// initialise query params
// initialize query params
var filter, orderBy, selects *string
var page, limit *int

Expand Down Expand Up @@ -79,7 +79,7 @@ func dataSourceNutanixVPCsv4Read(ctx context.Context, d *schema.ResourceData, me
} else {
selects = nil
}
resp, err := conn.VpcApiInstance.ListVpcs(page, limit, filter, orderBy, selects)
resp, err := conn.VpcAPIInstance.ListVpcs(page, limit, filter, orderBy, selects)
if err != nil {
var errordata map[string]interface{}
e := json.Unmarshal([]byte(err.Error()), &errordata)
Expand Down
17 changes: 7 additions & 10 deletions nutanix/services/v2/networking/resource_nutanix_subnets_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ func ResourceNutanixSubnetv4Create(ctx context.Context, d *schema.ResourceData,
}
if subType, ok := d.GetOk("subnet_type"); ok {
subMap := map[string]interface{}{
"OVERLAY": 2,
"VLAN": 3,
"OVERLAY": "2",
"VLAN": "3",
}
pInt := subMap[subType.(string)]
p := import1.SubnetType(pInt.(int))
Expand Down Expand Up @@ -466,7 +466,7 @@ func ResourceNutanixSubnetv4Create(ctx context.Context, d *schema.ResourceData,
inputSpec.IpUsage = exapndIPUsage(ipUsage)
}

resp, err := conn.SubnetApiInstance.CreateSubnet(&inputSpec)
resp, err := conn.SubnetAPIInstance.CreateSubnet(&inputSpec)
if err != nil {
var errordata map[string]interface{}
e := json.Unmarshal([]byte(err.Error()), &errordata)
Expand Down Expand Up @@ -608,10 +608,10 @@ func expandVirtualSwitch(pr interface{}) *import1.VirtualSwitch {
}
if bondMode, ok := val["bond_mode"]; ok {
bondMap := map[string]interface{}{
"ACTIVE_BACKUP": 2,
"BALANCE_SLB": 3,
"BALANCE_TCP": 4,
"NONE": 5,
"ACTIVE_BACKUP": "2",
"BALANCE_SLB": "3",
"BALANCE_TCP": "4",
"NONE": "5",
}
pInt := bondMap[bondMode.(string)]
p := import1.BondModeType(pInt.(int))
Expand Down Expand Up @@ -746,7 +746,6 @@ func expandVpc(pr interface{}) *import1.Vpc {
if extRoutablePrefix, ok := val["externally_routable_prefixes"]; ok {
vpc.ExternallyRoutablePrefixes = expandIPSubnet(extRoutablePrefix.([]interface{}))
}

}
return nil
}
Expand Down Expand Up @@ -804,7 +803,6 @@ func expandGatewayNodeReference(pr interface{}) *import1.GatewayNodeReference {
if nodeipAdd, ok := val["node_ip_address"]; ok {
gatewayNodesRef.NodeIpAddress = expandIPAddressMap(nodeipAdd)
}

return gatewayNodesRef
}
return nil
Expand Down Expand Up @@ -903,7 +901,6 @@ func exapndIPUsage(pr interface{}) *import1.IPUsage {
ipUsage.NumAssignedIPs = utils.Int64Ptr(numAssgIPs.(int64))
}
return ipUsage

}
return nil
}

0 comments on commit 6beec05

Please sign in to comment.