fix: builder and sdk changes (#81)
## Description
<!-- **Please link some issue here describing what you are trying to achieve.**
In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->
relates to #1234
## Checklist
- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] Acceptance tests got implemented or updated (see e.g. [here](f5f99d1709/stackit/internal/services/dns/dns_acc_test.go))
- [x] Unit tests are passing: `make test` (will be checked by CI)
- [x] No linter issues: `make lint` (will be checked by CI)
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Co-authored-by: marcel.henselin <marcel.henselin@stackit.cloud>
Reviewed-on: #81
This commit is contained in:
parent
635a9abf20
commit
1033d7e034
145 changed files with 5944 additions and 5298 deletions
|
|
@ -4,8 +4,10 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||
utils2 "github.com/stackitcloud/stackit-sdk-go/core/utils"
|
||||
|
||||
sqlserverflexbeta "github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex/v3beta1api"
|
||||
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/sqlserverflexbeta"
|
||||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
|
||||
)
|
||||
|
||||
|
|
@ -14,7 +16,7 @@ func mapFields(source *sqlserverflexbeta.GetDatabaseResponse, model *dataSourceM
|
|||
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 {
|
||||
|
|
@ -24,8 +26,8 @@ func mapFields(source *sqlserverflexbeta.GetDatabaseResponse, model *dataSourceM
|
|||
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")
|
||||
}
|
||||
|
|
@ -37,7 +39,7 @@ func mapFields(source *sqlserverflexbeta.GetDatabaseResponse, model *dataSourceM
|
|||
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(
|
||||
|
|
@ -55,7 +57,7 @@ func mapResourceFields(source *sqlserverflexbeta.GetDatabaseResponse, model *res
|
|||
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 {
|
||||
|
|
@ -65,8 +67,8 @@ func mapResourceFields(source *sqlserverflexbeta.GetDatabaseResponse, model *res
|
|||
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")
|
||||
}
|
||||
|
|
@ -79,8 +81,8 @@ func mapResourceFields(source *sqlserverflexbeta.GetDatabaseResponse, model *res
|
|||
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())
|
||||
|
|
@ -95,9 +97,9 @@ func toCreatePayload(model *resourceModel) (*sqlserverflexbeta.CreateDatabaseReq
|
|||
}
|
||||
|
||||
return &sqlserverflexbeta.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: utils2.Ptr(int32(model.Compatibility.ValueInt64())), //nolint:gosec // TODO
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue