Skip to content

Commit

Permalink
Merge pull request #773 from Juniper/bug/772-404-handling
Browse files Browse the repository at this point in the history
Bugfix: Handle 404s when resource not found
  • Loading branch information
chrismarget-j authored Aug 9, 2024
2 parents 3a666d3 + 9b9cfbd commit 9b2036e
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion apstra/resource_freeform_allocation_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (o *resourceFreeformAllocGroup) Read(ctx context.Context, req resource.Read
bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString())
if err != nil {
if utils.IsApstra404(err) {
resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error())
resp.State.RemoveResource(ctx)
return
}
resp.Diagnostics.AddError("failed to create blueprint client", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion apstra/resource_freeform_config_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (o *resourceFreeformConfigTemplate) Read(ctx context.Context, req resource.
bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString())
if err != nil {
if utils.IsApstra404(err) {
resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error())
resp.State.RemoveResource(ctx)
return
}
resp.Diagnostics.AddError("failed to create blueprint client", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion apstra/resource_freeform_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (o *resourceFreeformLink) Read(ctx context.Context, req resource.ReadReques
bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString())
if err != nil {
if utils.IsApstra404(err) {
resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error())
resp.State.RemoveResource(ctx)
return
}
resp.Diagnostics.AddError("failed to create blueprint client", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion apstra/resource_freeform_property_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (o *resourceFreeformPropertySet) Read(ctx context.Context, req resource.Rea
bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString())
if err != nil {
if utils.IsApstra404(err) {
resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error())
resp.State.RemoveResource(ctx)
return
}
resp.Diagnostics.AddError("failed to create blueprint client", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion apstra/resource_freeform_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (o *resourceFreeformResource) Read(ctx context.Context, req resource.ReadRe
bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString())
if err != nil {
if utils.IsApstra404(err) {
resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error())
resp.State.RemoveResource(ctx)
return
}
resp.Diagnostics.AddError("failed to create blueprint client", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion apstra/resource_freeform_resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (o *resourceFreeformResourceGroup) Read(ctx context.Context, req resource.R
bp, err := o.getBpClientFunc(ctx, state.BlueprintId.ValueString())
if err != nil {
if utils.IsApstra404(err) {
resp.Diagnostics.AddError(fmt.Sprintf("blueprint %s not found", state.BlueprintId), err.Error())
resp.State.RemoveResource(ctx)
return
}
resp.Diagnostics.AddError("failed to create blueprint client", err.Error())
Expand Down

0 comments on commit 9b2036e

Please sign in to comment.