Skip to content

Commit

Permalink
remove nonsense switch statement; change error summary strings
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Aug 5, 2023
1 parent f13b705 commit 03a017a
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions apstra/resource_datacenter_resource_pool_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (o *resourcePoolAllocation) Create(ctx context.Context, req resource.Create
err = o.lockFunc(ctx, plan.BlueprintId.ValueString())
if err != nil {
resp.Diagnostics.AddError(
fmt.Sprintf("error locking blueprint %q mutex", plan.BlueprintId.ValueString()),
fmt.Sprintf("failed locking blueprint %q mutex", plan.BlueprintId.ValueString()),
err.Error())
return
}
Expand All @@ -79,14 +79,9 @@ func (o *resourcePoolAllocation) Create(ctx context.Context, req resource.Create
}

// Set the new allocation
switch {
case !plan.RoutingZoneId.IsNull():
err = bp.SetResourceAllocation(ctx, request)
default:
err = bp.SetResourceAllocation(ctx, request)
}
err = bp.SetResourceAllocation(ctx, request)
if err != nil {
resp.Diagnostics.AddError("error setting resource allocation", err.Error())
resp.Diagnostics.AddError("failed setting resource allocation", err.Error())
return
}

Expand Down Expand Up @@ -129,7 +124,7 @@ func (o *resourcePoolAllocation) Read(ctx context.Context, req resource.ReadRequ
return
}
resp.Diagnostics.AddError(
fmt.Sprintf("error getting %q resource allocation", allocationRequest.ResourceGroup.Name.String()),
fmt.Sprintf("failed getting %q resource allocation", allocationRequest.ResourceGroup.Name.String()),
err.Error())
return
}
Expand Down Expand Up @@ -163,7 +158,7 @@ func (o *resourcePoolAllocation) Update(ctx context.Context, req resource.Update
err = o.lockFunc(ctx, plan.BlueprintId.ValueString())
if err != nil {
resp.Diagnostics.AddError(
fmt.Sprintf("error locking blueprint %q mutex", plan.BlueprintId.ValueString()),
fmt.Sprintf("failed locking blueprint %q mutex", plan.BlueprintId.ValueString()),
err.Error())
return
}
Expand All @@ -177,7 +172,7 @@ func (o *resourcePoolAllocation) Update(ctx context.Context, req resource.Update
// Set the new allocation
err = bp.SetResourceAllocation(ctx, request)
if err != nil {
resp.Diagnostics.AddError("error setting resource allocation", err.Error())
resp.Diagnostics.AddError("failed setting resource allocation", err.Error())
}

// Set state
Expand All @@ -204,7 +199,7 @@ func (o *resourcePoolAllocation) Delete(ctx context.Context, req resource.Delete
err := o.lockFunc(ctx, state.BlueprintId.ValueString())
if err != nil {
resp.Diagnostics.AddError(
fmt.Sprintf("error locking blueprint %q mutex", state.BlueprintId.ValueString()),
fmt.Sprintf("failed locking blueprint %q mutex", state.BlueprintId.ValueString()),
err.Error())
return
}
Expand All @@ -227,6 +222,6 @@ func (o *resourcePoolAllocation) Delete(ctx context.Context, req resource.Delete
// Set the empty allocation
err = client.SetResourceAllocation(ctx, request)
if err != nil {
resp.Diagnostics.AddError("error setting resource allocation", err.Error())
resp.Diagnostics.AddError("failed setting resource allocation", err.Error())
}
}

0 comments on commit 03a017a

Please sign in to comment.