fix: refactor postgres after api updates
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 12s
CI Workflow / CI (pull_request) Failing after 30s
Publish / Check GoReleaser config (pull_request) Has been skipped
CI Workflow / Code coverage report (pull_request) Has been skipped
Publish / Publish provider (pull_request) Has been skipped

This commit is contained in:
Marcel S. Henselin 2026-01-30 11:58:26 +01:00
parent 32b83a0836
commit 764978db88
6 changed files with 52 additions and 16 deletions

View file

@ -56,7 +56,7 @@ func getDatabase(
const pageSize = 25
for page := int64(1); ; page++ {
for page := int32(1); ; page++ {
res, err := client.ListDatabasesRequest(ctx, projectId, region, instanceId).
Page(page).Size(pageSize).Sort(postgresflex.DATABASESORT_INDEX_ASC).Execute()
if err != nil {

View file

@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"math"
"net/http"
"regexp"
"strconv"
@ -365,7 +366,13 @@ func (r *databaseResource) Update(
projectId := model.ProjectId.ValueString()
instanceId := model.InstanceId.ValueString()
databaseId := model.DatabaseId.ValueInt64()
databaseId64 := model.DatabaseId.ValueInt64()
if databaseId64 > math.MaxInt32 {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (databaseId)")
return
}
databaseId := int32(databaseId64)
region := model.Region.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "instance_id", instanceId)
@ -449,7 +456,13 @@ func (r *databaseResource) Delete(
projectId := model.ProjectId.ValueString()
instanceId := model.InstanceId.ValueString()
databaseId := model.DatabaseId.ValueInt64()
databaseId64 := model.DatabaseId.ValueInt64()
if databaseId64 > math.MaxInt32 {
core.LogAndAddError(ctx, &resp.Diagnostics, "Error in type conversion", "int value too large (databaseId)")
return
}
databaseId := int32(databaseId64)
region := model.Region.ValueString()
ctx = tflog.SetField(ctx, "project_id", projectId)
ctx = tflog.SetField(ctx, "instance_id", instanceId)