diff --git a/cmd/migration-tool/transforms.go b/cmd/migration-tool/transforms.go index 849c92360..e3937e31f 100644 --- a/cmd/migration-tool/transforms.go +++ b/cmd/migration-tool/transforms.go @@ -8,39 +8,47 @@ import ( ) // matches block headers, ex: -// resource "metal_project" "fooproject" { -// data "packet_vlan" "foovlan" { +// +// resource "metal_project" "fooproject" { +// data "packet_vlan" "foovlan" { var matchBlockHeader = regexp.MustCompile(`(resource|data)(\s+")(metal|packet)(.*?)`) // matches resource interpolation strings (Terraform v0.11 and earlier), ex: -// device_id = "${metal_device.foodevice.id}" +// +// device_id = "${metal_device.foodevice.id}" var matchResourceInterpolation = regexp.MustCompile(`(.*?)(\${\s*)(metal|packet)(_.*?)`) // matches resource reference (Terraform v0.12+), ex: -// device_id = metal_device.foodevice.id +// +// device_id = metal_device.foodevice.id var matchResourceReference = regexp.MustCompile(`(.*?)(=\s*)(metal|packet)(_.*?)`) // matches resource reference in function, ex: -// cidr_notation = join("/", [cidrhost(metal_reserved_ip_block.fooblock.cidr_notation, 0), "32"]) +// +// cidr_notation = join("/", [cidrhost(metal_reserved_ip_block.fooblock.cidr_notation, 0), "32"]) var matchResourceFunction = regexp.MustCompile(`(.*?)(\(\s*)(metal|packet)(_.*?)`) // matches resource reference in conditional, ex: -// ip_address = "${var.network_type == "public" ? metal_device.foodevice.access_public_ipv4 : metal_device.foodevice.access_private_ipv4}" -// ip_address = var.network_type == "public" ? metal_device.foodevice.access_public_ipv4 : metal_device.foodevice.access_private_ipv4 +// +// ip_address = "${var.network_type == "public" ? metal_device.foodevice.access_public_ipv4 : metal_device.foodevice.access_private_ipv4}" +// ip_address = var.network_type == "public" ? metal_device.foodevice.access_public_ipv4 : metal_device.foodevice.access_private_ipv4 var matchResourceConditional = regexp.MustCompile(`(.*?[:|\?])(\s*)(metal|packet)(_.*?)`) // matches resource reference in for loop,ex: -// toset([for network in metal_device.foodevice.network : network.family]) +// +// toset([for network in metal_device.foodevice.network : network.family]) var matchResourceForLoop = regexp.MustCompile(`(.*?)(in\s*)(metal|packet)(_.*?)`) // matches resource in expression,ex: -// tolist([metal_device.foodevice[*].access_public_ipv4]) -// !metal_ip_attachment.fooattach.public -// totalSpeed = metal_connection.fooconnA.speed + metal_connection.fooconnB.speed +// +// tolist([metal_device.foodevice[*].access_public_ipv4]) +// !metal_ip_attachment.fooattach.public +// totalSpeed = metal_connection.fooconnA.speed + metal_connection.fooconnB.speed var matchResourceExpression = regexp.MustCompile(`(.*?[\+|-|\*|\/|>|<|&|\|\||%|!|\[]\s*)(metal|packet)(_.*?)`) // matches datasource references, ex: -// address_family = "${lookup(data.packet_device_bgp_neighbors.test.bgp_neighbors[0], "address_family")}" +// +// address_family = "${lookup(data.packet_device_bgp_neighbors.test.bgp_neighbors[0], "address_family")}" var matchDatasourceReference = regexp.MustCompile(`(.*?data)(\.)(metal|packet)(_.*?)`) // replace specific string patterns in template files diff --git a/internal/provider/provider.go b/equinix/provider/framework.go similarity index 99% rename from internal/provider/provider.go rename to equinix/provider/framework.go index 4e0d18653..4d533a9b2 100644 --- a/internal/provider/provider.go +++ b/equinix/provider/framework.go @@ -23,6 +23,8 @@ import ( "github.com/hashicorp/terraform-plugin-framework/schema/validator" ) +type Config = config.Config + type FrameworkProvider struct { ProviderVersion string Meta *config.Config diff --git a/internal/provider/provider_config.go b/equinix/provider/framework_config.go similarity index 100% rename from internal/provider/provider_config.go rename to equinix/provider/framework_config.go diff --git a/equinix/provider_test.go b/equinix/provider_test.go index a539aca3d..8a4beda11 100644 --- a/equinix/provider_test.go +++ b/equinix/provider_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" + "github.com/equinix/terraform-provider-equinix/equinix/provider" "github.com/equinix/terraform-provider-equinix/internal/config" - "github.com/equinix/terraform-provider-equinix/internal/provider" "github.com/equinix/terraform-provider-equinix/version" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -131,7 +131,7 @@ func TestProvider_setSchemaValueIfNotEmpty(t *testing.T) { var b *int = nil d := schema.TestResourceDataRaw(t, s, make(map[string]interface{})) // when - setSchemaValueIfNotEmpty(key, b, d) + _ = setSchemaValueIfNotEmpty(key, b, d) // then _, ok := d.GetOk(key) assert.False(t, ok, "Key was not set") diff --git a/go.mod b/go.mod index 8d0046192..6d2919473 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/equinix/terraform-provider-equinix -go 1.22 +go 1.22.0 require ( github.com/equinix/equinix-sdk-go v0.42.0 diff --git a/internal/acceptance/acceptance.go b/internal/acceptance/acceptance.go index 0e994f7aa..4d2264b27 100644 --- a/internal/acceptance/acceptance.go +++ b/internal/acceptance/acceptance.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/equinix/terraform-provider-equinix/equinix" + "github.com/equinix/terraform-provider-equinix/equinix/provider" "github.com/equinix/terraform-provider-equinix/internal/config" "github.com/equinix/terraform-provider-equinix/internal/env" - "github.com/equinix/terraform-provider-equinix/internal/provider" "github.com/equinix/terraform-provider-equinix/version" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" terraformsdk "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" diff --git a/internal/planmodifiers/immutable_int64_test.go b/internal/planmodifiers/immutable_int64_test.go index 2e56b5a58..a5719af56 100644 --- a/internal/planmodifiers/immutable_int64_test.go +++ b/internal/planmodifiers/immutable_int64_test.go @@ -11,8 +11,8 @@ import ( func TestImmutableStringSet(t *testing.T) { testCases := []struct { - Old, New, Expected int64 - ExpectError bool + Old, New, Expected int64 + ExpectError bool }{ { Old: 0, @@ -33,7 +33,7 @@ func TestImmutableStringSet(t *testing.T) { for i, testCase := range testCases { stateValue := types.Int64Value(testCase.Old) planValue := types.Int64Value(testCase.New) - expectedValue := types.Int64Null() + expectedValue := types.Int64Null() if testCase.Expected != 0 { expectedValue = types.Int64Value(testCase.Expected) } @@ -41,7 +41,7 @@ func TestImmutableStringSet(t *testing.T) { req := planmodifier.Int64Request{ StateValue: stateValue, PlanValue: planValue, - Path: path.Root("test"), + Path: path.Root("test"), } var resp planmodifier.Int64Response @@ -58,4 +58,4 @@ func TestImmutableStringSet(t *testing.T) { t.Fatalf("%d: output plan value does not equal expected. Want %d plan value, got %d", i, expectedValue, resp.PlanValue.ValueInt64()) } } -} \ No newline at end of file +} diff --git a/internal/resources/metal/project/resource_test.go b/internal/resources/metal/project/resource_test.go index f0a6c26e0..38d7caac7 100644 --- a/internal/resources/metal/project/resource_test.go +++ b/internal/resources/metal/project/resource_test.go @@ -10,9 +10,9 @@ import ( "github.com/equinix/equinix-sdk-go/services/metalv1" "github.com/equinix/terraform-provider-equinix/equinix" + "github.com/equinix/terraform-provider-equinix/equinix/provider" "github.com/equinix/terraform-provider-equinix/internal/acceptance" "github.com/equinix/terraform-provider-equinix/internal/config" - "github.com/equinix/terraform-provider-equinix/internal/provider" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-testing/helper/acctest" diff --git a/main.go b/main.go index b9828711f..f03f13e2b 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,7 @@ import ( "log" "github.com/equinix/terraform-provider-equinix/equinix" - "github.com/equinix/terraform-provider-equinix/internal/provider" + "github.com/equinix/terraform-provider-equinix/equinix/provider" "github.com/equinix/terraform-provider-equinix/version" "github.com/hashicorp/terraform-plugin-framework/providerserver"