fix: refactor publish command
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 13s
CI Workflow / CI (pull_request) Failing after 29s
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
Some checks failed
CI Workflow / Check GoReleaser config (pull_request) Successful in 13s
CI Workflow / CI (pull_request) Failing after 29s
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
feat: add connection info fix: prevent postgresql from failing when encryption is empty
This commit is contained in:
parent
5ec2ab8c67
commit
3a2daf9c56
8 changed files with 650 additions and 425 deletions
|
|
@ -15,7 +15,7 @@ import (
|
|||
)
|
||||
|
||||
func mapGetInstanceResponseToModel(ctx context.Context, m *postgresflexalpharesource.InstanceModel, resp *postgresflex.GetInstanceResponse) error {
|
||||
tflog.Info(ctx, ">>>> MSH DEBUG <<<<", map[string]interface{}{
|
||||
tflog.Debug(ctx, ">>>> MSH DEBUG <<<<", map[string]interface{}{
|
||||
"id": m.Id.ValueString(),
|
||||
"instance_id": m.InstanceId.ValueString(),
|
||||
"backup_schedule": m.BackupSchedule.ValueString(),
|
||||
|
|
@ -47,17 +47,17 @@ func mapGetInstanceResponseToModel(ctx context.Context, m *postgresflexalphareso
|
|||
},
|
||||
)
|
||||
}
|
||||
|
||||
m.ConnectionInfo.Host = types.StringValue(resp.ConnectionInfo.GetHost())
|
||||
m.ConnectionInfo.Port = types.Int64Value(resp.ConnectionInfo.GetPort())
|
||||
|
||||
m.FlavorId = types.StringValue(resp.GetFlavorId())
|
||||
if m.Id.IsNull() || m.Id.IsUnknown() {
|
||||
m.Id = utils.BuildInternalTerraformId(m.ProjectId.ValueString(), m.Region.ValueString(), m.InstanceId.ValueString())
|
||||
}
|
||||
m.InstanceId = types.StringPointerValue(resp.Id)
|
||||
|
||||
//m.IsDeletable = types.BoolUnknown()
|
||||
//if isDel, ok := resp.GetIsDeletableOk(); ok {
|
||||
// m.IsDeletable = types.BoolValue(isDel)
|
||||
m.IsDeletable = types.BoolValue(resp.GetIsDeletable())
|
||||
//}
|
||||
|
||||
netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
|
||||
if diags.HasError() {
|
||||
|
|
@ -93,10 +93,6 @@ func mapGetInstanceResponseToModel(ctx context.Context, m *postgresflexalphareso
|
|||
|
||||
m.Name = types.StringValue(resp.GetName())
|
||||
|
||||
//m.Status = types.StringUnknown()
|
||||
//if status, ok := resp.GetStatusOk(); ok {
|
||||
// m.Status = types.StringValue(string(status))
|
||||
//}
|
||||
m.Status = types.StringValue(string(resp.GetStatus()))
|
||||
|
||||
storage, diags := postgresflexalpharesource.NewStorageValue(
|
||||
|
|
@ -117,13 +113,14 @@ func mapGetInstanceResponseToModel(ctx context.Context, m *postgresflexalphareso
|
|||
|
||||
func mapGetDataInstanceResponseToModel(ctx context.Context, m *postgresflexalphadatasource.InstanceModel, resp *postgresflex.GetInstanceResponse) error {
|
||||
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
||||
//nolint:gocritic
|
||||
// m.Encryption = postgresflexalpharesource.EncryptionValue{
|
||||
// KekKeyId: types.StringValue(resp.Encryption.GetKekKeyId()),
|
||||
// KekKeyRingId: types.StringValue(resp.Encryption.GetKekKeyRingId()),
|
||||
// KekKeyVersion: types.StringValue(resp.Encryption.GetKekKeyVersion()),
|
||||
// ServiceAccount: types.StringValue(resp.Encryption.GetServiceAccount()),
|
||||
// }
|
||||
m.Encryption = postgresflexalphadatasource.EncryptionValue{
|
||||
KekKeyId: types.StringValue(resp.Encryption.GetKekKeyId()),
|
||||
KekKeyRingId: types.StringValue(resp.Encryption.GetKekKeyRingId()),
|
||||
KekKeyVersion: types.StringValue(resp.Encryption.GetKekKeyVersion()),
|
||||
ServiceAccount: types.StringValue(resp.Encryption.GetServiceAccount()),
|
||||
}
|
||||
m.ConnectionInfo.Host = types.StringValue(resp.ConnectionInfo.GetHost())
|
||||
m.ConnectionInfo.Port = types.Int64Value(resp.ConnectionInfo.GetPort())
|
||||
m.FlavorId = types.StringValue(resp.GetFlavorId())
|
||||
m.Id = utils.BuildInternalTerraformId(m.ProjectId.ValueString(), m.Region.ValueString(), m.InstanceId.ValueString())
|
||||
m.InstanceId = types.StringPointerValue(resp.Id)
|
||||
|
|
|
|||
|
|
@ -247,16 +247,20 @@ func (r *instanceResource) Create(
|
|||
}
|
||||
|
||||
func modelToCreateInstancePayload(netAcl []string, model postgresflexalpha.InstanceModel, replVal int32) postgresflex.CreateInstanceRequestPayload {
|
||||
payload := postgresflex.CreateInstanceRequestPayload{
|
||||
BackupSchedule: model.BackupSchedule.ValueStringPointer(),
|
||||
Encryption: &postgresflex.InstanceEncryption{
|
||||
var enc postgresflex.InstanceEncryption
|
||||
if !model.Encryption.IsNull() && !model.Encryption.IsUnknown() {
|
||||
enc = postgresflex.InstanceEncryption{
|
||||
KekKeyId: model.Encryption.KekKeyId.ValueStringPointer(),
|
||||
KekKeyRingId: model.Encryption.KekKeyRingId.ValueStringPointer(),
|
||||
KekKeyVersion: model.Encryption.KekKeyVersion.ValueStringPointer(),
|
||||
ServiceAccount: model.Encryption.ServiceAccount.ValueStringPointer(),
|
||||
},
|
||||
FlavorId: model.FlavorId.ValueStringPointer(),
|
||||
Name: model.Name.ValueStringPointer(),
|
||||
}
|
||||
}
|
||||
payload := postgresflex.CreateInstanceRequestPayload{
|
||||
BackupSchedule: model.BackupSchedule.ValueStringPointer(),
|
||||
Encryption: &enc,
|
||||
FlavorId: model.FlavorId.ValueStringPointer(),
|
||||
Name: model.Name.ValueStringPointer(),
|
||||
Network: &postgresflex.InstanceNetwork{
|
||||
AccessScope: postgresflex.InstanceNetworkGetAccessScopeAttributeType(
|
||||
model.Network.AccessScope.ValueStringPointer(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue