fix: try fix errors
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 6s
CI Workflow / Code coverage report (pull_request) Has been cancelled
CI Workflow / Test readiness for publishing provider (pull_request) Has been cancelled
CI Workflow / CI run build and linting (pull_request) Has been cancelled
CI Workflow / CI run tests (pull_request) Has been cancelled
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 6s
CI Workflow / Code coverage report (pull_request) Has been cancelled
CI Workflow / Test readiness for publishing provider (pull_request) Has been cancelled
CI Workflow / CI run build and linting (pull_request) Has been cancelled
CI Workflow / CI run tests (pull_request) Has been cancelled
This commit is contained in:
parent
1451273760
commit
f83fe3b30b
10 changed files with 137 additions and 243 deletions
|
|
@ -2,7 +2,6 @@ package sqlserverflexbeta
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
|
||||
|
|
@ -34,7 +33,7 @@ func mapFields(source *sqlserverflexbeta.GetDatabaseResponse, model *dataSourceM
|
|||
model.Id = types.Int64Value(databaseId)
|
||||
model.DatabaseName = types.StringValue(source.GetName())
|
||||
model.Name = types.StringValue(source.GetName())
|
||||
model.Owner = types.StringValue(strings.Trim(source.GetOwner(), "\""))
|
||||
model.Owner = types.StringValue(source.GetOwner())
|
||||
model.Region = types.StringValue(region)
|
||||
model.ProjectId = types.StringValue(model.ProjectId.ValueString())
|
||||
model.InstanceId = types.StringValue(model.InstanceId.ValueString())
|
||||
|
|
@ -75,7 +74,7 @@ func mapResourceFields(source *sqlserverflexbeta.GetDatabaseResponse, model *res
|
|||
model.Id = types.Int64Value(databaseId)
|
||||
model.DatabaseName = types.StringValue(source.GetName())
|
||||
model.Name = types.StringValue(source.GetName())
|
||||
model.Owner = types.StringValue(strings.Trim(source.GetOwner(), "\""))
|
||||
model.Owner = types.StringValue(source.GetOwner())
|
||||
model.Region = types.StringValue(region)
|
||||
model.ProjectId = types.StringValue(model.ProjectId.ValueString())
|
||||
model.InstanceId = types.StringValue(model.InstanceId.ValueString())
|
||||
|
|
|
|||
|
|
@ -247,7 +247,6 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques
|
|||
return
|
||||
}
|
||||
|
||||
// TODO: is this necessary to wait for the database-> API say 200 ?
|
||||
waitResp, err := wait.CreateDatabaseWaitHandler(
|
||||
ctx,
|
||||
r.client,
|
||||
|
|
@ -310,19 +309,8 @@ func (r *databaseResource) Create(ctx context.Context, req resource.CreateReques
|
|||
return
|
||||
}
|
||||
|
||||
database, err := r.client.GetDatabaseRequest(ctx, projectId, region, instanceId, databaseName).Execute()
|
||||
if err != nil {
|
||||
core.LogAndAddError(
|
||||
ctx,
|
||||
&resp.Diagnostics,
|
||||
"Error creating database",
|
||||
fmt.Sprintf("Getting database details after creation: %v", err),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
// Map response body to schema
|
||||
err = mapResourceFields(database, &data, region)
|
||||
err = mapResourceFields(waitResp, &data, region)
|
||||
if err != nil {
|
||||
core.LogAndAddError(
|
||||
ctx,
|
||||
|
|
@ -361,15 +349,10 @@ func (r *databaseResource) Read(ctx context.Context, req resource.ReadRequest, r
|
|||
|
||||
ctx = core.InitProviderContext(ctx)
|
||||
|
||||
projectId, region, instanceId, databaseName, errExt := r.extractIdentityData(model, identityData)
|
||||
if errExt != nil {
|
||||
core.LogAndAddError(
|
||||
ctx,
|
||||
&resp.Diagnostics,
|
||||
extractErrorSummary,
|
||||
fmt.Sprintf(extractErrorMessage, errExt),
|
||||
)
|
||||
}
|
||||
projectId := model.ProjectId.ValueString()
|
||||
region := model.Region.ValueString()
|
||||
instanceId := model.InstanceId.ValueString()
|
||||
databaseName := model.DatabaseName.ValueString()
|
||||
|
||||
ctx = tflog.SetField(ctx, "project_id", projectId)
|
||||
ctx = tflog.SetField(ctx, "instance_id", instanceId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue