Skip to content

Commit

Permalink
resource/cloudflare_argo: call Read operation on Import
Browse files Browse the repository at this point in the history
Ensures we sync the remote with the local on `Import` operations.

Closes #1135
  • Loading branch information
jacobbednarz committed Nov 1, 2021
1 parent 5189383 commit 9ba17cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .changelog/1295.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/cloudflare_argo: call `Read` for `Import` operations
```
24 changes: 11 additions & 13 deletions cloudflare/resource_cloudflare_argo.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,20 @@ func resourceCloudflareArgoRead(d *schema.ResourceData, meta interface{}) error
d.SetId(checksum)
d.Set("zone_id", zoneID)

if _, ok := d.GetOk("tiered_caching"); ok {
tieredCaching, err := client.ArgoTieredCaching(context.Background(), zoneID)
if err != nil {
return errors.Wrap(err, "failed to get tiered caching setting")
}

d.Set("tiered_caching", tieredCaching.Value)
tieredCaching, err := client.ArgoTieredCaching(context.Background(), zoneID)
if err != nil {
return errors.Wrap(err, "failed to get tiered caching setting")
}

if _, ok := d.GetOk("smart_routing"); ok {
smartRouting, err := client.ArgoSmartRouting(context.Background(), zoneID)
if err != nil {
return errors.Wrap(err, "failed to get smart routing setting")
}
d.Set("tiered_caching", tieredCaching.Value)

d.Set("smart_routing", smartRouting.Value)
smartRouting, err := client.ArgoSmartRouting(context.Background(), zoneID)
if err != nil {
return errors.Wrap(err, "failed to get smart routing setting")
}

d.Set("smart_routing", smartRouting.Value)

return nil
}

Expand Down Expand Up @@ -125,5 +121,7 @@ func resourceCloudflareArgoImport(d *schema.ResourceData, meta interface{}) ([]*
d.SetId(id)
d.Set("zone_id", zoneID)

resourceCloudflareArgoRead(d, meta)

return []*schema.ResourceData{d}, nil
}

0 comments on commit 9ba17cc

Please sign in to comment.