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

remove nonsense switch statement; change error summary strings #251

Merged
merged 1 commit into from
Aug 6, 2023
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
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())
}
}