Skip to content

Commit

Permalink
Replace ReadContext with ReadWithoutTimeout (#389)
Browse files Browse the repository at this point in the history
* replace readcontext with reacwithouttimeout

* replace ReadContext with ReadWithoutTimeout
in AWS peering data source

* drop azure_peering_id assertion
and add clarifying comment

* use timeout constant directly
instead of schema timeout

Co-authored-by: Brenna Hewer-Darroch <[email protected]>
  • Loading branch information
itsjaspermilan and bcmdarroch authored Sep 9, 2022
1 parent a56d2f8 commit 8e14446
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions internal/provider/data_source_aws_network_peering.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

func dataSourceAwsNetworkPeering() *schema.Resource {
return &schema.Resource{
Description: "The AWS network peering data source provides information about an existing network peering between an HVN and a peer AWS VPC.",
ReadContext: dataSourceAwsNetworkPeeringRead,
Description: "The AWS network peering data source provides information about an existing network peering between an HVN and a peer AWS VPC.",
ReadWithoutTimeout: dataSourceAwsNetworkPeeringRead,
Timeouts: &schema.ResourceTimeout{
Read: &peeringCreateTimeout,
},
Expand Down Expand Up @@ -114,7 +114,7 @@ func dataSourceAwsNetworkPeeringRead(ctx context.Context, d *schema.ResourceData
}

if waitForActive && peering.State != networkmodels.HashicorpCloudNetwork20200907PeeringStateACTIVE {
peering, err = clients.WaitForPeeringToBeActive(ctx, client, peering.ID, hvnID, loc, d.Timeout(schema.TimeoutRead))
peering, err = clients.WaitForPeeringToBeActive(ctx, client, peering.ID, hvnID, loc, peeringCreateTimeout)
if err != nil {
return diag.FromErr(err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/data_source_azure_peering_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

func dataSourceAzurePeeringConnection() *schema.Resource {
return &schema.Resource{
Description: "The Azure peering connection data source provides information about a peering connection between an HVN and a peer Azure VNet.",
ReadContext: dataSourceAzurePeeringConnectionRead,
Description: "The Azure peering connection data source provides information about a peering connection between an HVN and a peer Azure VNet.",
ReadWithoutTimeout: dataSourceAzurePeeringConnectionRead,
Timeouts: &schema.ResourceTimeout{
Read: &peeringCreateTimeout,
},
Expand Down Expand Up @@ -129,7 +129,7 @@ func dataSourceAzurePeeringConnectionRead(ctx context.Context, d *schema.Resourc
}

if waitForActive && peering.State != networkmodels.HashicorpCloudNetwork20200907PeeringStateACTIVE {
peering, err = clients.WaitForPeeringToBeActive(ctx, client, peering.ID, hvnLink.ID, loc, d.Timeout(schema.TimeoutRead))
peering, err = clients.WaitForPeeringToBeActive(ctx, client, peering.ID, hvnLink.ID, loc, peeringCreateTimeout)
if err != nil {
return diag.FromErr(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ func TestAccAzurePeeringConnection(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "peer_tenant_id", tenantID),
resource.TestCheckResourceAttr(resourceName, "peer_vnet_name", uniqueAzurePeeringTestID),
resource.TestCheckResourceAttrSet(resourceName, "peer_vnet_region"),
resource.TestCheckResourceAttrSet(resourceName, "azure_peering_id"),
resource.TestCheckResourceAttrSet(resourceName, "organization_id"),
resource.TestCheckResourceAttrSet(resourceName, "project_id"),
resource.TestCheckResourceAttrSet(resourceName, "created_at"),
resource.TestCheckResourceAttrSet(resourceName, "expires_at"),
resource.TestCheckResourceAttrSet(resourceName, "state"),
testLink(resourceName, "self_link", uniqueAzurePeeringTestID, PeeringResourceType, "hcp_hvn.test"),
// Note: azure_peering_id is not set until the peering is accepted after creation.
),
},
// Tests import
Expand Down

0 comments on commit 8e14446

Please sign in to comment.