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
|
||||
}
|
||||
|
||||
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 {
|
||||
core.LogAndAddError(
|
||||
ctx,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ func mapResponseToModel(
|
|||
) error {
|
||||
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
||||
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.Id = types.StringValue(resp.GetId())
|
||||
m.InstanceId = types.StringValue(resp.GetId())
|
||||
|
|
@ -81,7 +81,7 @@ func mapDataResponseToModel(
|
|||
) error {
|
||||
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
||||
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.Id = types.StringValue(resp.GetId())
|
||||
m.InstanceId = types.StringValue(resp.GetId())
|
||||
|
|
@ -130,6 +130,7 @@ func mapDataResponseToModel(
|
|||
}
|
||||
|
||||
func handleEncryption(
|
||||
ctx context.Context,
|
||||
m *sqlserverflexbetaResGen.InstanceModel,
|
||||
resp *sqlserverflexbeta.GetInstanceResponse,
|
||||
) sqlserverflexbetaResGen.EncryptionValue {
|
||||
|
|
@ -145,23 +146,20 @@ func handleEncryption(
|
|||
return m.Encryption
|
||||
}
|
||||
|
||||
enc := sqlserverflexbetaResGen.NewEncryptionValueNull()
|
||||
if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok {
|
||||
enc.KekKeyId = types.StringValue(kVal)
|
||||
}
|
||||
if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok {
|
||||
enc.KekKeyRingId = types.StringValue(kkVal)
|
||||
}
|
||||
if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok {
|
||||
enc.KekKeyVersion = types.StringValue(kkvVal)
|
||||
}
|
||||
if sa, ok := resp.Encryption.GetServiceAccountOk(); ok {
|
||||
enc.ServiceAccount = types.StringValue(sa)
|
||||
}
|
||||
enc := sqlserverflexbetaResGen.NewEncryptionValueMust(
|
||||
sqlserverflexbetaResGen.EncryptionValue{}.AttributeTypes(ctx),
|
||||
map[string]attr.Value{
|
||||
"kek_key_id": types.StringValue(resp.Encryption.GetKekKeyId()),
|
||||
"kek_key_ring_id": types.StringValue(resp.Encryption.GetKekKeyRingId()),
|
||||
"kek_key_version": types.StringValue(resp.Encryption.GetKekKeyVersion()),
|
||||
"service_account": types.StringValue(resp.Encryption.GetServiceAccount()),
|
||||
},
|
||||
)
|
||||
return enc
|
||||
}
|
||||
|
||||
func handleDSEncryption(
|
||||
ctx context.Context,
|
||||
m *dataSourceModel,
|
||||
resp *sqlserverflexbeta.GetInstanceResponse,
|
||||
) sqlserverflexbetaDataGen.EncryptionValue {
|
||||
|
|
@ -177,19 +175,15 @@ func handleDSEncryption(
|
|||
return m.Encryption
|
||||
}
|
||||
|
||||
enc := sqlserverflexbetaDataGen.NewEncryptionValueNull()
|
||||
if kVal, ok := resp.Encryption.GetKekKeyIdOk(); ok {
|
||||
enc.KekKeyId = types.StringValue(kVal)
|
||||
}
|
||||
if kkVal, ok := resp.Encryption.GetKekKeyRingIdOk(); ok {
|
||||
enc.KekKeyRingId = types.StringValue(kkVal)
|
||||
}
|
||||
if kkvVal, ok := resp.Encryption.GetKekKeyVersionOk(); ok {
|
||||
enc.KekKeyVersion = types.StringValue(kkvVal)
|
||||
}
|
||||
if sa, ok := resp.Encryption.GetServiceAccountOk(); ok {
|
||||
enc.ServiceAccount = types.StringValue(sa)
|
||||
}
|
||||
enc := sqlserverflexbetaDataGen.NewEncryptionValueMust(
|
||||
sqlserverflexbetaDataGen.EncryptionValue{}.AttributeTypes(ctx),
|
||||
map[string]attr.Value{
|
||||
"kek_key_id": types.StringValue(resp.Encryption.GetKekKeyId()),
|
||||
"kek_key_ring_id": types.StringValue(resp.Encryption.GetKekKeyRingId()),
|
||||
"kek_key_version": types.StringValue(resp.Encryption.GetKekKeyVersion()),
|
||||
"service_account": types.StringValue(resp.Encryption.GetServiceAccount()),
|
||||
},
|
||||
)
|
||||
return enc
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue