fix: adjust to new generator and sdk use
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 3m33s
CI Workflow / CI run tests (pull_request) Failing after 4m51s
CI Workflow / CI run build and linting (pull_request) Failing after 4m37s
CI Workflow / Code coverage report (pull_request) Has been skipped
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 3m33s
CI Workflow / CI run tests (pull_request) Failing after 4m51s
CI Workflow / CI run build and linting (pull_request) Failing after 4m37s
CI Workflow / Code coverage report (pull_request) Has been skipped
This commit is contained in:
parent
ca0f646526
commit
826bb5b36a
36 changed files with 2089 additions and 1166 deletions
|
|
@ -5,8 +5,9 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
coreUtils "github.com/stackitcloud/stackit-sdk-go/core/utils"
|
||||
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexalpha"
|
||||
sqlserverflexalpha "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3alpha1api"
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
|
||||
)
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ func mapFields(source *sqlserverflexalpha.GetDatabaseResponse, model *dataSource
|
|||
if source == nil {
|
||||
return fmt.Errorf("response is nil")
|
||||
}
|
||||
if source.Id == nil || *source.Id == 0 {
|
||||
if source.Id == 0 {
|
||||
return fmt.Errorf("id not present")
|
||||
}
|
||||
if model == nil {
|
||||
|
|
@ -25,8 +26,8 @@ func mapFields(source *sqlserverflexalpha.GetDatabaseResponse, model *dataSource
|
|||
var databaseId int64
|
||||
if model.Id.ValueInt64() != 0 {
|
||||
databaseId = model.Id.ValueInt64()
|
||||
} else if source.Id != nil {
|
||||
databaseId = *source.Id
|
||||
} else if source.Id != 0 {
|
||||
databaseId = source.Id
|
||||
} else {
|
||||
return fmt.Errorf("database id not present")
|
||||
}
|
||||
|
|
@ -38,7 +39,7 @@ func mapFields(source *sqlserverflexalpha.GetDatabaseResponse, model *dataSource
|
|||
model.Region = types.StringValue(region)
|
||||
model.ProjectId = types.StringValue(model.ProjectId.ValueString())
|
||||
model.InstanceId = types.StringValue(model.InstanceId.ValueString())
|
||||
model.CompatibilityLevel = types.Int64Value(source.GetCompatibilityLevel())
|
||||
model.CompatibilityLevel = types.Int64Value(int64(source.GetCompatibilityLevel()))
|
||||
model.CollationName = types.StringValue(source.GetCollationName())
|
||||
|
||||
model.TerraformId = utils.BuildInternalTerraformId(
|
||||
|
|
@ -56,7 +57,7 @@ func mapResourceFields(source *sqlserverflexalpha.GetDatabaseResponse, model *re
|
|||
if source == nil {
|
||||
return fmt.Errorf("response is nil")
|
||||
}
|
||||
if source.Id == nil || *source.Id == 0 {
|
||||
if source.Id == 0 {
|
||||
return fmt.Errorf("id not present")
|
||||
}
|
||||
if model == nil {
|
||||
|
|
@ -66,8 +67,8 @@ func mapResourceFields(source *sqlserverflexalpha.GetDatabaseResponse, model *re
|
|||
var databaseId int64
|
||||
if model.Id.ValueInt64() != 0 {
|
||||
databaseId = model.Id.ValueInt64()
|
||||
} else if source.Id != nil {
|
||||
databaseId = *source.Id
|
||||
} else if source.Id != 0 {
|
||||
databaseId = source.Id
|
||||
} else {
|
||||
return fmt.Errorf("database id not present")
|
||||
}
|
||||
|
|
@ -80,8 +81,8 @@ func mapResourceFields(source *sqlserverflexalpha.GetDatabaseResponse, model *re
|
|||
model.ProjectId = types.StringValue(model.ProjectId.ValueString())
|
||||
model.InstanceId = types.StringValue(model.InstanceId.ValueString())
|
||||
|
||||
model.Compatibility = types.Int64Value(source.GetCompatibilityLevel())
|
||||
model.CompatibilityLevel = types.Int64Value(source.GetCompatibilityLevel())
|
||||
model.Compatibility = types.Int64Value(int64(source.GetCompatibilityLevel()))
|
||||
model.CompatibilityLevel = types.Int64Value(int64(source.GetCompatibilityLevel()))
|
||||
|
||||
model.Collation = types.StringValue(source.GetCollationName()) // it does not come back from api
|
||||
model.CollationName = types.StringValue(source.GetCollationName())
|
||||
|
|
@ -96,9 +97,9 @@ func toCreatePayload(model *resourceModel) (*sqlserverflexalpha.CreateDatabaseRe
|
|||
}
|
||||
|
||||
return &sqlserverflexalpha.CreateDatabaseRequestPayload{
|
||||
Name: model.Name.ValueStringPointer(),
|
||||
Owner: model.Owner.ValueStringPointer(),
|
||||
Name: model.Name.ValueString(),
|
||||
Owner: model.Owner.ValueString(),
|
||||
Collation: model.Collation.ValueStringPointer(),
|
||||
Compatibility: model.Compatibility.ValueInt64Pointer(),
|
||||
Compatibility: coreUtils.Ptr(int32(model.Compatibility.ValueInt64())),
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue