chore: changed and refactored providers (#36)
## Description
<!-- **Please link some issue here describing what you are trying to achieve.**
In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->
relates to #1234
## Checklist
- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] Acceptance tests got implemented or updated (see e.g. [here](f5f99d1709/stackit/internal/services/dns/dns_acc_test.go))
- [x] Unit tests are passing: `make test` (will be checked by CI)
- [x] No linter issues: `make lint` (will be checked by CI)
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Reviewed-on: #36
Reviewed-by: Marcel_Henselin <marcel.henselin@stackit.cloud>
Co-authored-by: Andre Harms <andre.harms@stackit.cloud>
Co-committed-by: Andre Harms <andre.harms@stackit.cloud>
This commit is contained in:
parent
b1b359f436
commit
de019908d2
70 changed files with 6250 additions and 2608 deletions
|
|
@ -14,26 +14,32 @@ import (
|
|||
"tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/stackit/internal/utils"
|
||||
)
|
||||
|
||||
func mapGetInstanceResponseToModel(ctx context.Context, m *postgresflexalpharesource.InstanceModel, resp *postgresflex.GetInstanceResponse) error {
|
||||
tflog.Debug(ctx, ">>>> MSH DEBUG <<<<", map[string]interface{}{
|
||||
"id": m.Id.ValueString(),
|
||||
"instance_id": m.InstanceId.ValueString(),
|
||||
"backup_schedule": m.BackupSchedule.ValueString(),
|
||||
"flavor_id": m.FlavorId.ValueString(),
|
||||
"encryption.kek_key_id": m.Encryption.KekKeyId.ValueString(),
|
||||
"encryption.kek_key_ring_id": m.Encryption.KekKeyRingId.ValueString(),
|
||||
"encryption.kek_key_version": m.Encryption.KekKeyVersion.ValueString(),
|
||||
"encryption.service_account": m.Encryption.ServiceAccount.ValueString(),
|
||||
"is_deletable": m.IsDeletable.ValueBool(),
|
||||
"name": m.Name.ValueString(),
|
||||
"status": m.Status.ValueString(),
|
||||
"retention_days": m.RetentionDays.ValueInt64(),
|
||||
"replicas": m.Replicas.ValueInt64(),
|
||||
"network.instance_address": m.Network.InstanceAddress.ValueString(),
|
||||
"network.router_address": m.Network.RouterAddress.ValueString(),
|
||||
"version": m.Version.ValueString(),
|
||||
"network.acl": m.Network.Acl.String(),
|
||||
})
|
||||
func mapGetInstanceResponseToModel(
|
||||
ctx context.Context,
|
||||
m *postgresflexalpharesource.InstanceModel,
|
||||
resp *postgresflex.GetInstanceResponse,
|
||||
) error {
|
||||
tflog.Debug(
|
||||
ctx, ">>>> MSH DEBUG <<<<", map[string]interface{}{
|
||||
"id": m.Id.ValueString(),
|
||||
"instance_id": m.InstanceId.ValueString(),
|
||||
"backup_schedule": m.BackupSchedule.ValueString(),
|
||||
"flavor_id": m.FlavorId.ValueString(),
|
||||
"encryption.kek_key_id": m.Encryption.KekKeyId.ValueString(),
|
||||
"encryption.kek_key_ring_id": m.Encryption.KekKeyRingId.ValueString(),
|
||||
"encryption.kek_key_version": m.Encryption.KekKeyVersion.ValueString(),
|
||||
"encryption.service_account": m.Encryption.ServiceAccount.ValueString(),
|
||||
"is_deletable": m.IsDeletable.ValueBool(),
|
||||
"name": m.Name.ValueString(),
|
||||
"status": m.Status.ValueString(),
|
||||
"retention_days": m.RetentionDays.ValueInt64(),
|
||||
"replicas": m.Replicas.ValueInt64(),
|
||||
"network.instance_address": m.Network.InstanceAddress.ValueString(),
|
||||
"network.router_address": m.Network.RouterAddress.ValueString(),
|
||||
"version": m.Version.ValueString(),
|
||||
"network.acl": m.Network.Acl.String(),
|
||||
},
|
||||
)
|
||||
|
||||
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
||||
m.Encryption = postgresflexalpharesource.NewEncryptionValueNull()
|
||||
|
|
@ -61,7 +67,11 @@ func mapGetInstanceResponseToModel(ctx context.Context, m *postgresflexalphareso
|
|||
|
||||
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.Id = utils.BuildInternalTerraformId(
|
||||
m.ProjectId.ValueString(),
|
||||
m.Region.ValueString(),
|
||||
m.InstanceId.ValueString(),
|
||||
)
|
||||
}
|
||||
m.InstanceId = types.StringPointerValue(resp.Id)
|
||||
|
||||
|
|
@ -121,7 +131,11 @@ func mapGetInstanceResponseToModel(ctx context.Context, m *postgresflexalphareso
|
|||
return nil
|
||||
}
|
||||
|
||||
func mapGetDataInstanceResponseToModel(ctx context.Context, m *postgresflexalphadatasource.InstanceModel, resp *postgresflex.GetInstanceResponse) error {
|
||||
func mapGetDataInstanceResponseToModel(
|
||||
ctx context.Context,
|
||||
m *dataSourceModel,
|
||||
resp *postgresflex.GetInstanceResponse,
|
||||
) error {
|
||||
m.BackupSchedule = types.StringValue(resp.GetBackupSchedule())
|
||||
handleEncryption(m, resp)
|
||||
m.ConnectionInfo.Host = types.StringValue(resp.ConnectionInfo.GetHost())
|
||||
|
|
@ -155,7 +169,7 @@ func mapGetDataInstanceResponseToModel(ctx context.Context, m *postgresflexalpha
|
|||
return nil
|
||||
}
|
||||
|
||||
func handleNetwork(ctx context.Context, m *postgresflexalphadatasource.InstanceModel, resp *postgresflex.GetInstanceResponse) error {
|
||||
func handleNetwork(ctx context.Context, m *dataSourceModel, resp *postgresflex.GetInstanceResponse) error {
|
||||
netAcl, diags := types.ListValueFrom(ctx, types.StringType, resp.Network.GetAcl())
|
||||
if diags.HasError() {
|
||||
return fmt.Errorf("failed converting network acl from response")
|
||||
|
|
@ -187,7 +201,7 @@ func handleNetwork(ctx context.Context, m *postgresflexalphadatasource.InstanceM
|
|||
return nil
|
||||
}
|
||||
|
||||
func handleEncryption(m *postgresflexalphadatasource.InstanceModel, resp *postgresflex.GetInstanceResponse) {
|
||||
func handleEncryption(m *dataSourceModel, resp *postgresflex.GetInstanceResponse) {
|
||||
keyId := ""
|
||||
if keyIdVal, ok := resp.Encryption.GetKekKeyIdOk(); ok {
|
||||
keyId = keyIdVal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue