Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Timeout for metal network device #387

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions cmd/migration-tool/transforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion equinix/resource_metal_connection_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func TestAccMetalConnection_shared_zside(t *testing.T) {
},
})


}

func TestAccMetalConnection_shared(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion equinix/resource_network_bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func resourceNetworkBGP() *schema.Resource {
UpdateContext: resourceNetworkBGPUpdate,
DeleteContext: resourceNetworkBGPDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Schema: createNetworkBGPResourceSchema(),
Timeouts: &schema.ResourceTimeout{
Expand Down
2 changes: 1 addition & 1 deletion equinix/resource_network_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func resourceNetworkDevice() *schema.Resource {
UpdateContext: resourceNetworkDeviceUpdate,
DeleteContext: resourceNetworkDeviceDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Schema: createNetworkDeviceSchema(),
Timeouts: &schema.ResourceTimeout{
Expand Down
2 changes: 1 addition & 1 deletion equinix/resource_network_device_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func resourceNetworkDeviceLink() *schema.Resource {
UpdateContext: resourceNetworkDeviceLinkUpdate,
DeleteContext: resourceNetworkDeviceLinkDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Schema: createNetworkDeviceLinkResourceSchema(),
Timeouts: &schema.ResourceTimeout{
Expand Down
2 changes: 1 addition & 1 deletion equinix/resource_network_ssh_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func resourceNetworkSSHKey() *schema.Resource {
ReadContext: resourceNetworkSSHKeyRead,
DeleteContext: resourceNetworkSSHKeyDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},
Schema: createNetworkSSHKeyResourceSchema(),
Timeouts: &schema.ResourceTimeout{
Expand Down