Skip to content

Commit

Permalink
Merge branch 'main' into migrate-vlans-to-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
aayushrangwala authored Mar 14, 2024
2 parents 2c35e4b + 93a0cc2 commit b57a53d
Show file tree
Hide file tree
Showing 9 changed files with 671 additions and 395 deletions.
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ github.com/equinix-labs/fabric-go v0.7.1 h1:4yk0IKXMcc72rkRVbcYHokAEc1uUB06t6NXK
github.com/equinix-labs/fabric-go v0.7.1/go.mod h1:oqgGS3GOI8hHGPJKsAwDOEX0qRHl52sJGvwA/zMSd90=
github.com/equinix/ecx-go/v2 v2.3.1 h1:gFcAIeyaEUw7S8ebqApmT7E/S7pC7Ac3wgScp89fkPU=
github.com/equinix/ecx-go/v2 v2.3.1/go.mod h1:FvCdZ3jXU8Z4CPKig2DT+4J2HdwgRK17pIcznM7RXyk=
github.com/equinix/equinix-sdk-go v0.34.0 h1:CgEl174Jm0ima4rzNFXSl3K7RzTy0NF8eji1/dwYS+Q=
github.com/equinix/equinix-sdk-go v0.34.0/go.mod h1:qnpdRzVftHFNaJFk1VSIrAOTLrIoeDrxzUr3l8ARyvQ=
github.com/equinix/equinix-sdk-go v0.35.0 h1:p/uwA8QPBAuNnKGc3mQkwjw+6++qUadLNnKFQ8jw+wg=
github.com/equinix/equinix-sdk-go v0.35.0/go.mod h1:hEb3XLaedz7xhl/dpPIS6eOIiXNPeqNiVoyDrT6paIg=
github.com/equinix/ne-go v1.16.0 h1:ZijMZxlu/2323RDfisxyeXukMn1TNv5tP5XiXZ8tWRM=
Expand Down Expand Up @@ -596,8 +594,6 @@ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1F
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tmccombs/hcl2json v0.3.3 h1:+DLNYqpWE0CsOQiEZu+OZm5ZBImake3wtITYxQ8uLFQ=
Expand Down
10 changes: 5 additions & 5 deletions internal/resources/metal/connection/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors"
"github.com/equinix/terraform-provider-equinix/internal/framework"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/packethost/packngo"

"context"
"fmt"
Expand Down Expand Up @@ -37,8 +36,7 @@ func (r *DataSource) Read(
req datasource.ReadRequest,
resp *datasource.ReadResponse,
) {
r.Meta.AddFwModuleToMetalUserAgent(ctx, req.ProviderMeta)
client := r.Meta.Metal
client := r.Meta.NewMetalClientForFramework(ctx, req.ProviderMeta)

// Retrieve values from plan
var data DataSourceModel
Expand All @@ -51,8 +49,10 @@ func (r *DataSource) Read(
id := data.ConnectionID.ValueString()

// Use API client to get the current state of the resource
getOpts := &packngo.GetOptions{Includes: []string{"service_tokens", "organization", "facility", "metro", "project"}}
conn, _, err := client.Connections.Get(id, getOpts)
conn, _, err := client.InterconnectionsApi.GetInterconnection(ctx, id).
Include([]string{"service_tokens", "organization", "organization.address", "organization.billing_address", "facility", "metro", "project"}).
Execute()

if err != nil {
// If the Metal Connection is not found, remove it from the state
if equinix_errors.IsNotFound(err) {
Expand Down
11 changes: 8 additions & 3 deletions internal/resources/metal/connection/datasource_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"context"
"fmt"

"github.com/equinix/equinix-sdk-go/services/metalv1"
"github.com/equinix/terraform-provider-equinix/internal/framework"
fwtypes "github.com/equinix/terraform-provider-equinix/internal/framework/types"

"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/packethost/packngo"
)

func dataSourceSchema(ctx context.Context) schema.Schema {
Expand Down Expand Up @@ -59,8 +59,8 @@ func dataSourceSchema(ctx context.Context) schema.Schema {
},
"mode": schema.StringAttribute{
Description: fmt.Sprintf("Connection mode - %s or %s",
string(packngo.ConnectionModeStandard),
string(packngo.ConnectionModeTunnel),
string(metalv1.INTERCONNECTIONMODE_STANDARD),
string(metalv1.INTERCONNECTIONMODE_TUNNEL),
),
Computed: true,
},
Expand All @@ -74,6 +74,11 @@ func dataSourceSchema(ctx context.Context) schema.Schema {
Computed: true,
ElementType: types.Int64Type,
},
"vrfs": schema.ListAttribute{
Description: "Attached vrfs, only in shared connection",
Computed: true,
ElementType: types.StringType,
},
"service_token_type": schema.StringAttribute{
Description: "Only used with shared connection. Type of service token to use for the connection, a_side or z_side",
Computed: true,
Expand Down
Loading

0 comments on commit b57a53d

Please sign in to comment.