fix: refactor connection info structure to use nested write attribute
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 4s
CI Workflow / CI run tests (pull_request) Failing after 22m28s
CI Workflow / CI run build and linting (pull_request) Successful in 24m2s
CI Workflow / Code coverage report (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 26m18s
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 4s
CI Workflow / CI run tests (pull_request) Failing after 22m28s
CI Workflow / CI run build and linting (pull_request) Successful in 24m2s
CI Workflow / Code coverage report (pull_request) Successful in 5s
CI Workflow / Test readiness for publishing provider (pull_request) Successful in 26m18s
This commit is contained in:
parent
71b7c69f10
commit
313c252839
3 changed files with 884 additions and 158 deletions
|
|
@ -33,9 +33,9 @@ func mapGetInstanceResponseToModel(
|
|||
)
|
||||
}
|
||||
|
||||
isConnectionInfoIncomplete := resp.ConnectionInfo == nil ||
|
||||
resp.ConnectionInfo.Host == nil || *resp.ConnectionInfo.Host == "" ||
|
||||
resp.ConnectionInfo.Port == nil || *resp.ConnectionInfo.Port == 0
|
||||
isConnectionInfoIncomplete := resp.ConnectionInfo == nil || resp.ConnectionInfo.Write == nil ||
|
||||
resp.ConnectionInfo.Write.Host == nil || *resp.ConnectionInfo.Write.Host == "" ||
|
||||
resp.ConnectionInfo.Write.Port == nil || *resp.ConnectionInfo.Write.Port == 0
|
||||
|
||||
if isConnectionInfoIncomplete {
|
||||
m.ConnectionInfo = postgresflexalpharesource.NewConnectionInfoValueNull()
|
||||
|
|
@ -43,22 +43,17 @@ func mapGetInstanceResponseToModel(
|
|||
m.ConnectionInfo = postgresflexalpharesource.NewConnectionInfoValueMust(
|
||||
postgresflexalpharesource.ConnectionInfoValue{}.AttributeTypes(ctx),
|
||||
map[string]attr.Value{
|
||||
"host": types.StringPointerValue(resp.ConnectionInfo.Host),
|
||||
"port": types.Int64PointerValue(resp.ConnectionInfo.Port),
|
||||
"write": postgresflexalpharesource.NewWriteValueMust(
|
||||
postgresflexalpharesource.WriteValue{}.AttributeTypes(ctx),
|
||||
map[string]attr.Value{
|
||||
"host": types.StringPointerValue(resp.ConnectionInfo.Write.Host),
|
||||
"port": types.Int64PointerValue(resp.ConnectionInfo.Write.Port),
|
||||
},
|
||||
),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
m.ConnectionInfo.Host = types.StringValue("")
|
||||
if host, ok := resp.ConnectionInfo.GetHostOk(); ok {
|
||||
m.ConnectionInfo.Host = types.StringValue(host)
|
||||
}
|
||||
|
||||
m.ConnectionInfo.Port = types.Int64Value(0)
|
||||
if port, ok := resp.ConnectionInfo.GetPortOk(); ok {
|
||||
m.ConnectionInfo.Port = types.Int64Value(port)
|
||||
}
|
||||
|
||||
m.FlavorId = types.StringValue(resp.GetFlavorId())
|
||||
if m.Id.IsNull() || m.Id.IsUnknown() {
|
||||
m.Id = utils.BuildInternalTerraformId(
|
||||
|
|
@ -164,9 +159,9 @@ func mapGetDataInstanceResponseToModel(
|
|||
}
|
||||
|
||||
func handleConnectionInfo(ctx context.Context, m *dataSourceModel, resp *postgresflex.GetInstanceResponse) {
|
||||
isConnectionInfoIncomplete := resp.ConnectionInfo == nil ||
|
||||
resp.ConnectionInfo.Host == nil || *resp.ConnectionInfo.Host == "" ||
|
||||
resp.ConnectionInfo.Port == nil || *resp.ConnectionInfo.Port == 0
|
||||
isConnectionInfoIncomplete := resp.ConnectionInfo == nil || resp.ConnectionInfo.Write == nil ||
|
||||
resp.ConnectionInfo.Write.Host == nil || *resp.ConnectionInfo.Write.Host == "" ||
|
||||
resp.ConnectionInfo.Write.Port == nil || *resp.ConnectionInfo.Write.Port == 0
|
||||
|
||||
if isConnectionInfoIncomplete {
|
||||
m.ConnectionInfo = postgresflexalphadatasource.NewConnectionInfoValueNull()
|
||||
|
|
@ -174,8 +169,13 @@ func handleConnectionInfo(ctx context.Context, m *dataSourceModel, resp *postgre
|
|||
m.ConnectionInfo = postgresflexalphadatasource.NewConnectionInfoValueMust(
|
||||
postgresflexalphadatasource.ConnectionInfoValue{}.AttributeTypes(ctx),
|
||||
map[string]attr.Value{
|
||||
"host": types.StringPointerValue(resp.ConnectionInfo.Host),
|
||||
"port": types.Int64PointerValue(resp.ConnectionInfo.Port),
|
||||
"write": postgresflexalphadatasource.NewWriteValueMust(
|
||||
postgresflexalphadatasource.WriteValue{}.AttributeTypes(ctx),
|
||||
map[string]attr.Value{
|
||||
"host": types.StringPointerValue(resp.ConnectionInfo.Write.Host),
|
||||
"port": types.Int64PointerValue(resp.ConnectionInfo.Write.Port),
|
||||
},
|
||||
),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue