Skip to content

Commit

Permalink
fix: Remove timeout for metal vrf (#386)
Browse files Browse the repository at this point in the history
As part of fixing the timeouts for metal resources to actually comply
with what is documented, it was found out that we donot document any
timeout support for metal VRF whereas in the code we do have support for
timeouts.

Since it has never been working due to the below issue, also not
documented, it'll be ideal to remove it directly considering a code
smell

Relates to: #357
  • Loading branch information
ctreatma authored Sep 25, 2023
2 parents c810d08 + 73c8b26 commit 45e8380
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
8 changes: 5 additions & 3 deletions equinix/data_source_metal_vrf.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package equinix

import (
"context"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceMetalVRF() *schema.Resource {
return &schema.Resource{
Read: dataSourceMetalVRFRead,
ReadWithoutTimeout: diagnosticsWrapper(dataSourceMetalVRFRead),

Schema: map[string]*schema.Schema{
"vrf_id": {
Expand Down Expand Up @@ -49,9 +51,9 @@ func dataSourceMetalVRF() *schema.Resource {
}
}

func dataSourceMetalVRFRead(d *schema.ResourceData, meta interface{}) error {
func dataSourceMetalVRFRead(ctx context.Context, d *schema.ResourceData, meta interface{}) error {
vrfId, _ := d.Get("vrf_id").(string)

d.SetId(vrfId)
return resourceMetalVRFRead(d, meta)
return resourceMetalVRFRead(ctx, d, meta)
}
32 changes: 13 additions & 19 deletions equinix/resource_metal_vrf.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
package equinix

import (
"log"
"time"

"context"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/packethost/packngo"
"log"
)

func resourceMetalVRF() *schema.Resource {
return &schema.Resource{
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(20 * time.Minute),
Update: schema.DefaultTimeout(20 * time.Minute),
Delete: schema.DefaultTimeout(20 * time.Minute),
},
Read: resourceMetalVRFRead,
Create: resourceMetalVRFCreate,
Update: resourceMetalVRFUpdate,
Delete: resourceMetalVRFDelete,
ReadWithoutTimeout: diagnosticsWrapper(resourceMetalVRFRead),
CreateWithoutTimeout: diagnosticsWrapper(resourceMetalVRFCreate),
UpdateWithoutTimeout: diagnosticsWrapper(resourceMetalVRFUpdate),
DeleteWithoutTimeout: diagnosticsWrapper(resourceMetalVRFDelete),
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
StateContext: schema.ImportStatePassthroughContext,
},

Schema: map[string]*schema.Schema{
Expand Down Expand Up @@ -61,7 +55,7 @@ func resourceMetalVRF() *schema.Resource {
}
}

func resourceMetalVRFCreate(d *schema.ResourceData, meta interface{}) error {
func resourceMetalVRFCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) error {
meta.(*Config).addModuleToMetalUserAgent(d)
client := meta.(*Config).metal

Expand All @@ -81,10 +75,10 @@ func resourceMetalVRFCreate(d *schema.ResourceData, meta interface{}) error {

d.SetId(vrf.ID)

return resourceMetalVRFRead(d, meta)
return resourceMetalVRFRead(ctx, d, meta)
}

func resourceMetalVRFUpdate(d *schema.ResourceData, meta interface{}) error {
func resourceMetalVRFUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) error {
meta.(*Config).addModuleToMetalUserAgent(d)
client := meta.(*Config).metal

Expand All @@ -111,10 +105,10 @@ func resourceMetalVRFUpdate(d *schema.ResourceData, meta interface{}) error {
return friendlyError(err)
}

return resourceMetalVRFRead(d, meta)
return resourceMetalVRFRead(ctx, d, meta)
}

func resourceMetalVRFRead(d *schema.ResourceData, meta interface{}) error {
func resourceMetalVRFRead(ctx context.Context, d *schema.ResourceData, meta interface{}) error {
meta.(*Config).addModuleToMetalUserAgent(d)
client := meta.(*Config).metal

Expand Down Expand Up @@ -142,7 +136,7 @@ func resourceMetalVRFRead(d *schema.ResourceData, meta interface{}) error {
return setMap(d, m)
}

func resourceMetalVRFDelete(d *schema.ResourceData, meta interface{}) error {
func resourceMetalVRFDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) error {
meta.(*Config).addModuleToMetalUserAgent(d)
client := meta.(*Config).metal

Expand Down

0 comments on commit 45e8380

Please sign in to comment.