equinix / terraform-provider-metal

DEPRECATED Equinix Metal standalone TF provider. Use the unified Equinix Terraform Provider.
https://registry.terraform.io/providers/equinix/equinix/latest/docs/guides/migration_guide_equinix_metal
Mozilla Public License 2.0
14 stars 11 forks source link

fix Virtual Circuit disconnecting before delete #189

Closed displague closed 3 years ago

displague commented 3 years ago

I suspect this... Fixes #183

Error: PUT https://api.equinix.com/metal/v1/virtual-circuits/31e13e9e-57e8-4720-a9b2-a715106a9a8c: 422 Update params can't be blank

https://github.com/packethost/packngo/blob/86fc114a1bf21d9f0ad2f16ddbbecd769b79ee4a/virtualcircuits.go#L40 The omitempty here will prevent the nil VirtualNetworkID from being sent to the API. By using an empty string, the API will receive something, however it is not clear to me if the API will accept "" to declare the intention to disconnect the VLAN, or if we will need to change packngo to permit null to be sent. In this case, we could use an option that may be undefined/omitted or literal null or string:

VirtualNetworkID **string `json:"vnid,omitempty"`, 
t0mk commented 3 years ago

@displague looks like a good temporary solution. I should have seen that the omitempty will not work as expected iwth the nil there.

Would be good to know what exactly the API expects there for the removal. It should be possible to observe from web UI console (with debugging tools) if you have a connection for testing available.

displague commented 3 years ago

We may not need to remove the VLAN explicitly. When I can test this I will try taking that approach too.