fix: try fix encryption save
This commit is contained in:
parent
aba831cbdd
commit
6ccf6279b4
2 changed files with 24 additions and 29 deletions
|
|
@ -243,7 +243,8 @@ func (r *instanceResource) Create(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).WaitWithContext(ctx)
|
waitResp, err := wait.CreateInstanceWaitHandler(ctx, r.client, projectId, region, instanceId).
|
||||||
|
WaitWithContext(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
core.LogAndAddError(
|
core.LogAndAddError(
|
||||||
ctx,
|
ctx,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ func mapResponseToModel(
|
||||||
) error {
|
) error {
|
||||||
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
||||||
m.Edition = types.StringValue(string(resp.GetEdition()))
|
m.Edition = types.StringValue(string(resp.GetEdition()))
|
||||||
m.Encryption = handleEncryption(m, resp)
|
m.Encryption = handleEncryption(ctx, m, resp)
|
||||||
m.FlavorId = types.StringValue(resp.GetFlavorId())
|
m.FlavorId = types.StringValue(resp.GetFlavorId())
|
||||||
m.Id = types.StringValue(resp.GetId())
|
m.Id = types.StringValue(resp.GetId())
|
||||||
m.InstanceId = types.StringValue(resp.GetId())
|
m.InstanceId = types.StringValue(resp.GetId())
|
||||||
|
|
@ -81,7 +81,7 @@ func mapDataResponseToModel(
|
||||||
) error {
|
) error {
|
||||||
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
||||||
m.Edition = types.StringValue(string(resp.GetEdition()))
|
m.Edition = types.StringValue(string(resp.GetEdition()))
|
||||||
m.Encryption = handleDSEncryption(m, resp)
|
m.Encryption = handleDSEncryption(ctx, m, resp)
|
||||||
m.FlavorId = types.StringValue(resp.GetFlavorId())
|
m.FlavorId = types.StringValue(resp.GetFlavorId())
|
||||||
m.Id = types.StringValue(resp.GetId())
|
m.Id = types.StringValue(resp.GetId())
|
||||||
m.InstanceId = types.StringValue(resp.GetId())
|
m.InstanceId = types.StringValue(resp.GetId())
|
||||||
|
|
@ -130,6 +130,7 @@ func mapDataResponseToModel(
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleEncryption(
|
func handleEncryption(
|
||||||
|
ctx context.Context,
|
||||||
m *sqlserverflexbetaResGen.InstanceModel,
|
m *sqlserverflexbetaResGen.InstanceModel,
|
||||||
resp *sqlserverflexbeta.GetInstanceResponse,
|
resp *sqlserverflexbeta.GetInstanceResponse,
|
||||||
) sqlserverflexbetaResGen.EncryptionValue {
|
) sqlserverflexbetaResGen.EncryptionValue {
|
||||||
|
|
@ -145,23 +146,20 @@ func handleEncryption(
|
||||||
return m.Encryption
|
return m.Encryption
|
||||||
}
|
}
|
||||||
|
|
||||||
enc := sqlserverflexbetaResGen.NewEncryptionValueNull()
|
enc := sqlserverflexbetaResGen.NewEncryptionValueMust(
|
||||||
if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok {
|
sqlserverflexbetaResGen.EncryptionValue{}.AttributeTypes(ctx),
|
||||||
enc.KekKeyId = types.StringValue(kVal)
|
map[string]attr.Value{
|
||||||
}
|
"kek_key_id": types.StringValue(resp.Encryption.GetKekKeyId()),
|
||||||
if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok {
|
"kek_key_ring_id": types.StringValue(resp.Encryption.GetKekKeyRingId()),
|
||||||
enc.KekKeyRingId = types.StringValue(kkVal)
|
"kek_key_version": types.StringValue(resp.Encryption.GetKekKeyVersion()),
|
||||||
}
|
"service_account": types.StringValue(resp.Encryption.GetServiceAccount()),
|
||||||
if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok {
|
},
|
||||||
enc.KekKeyVersion = types.StringValue(kkvVal)
|
)
|
||||||
}
|
|
||||||
if sa, ok := resp.Encryption.GetServiceAccountOk(); ok {
|
|
||||||
enc.ServiceAccount = types.StringValue(sa)
|
|
||||||
}
|
|
||||||
return enc
|
return enc
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleDSEncryption(
|
func handleDSEncryption(
|
||||||
|
ctx context.Context,
|
||||||
m *dataSourceModel,
|
m *dataSourceModel,
|
||||||
resp *sqlserverflexbeta.GetInstanceResponse,
|
resp *sqlserverflexbeta.GetInstanceResponse,
|
||||||
) sqlserverflexbetaDataGen.EncryptionValue {
|
) sqlserverflexbetaDataGen.EncryptionValue {
|
||||||
|
|
@ -177,19 +175,15 @@ func handleDSEncryption(
|
||||||
return m.Encryption
|
return m.Encryption
|
||||||
}
|
}
|
||||||
|
|
||||||
enc := sqlserverflexbetaDataGen.NewEncryptionValueNull()
|
enc := sqlserverflexbetaDataGen.NewEncryptionValueMust(
|
||||||
if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok {
|
sqlserverflexbetaDataGen.EncryptionValue{}.AttributeTypes(ctx),
|
||||||
enc.KekKeyId = types.StringValue(kVal)
|
map[string]attr.Value{
|
||||||
}
|
"kek_key_id": types.StringValue(resp.Encryption.GetKekKeyId()),
|
||||||
if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok {
|
"kek_key_ring_id": types.StringValue(resp.Encryption.GetKekKeyRingId()),
|
||||||
enc.KekKeyRingId = types.StringValue(kkVal)
|
"kek_key_version": types.StringValue(resp.Encryption.GetKekKeyVersion()),
|
||||||
}
|
"service_account": types.StringValue(resp.Encryption.GetServiceAccount()),
|
||||||
if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok {
|
},
|
||||||
enc.KekKeyVersion = types.StringValue(kkvVal)
|
)
|
||||||
}
|
|
||||||
if sa, ok := resp.Encryption.GetServiceAccountOk(); ok {
|
|
||||||
enc.ServiceAccount = types.StringValue(sa)
|
|
||||||
}
|
|
||||||
return enc
|
return enc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue