Skip to content

Commit

Permalink
Fix go linting errors for fabric connection models file
Browse files Browse the repository at this point in the history
  • Loading branch information
thogarty committed Jan 7, 2025
1 parent ac1ae1d commit a2f9478
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions internal/resources/fabric/connection/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@ package connection

import (
"fmt"
"github.com/equinix/equinix-sdk-go/services/fabricv4"
"log"
"reflect"
"sort"

equinix_fabric_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema"
equinix_schema "github.com/equinix/terraform-provider-equinix/internal/schema"

"github.com/equinix/equinix-sdk-go/services/fabricv4"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"log"
"reflect"
"sort"
)

func additionalInfoContainsAWSSecrets(info []interface{}) ([]interface{}, bool) {
var awsSecrets []interface{}

for _, item := range info {
if value, _ := item.(map[string]interface{})["key"]; value == "accessKey" {
if value := item.(map[string]interface{})["key"]; value == "accessKey" {
awsSecrets = append(awsSecrets, item)
}

if value, _ := item.(map[string]interface{})["key"]; value == "secretKey" {
if value := item.(map[string]interface{})["key"]; value == "secretKey" {
awsSecrets = append(awsSecrets, item)
}
}
Expand Down Expand Up @@ -72,11 +74,11 @@ func connectionMap(conn *fabricv4.Connection) map[string]interface{} {
account := conn.GetAccount()
connection["account"] = equinix_fabric_schema.AccountGoToTerraform(&account)
}
if &conn.ASide != nil {
if !reflect.DeepEqual(conn.GetASide(), fabricv4.ConnectionSide{}) {
aSide := conn.GetASide()
connection["a_side"] = connectionSideGoToTerraform(&aSide)
}
if &conn.ZSide != nil {
if !reflect.DeepEqual(conn.GetZSide(), fabricv4.ConnectionSide{}) {
zSide := conn.GetZSide()
connection["z_side"] = connectionSideGoToTerraform(&zSide)
}
Expand All @@ -93,7 +95,7 @@ func connectionMap(conn *fabricv4.Connection) map[string]interface{} {
}

func connectionRedundancyTerraformToGo(redundancyTerraform []interface{}) fabricv4.ConnectionRedundancy {
if redundancyTerraform == nil || len(redundancyTerraform) == 0 {
if len(redundancyTerraform) == 0 {
return fabricv4.ConnectionRedundancy{}
}
var redundancy fabricv4.ConnectionRedundancy
Expand Down Expand Up @@ -124,7 +126,7 @@ func connectionRedundancyGoToTerraform(redundancy *fabricv4.ConnectionRedundancy
}

func serviceTokenTerraformToGo(serviceTokenList []interface{}) fabricv4.ServiceToken {
if serviceTokenList == nil || len(serviceTokenList) == 0 {
if len(serviceTokenList) == 0 {
return fabricv4.ServiceToken{}
}

Expand All @@ -142,7 +144,7 @@ func serviceTokenTerraformToGo(serviceTokenList []interface{}) fabricv4.ServiceT
}

func additionalInfoTerraformToGo(additionalInfoList []interface{}) []fabricv4.ConnectionSideAdditionalInfo {
if additionalInfoList == nil || len(additionalInfoList) == 0 {
if len(additionalInfoList) == 0 {
return nil
}

Expand All @@ -161,7 +163,7 @@ func additionalInfoTerraformToGo(additionalInfoList []interface{}) []fabricv4.Co
}

func connectionSideTerraformToGo(connectionSideTerraform []interface{}) fabricv4.ConnectionSide {
if connectionSideTerraform == nil || len(connectionSideTerraform) == 0 {
if len(connectionSideTerraform) == 0 {
return fabricv4.ConnectionSide{}
}

Expand All @@ -188,7 +190,7 @@ func connectionSideTerraformToGo(connectionSideTerraform []interface{}) fabricv4
}

func accessPointTerraformToGo(accessPointTerraform []interface{}) fabricv4.AccessPoint {
if accessPointTerraform == nil || len(accessPointTerraform) == 0 {
if len(accessPointTerraform) == 0 {
return fabricv4.AccessPoint{}
}

Expand Down Expand Up @@ -279,7 +281,7 @@ func accessPointTerraformToGo(accessPointTerraform []interface{}) fabricv4.Acces
}

func cloudRouterTerraformToGo(cloudRouterRequest []interface{}) fabricv4.CloudRouter {
if cloudRouterRequest == nil || len(cloudRouterRequest) == 0 {
if len(cloudRouterRequest) == 0 {
return fabricv4.CloudRouter{}
}
var cloudRouter fabricv4.CloudRouter
Expand All @@ -291,7 +293,7 @@ func cloudRouterTerraformToGo(cloudRouterRequest []interface{}) fabricv4.CloudRo
}

func linkProtocolTerraformToGo(linkProtocolList []interface{}) fabricv4.SimplifiedLinkProtocol {
if linkProtocolList == nil || len(linkProtocolList) == 0 {
if len(linkProtocolList) == 0 {
return fabricv4.SimplifiedLinkProtocol{}
}

Expand All @@ -318,7 +320,7 @@ func linkProtocolTerraformToGo(linkProtocolList []interface{}) fabricv4.Simplifi
}

func networkTerraformToGo(networkList []interface{}) fabricv4.SimplifiedNetwork {
if networkList == nil || len(networkList) == 0 {
if len(networkList) == 0 {
return fabricv4.SimplifiedNetwork{}
}
var network fabricv4.SimplifiedNetwork
Expand All @@ -329,7 +331,7 @@ func networkTerraformToGo(networkList []interface{}) fabricv4.SimplifiedNetwork
}

func simplifiedServiceProfileTerraformToGo(profileList []interface{}) fabricv4.SimplifiedServiceProfile {
if profileList == nil || len(profileList) == 0 {
if len(profileList) == 0 {
return fabricv4.SimplifiedServiceProfile{}
}

Expand All @@ -343,7 +345,7 @@ func simplifiedServiceProfileTerraformToGo(profileList []interface{}) fabricv4.S
}

func virtualDeviceTerraformToGo(virtualDeviceList []interface{}) fabricv4.VirtualDevice {
if virtualDeviceList == nil || len(virtualDeviceList) == 0 {
if len(virtualDeviceList) == 0 {
return fabricv4.VirtualDevice{}
}

Expand All @@ -362,7 +364,7 @@ func virtualDeviceTerraformToGo(virtualDeviceList []interface{}) fabricv4.Virtua
}

func interfaceTerraformToGo(interfaceList []interface{}) fabricv4.Interface {
if interfaceList == nil || len(interfaceList) == 0 {
if len(interfaceList) == 0 {
return fabricv4.Interface{}
}

Expand Down Expand Up @@ -721,7 +723,7 @@ func getUpdateRequests(conn *fabricv4.Connection, d *schema.ResourceData) ([][]f
}

func portTerraformToGo(portList []interface{}) fabricv4.SimplifiedPort {
if portList == nil || len(portList) == 0 {
if len(portList) == 0 {
return fabricv4.SimplifiedPort{}
}
var port fabricv4.SimplifiedPort
Expand Down

0 comments on commit a2f9478

Please sign in to comment.