feat: add database_id attribute to resource model and update related functions
This commit is contained in:
parent
502b2f5e0a
commit
91913c3446
6 changed files with 90 additions and 65 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue