Skip to content

Commit

Permalink
fix id not handled bug (#26441)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhang3 authored Jun 24, 2024
1 parent c6cb576 commit 0c94867
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,21 @@ func dataSourceExpressRouteCircuitPeering() *pluginsdk.Resource {
func dataSourceExpressRouteCircuitPeeringRead(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).Network.ExpressRouteCircuitPeerings
ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d)
subscriptionId := meta.(*clients.Client).Account.SubscriptionId
defer cancel()

// TODO this should be constructed?
id, err := commonids.ParseExpressRouteCircuitPeeringID(d.Id())
if err != nil {
return err
}
id := commonids.NewExpressRouteCircuitPeeringID(subscriptionId, d.Get("resource_group_name").(string), d.Get("express_route_circuit_name").(string), d.Get("peering_type").(string))

resp, err := client.Get(ctx, *id)
resp, err := client.Get(ctx, id)
if err != nil {
if response.WasNotFound(resp.HttpResponse) {
return fmt.Errorf("%s was not found", id)
}
return fmt.Errorf("retrieving %s: %+v", *id, err)
return fmt.Errorf("retrieving %s: %+v", id, err)
}

d.SetId(id.ID())

d.Set("peering_type", id.PeeringName)
d.Set("express_route_circuit_name", id.CircuitName)
d.Set("resource_group_name", id.ResourceGroupName)
Expand Down

0 comments on commit 0c94867

Please sign in to comment.