Skip to content

Commit

Permalink
feat: convert metal_port to equinix-sdk-go (#709)
Browse files Browse the repository at this point in the history
This replaces `packngo` with `equinix-sdk-go` in the metal_port resource
and datasource as part of #402. While I'm in these files I also opted to
move them into `internal/resources/metal/port` to align with #106.
  • Loading branch information
ctreatma authored Jul 8, 2024
1 parent afc5ce7 commit f8c2ab9
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 170 deletions.
5 changes: 3 additions & 2 deletions equinix/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/equinix/terraform-provider-equinix/internal/config"
fabric_connection "github.com/equinix/terraform-provider-equinix/internal/resources/fabric/connection"
fabric_network "github.com/equinix/terraform-provider-equinix/internal/resources/fabric/network"
metal_port "github.com/equinix/terraform-provider-equinix/internal/resources/metal/port"
"github.com/equinix/terraform-provider-equinix/internal/resources/metal/virtual_circuit"
"github.com/equinix/terraform-provider-equinix/internal/resources/metal/vrf"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -105,7 +106,7 @@ func Provider() *schema.Provider {
"equinix_metal_devices": dataSourceMetalDevices(),
"equinix_metal_device_bgp_neighbors": dataSourceMetalDeviceBGPNeighbors(),
"equinix_metal_plans": dataSourceMetalPlans(),
"equinix_metal_port": dataSourceMetalPort(),
"equinix_metal_port": metal_port.DataSource(),
"equinix_metal_reserved_ip_block": dataSourceMetalReservedIPBlock(),
"equinix_metal_spot_market_request": dataSourceMetalSpotMarketRequest(),
"equinix_metal_virtual_circuit": virtual_circuit.DataSource(),
Expand All @@ -128,7 +129,7 @@ func Provider() *schema.Provider {
"equinix_metal_project_api_key": resourceMetalProjectAPIKey(),
"equinix_metal_device": resourceMetalDevice(),
"equinix_metal_device_network_type": resourceMetalDeviceNetworkType(),
"equinix_metal_port": resourceMetalPort(),
"equinix_metal_port": metal_port.Resource(),
"equinix_metal_reserved_ip_block": resourceMetalReservedIPBlock(),
"equinix_metal_ip_attachment": resourceMetalIPAttachment(),
"equinix_metal_spot_market_request": resourceMetalSpotMarketRequest(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package equinix
package port

import (
"github.com/equinix/terraform-provider-equinix/internal/network"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceMetalPort() *schema.Resource {
func DataSource() *schema.Resource {
return &schema.Resource{
ReadWithoutTimeout: resourceMetalPortRead,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package equinix
package port_test

import (
"fmt"
"testing"

"github.com/equinix/terraform-provider-equinix/internal/acceptance"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)
Expand All @@ -12,9 +13,9 @@ func TestAccDataSourceMetalPort_byName(t *testing.T) {
rs := acctest.RandString(10)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
PreCheck: func() { acceptance.TestAccPreCheck(t) },
ExternalProviders: acceptance.TestExternalProviders,
ProtoV5ProviderFactories: acceptance.ProtoV5ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccDataSourceMetalPortConfig_byName(rs),
Expand Down Expand Up @@ -50,16 +51,16 @@ data "equinix_metal_port" "test" {
name = "eth0"
}
`, confAccMetalDevice_base(preferable_plans, preferable_metros, preferable_os), name, testDeviceTerminationTime())
`, acceptance.ConfAccMetalDevice_base(acceptance.Preferable_plans, acceptance.Preferable_metros, acceptance.Preferable_os), name, acceptance.TestDeviceTerminationTime())
}

func TestAccDataSourceMetalPort_byId(t *testing.T) {
rs := acctest.RandString(10)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ExternalProviders: testExternalProviders,
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories,
PreCheck: func() { acceptance.TestAccPreCheck(t) },
ExternalProviders: acceptance.TestExternalProviders,
ProtoV5ProviderFactories: acceptance.ProtoV5ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccDataSourceMetalPortConfig_byId(rs),
Expand Down Expand Up @@ -93,5 +94,5 @@ resource "equinix_metal_device" "test" {
data "equinix_metal_port" "test" {
port_id = equinix_metal_device.test.ports[0].id
}
`, confAccMetalDevice_base(preferable_plans, preferable_metros, preferable_os), name, testDeviceTerminationTime())
`, acceptance.ConfAccMetalDevice_base(acceptance.Preferable_plans, acceptance.Preferable_metros, acceptance.Preferable_os), name, acceptance.TestDeviceTerminationTime())
}
Loading

0 comments on commit f8c2ab9

Please sign in to comment.