Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #663: Eliminate unnecessary newState object from routing zone resource Read() method #664

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions apstra/resource_datacenter_routing_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,22 +202,16 @@ func (o *resourceDatacenterRoutingZone) Read(ctx context.Context, req resource.R
return
}

// create a new state object with relevant values copied from prior state
var newState blueprint.DatacenterRoutingZone
newState.Id = state.Id
newState.HadPriorVlanIdConfig = state.HadPriorVlanIdConfig
newState.HadPriorVniConfig = state.HadPriorVniConfig

// read the current status from the API
err = newState.Read(ctx, bp, &resp.Diagnostics)
err = state.Read(ctx, bp, &resp.Diagnostics)
if err != nil {
if utils.IsApstra404(err) {
resp.State.RemoveResource(ctx)
return
}

resp.Diagnostics.AddError(
fmt.Sprintf("failed while reading blueprint %s routing zone %s details", bp.Id(), newState.Id),
fmt.Sprintf("failed while reading blueprint %s routing zone %s details", bp.Id(), state.Id),
err.Error())
}
if resp.Diagnostics.HasError() {
Expand Down
Loading