chore: work save
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 4s
CI Workflow / Test readiness for publishing provider (pull_request) Failing after 4m1s
CI Workflow / CI run build and linting (pull_request) Failing after 5m1s
CI Workflow / CI run tests (pull_request) Failing after 5m16s
CI Workflow / Code coverage report (pull_request) Has been skipped

This commit is contained in:
Marcel S. Henselin 2026-03-06 16:06:32 +01:00
parent d6d3a795bb
commit 7f5802aff0
27 changed files with 802 additions and 962 deletions

View file

@ -13,6 +13,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/stackitcloud/stackit-sdk-go/core/oapierror"
coreUtils "github.com/stackitcloud/stackit-sdk-go/core/utils"
"github.com/stackitcloud/stackit-sdk-go/services/postgresflex/v3alpha1api"
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/conversion"
@ -206,7 +207,7 @@ func (r *instanceResource) Create(
return
}
replVal := model.Replicas.ValueInt32() // nolint:gosec // check is performed above
replVal := model.Replicas.ValueInt64() // nolint:gosec // check is performed above
payload := modelToCreateInstancePayload(netAcl, model, replVal)
// Create new instance
@ -221,7 +222,7 @@ func (r *instanceResource) Create(
}
ctx = core.LogResponse(ctx)
instanceId, ok := createResp.GetIdOk()
instanceID, ok := createResp.GetIdOk()
if !ok {
core.LogAndAddError(ctx, &resp.Diagnostics, "error creating instance", "could not find instance id in response")
return
@ -231,14 +232,14 @@ func (r *instanceResource) Create(
identity := InstanceResourceIdentityModel{
ProjectID: types.StringValue(projectId),
Region: types.StringValue(region),
InstanceID: types.StringPointerValue(instanceId),
InstanceID: types.StringPointerValue(instanceID),
}
resp.Diagnostics.Append(resp.Identity.Set(ctx, identity)...)
if resp.Diagnostics.HasError() {
return
}
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client.DefaultAPI, projectId, region, *instanceId).
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client.DefaultAPI, projectId, region, *instanceID).
WaitWithContext(ctx)
if err != nil {
core.LogAndAddError(
@ -271,9 +272,9 @@ func (r *instanceResource) Create(
}
func modelToCreateInstancePayload(
netAcl []string,
netACL []string,
model postgresflexalpha.InstanceModel,
replVal int32,
replVal int64,
) v3alpha1api.CreateInstanceRequestPayload {
var enc *v3alpha1api.InstanceEncryption
if !model.Encryption.IsNull() && !model.Encryption.IsUnknown() {
@ -291,13 +292,13 @@ func modelToCreateInstancePayload(
Name: model.Name.ValueString(),
Network: v3alpha1api.InstanceNetworkCreate{
AccessScope: (*v3alpha1api.InstanceNetworkAccessScope)(model.Network.AccessScope.ValueStringPointer()),
Acl: netAcl,
Acl: netACL,
},
Replicas: v3alpha1api.Replicas(replVal),
RetentionDays: model.RetentionDays.ValueInt32(),
RetentionDays: int32(model.RetentionDays.ValueInt64()),
Storage: v3alpha1api.StorageCreate{
PerformanceClass: model.Storage.PerformanceClass.ValueString(),
Size: model.Storage.Size.ValueInt32(),
Size: int32(model.Storage.Size.ValueInt64()),
},
Version: model.Version.ValueString(),
}
@ -438,7 +439,7 @@ func (r *instanceResource) Update(
return
}
replInt32 := model.Replicas.ValueInt32()
replInt32 := model.Replicas.ValueInt64()
payload := v3alpha1api.UpdateInstanceRequestPayload{
BackupSchedule: model.BackupSchedule.ValueString(),
FlavorId: model.FlavorId.ValueString(),
@ -447,9 +448,9 @@ func (r *instanceResource) Update(
Acl: netAcl,
},
Replicas: v3alpha1api.Replicas(replInt32),
RetentionDays: model.RetentionDays.ValueInt32(),
RetentionDays: int32(model.RetentionDays.ValueInt64()),
Storage: v3alpha1api.StorageUpdate{
Size: model.Storage.Size.ValueInt32Pointer(),
Size: coreUtils.Ptr(int32(model.Storage.Size.ValueInt64())),
},
Version: model.Version.ValueString(),
}