feat: add database_id attribute to resource model and update related functions

This commit is contained in:
Andre_Harms 2026-02-05 09:14:03 +01:00
parent 502b2f5e0a
commit 91913c3446
6 changed files with 90 additions and 65 deletions

View file

@ -2,7 +2,6 @@ package postgresflexalpha
import (
"fmt"
"strings"
"github.com/hashicorp/terraform-plugin-framework/types"
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/pkg_gen/postgresflexalpha"
@ -34,6 +33,7 @@ func mapFields(
}
model.Id = types.Int64Value(databaseId)
model.DatabaseID = types.Int64Value(databaseId)
model.Name = types.StringPointerValue(source.Name)
model.Owner = types.StringPointerValue(cleanString(source.Owner))
model.Region = types.StringValue(region)
@ -63,6 +63,7 @@ func mapResourceFields(source *postgresflexalpha.ListDatabase, model *ResourceMo
}
model.Id = types.Int64Value(databaseId)
model.DatabaseID = types.Int64Value(databaseId)
model.Name = types.StringPointerValue(source.Name)
model.Owner = types.StringPointerValue(cleanString(source.Owner))
return nil
@ -79,12 +80,3 @@ func toCreatePayload(model *ResourceModel) (*postgresflexalpha.CreateDatabaseReq
Owner: model.Owner.ValueStringPointer(),
}, nil
}
// cleanString removes leading and trailing quotes which are sometimes returned by the API.
func cleanString(s *string) *string {
if s == nil {
return nil
}
res := strings.Trim(*s, "\"")
return &res
}