Skip to content

Commit

Permalink
feat: faraway-replica tag fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wai-wong-edb committed Aug 14, 2024
1 parent cc22afe commit b9397c7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/provider/resource_fareplica.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/EnterpriseDB/terraform-provider-biganimal/pkg/api"
"github.com/EnterpriseDB/terraform-provider-biganimal/pkg/constants"
"github.com/EnterpriseDB/terraform-provider-biganimal/pkg/models"
commonApi "github.com/EnterpriseDB/terraform-provider-biganimal/pkg/models/common/api"
commonTerraform "github.com/EnterpriseDB/terraform-provider-biganimal/pkg/models/common/terraform"
"github.com/EnterpriseDB/terraform-provider-biganimal/pkg/plan_modifier"
"github.com/EnterpriseDB/terraform-provider-biganimal/pkg/utils"
"github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts"
Expand Down Expand Up @@ -62,6 +64,7 @@ type FAReplicaResourceModel struct {
PgIdentity types.String `tfsdk:"pg_identity"`
TransparentDataEncryptionAction types.String `tfsdk:"transparent_data_encryption_action"`
VolumeSnapshot types.Bool `tfsdk:"volume_snapshot_backup"`
Tags []commonTerraform.Tag `tfsdk:"tags"`

Timeouts timeouts.Value `tfsdk:"timeouts"`
}
Expand Down Expand Up @@ -687,6 +690,15 @@ func readFAReplica(ctx context.Context, client *api.ClusterClient, fAReplicaReso
fAReplicaResourceModel.TransparentDataEncryption.Status = types.StringValue(responseCluster.EncryptionKeyResp.Status)
}

fAReplicaResourceModel.Tags = []commonTerraform.Tag{}
for _, v := range responseCluster.Tags {
fAReplicaResourceModel.Tags = append(fAReplicaResourceModel.Tags, commonTerraform.Tag{
TagId: types.StringValue(v.TagId),
TagName: types.StringValue(v.TagName),
Color: basetypes.NewStringPointerValue(v.Color),
})
}

return nil
}

Expand Down Expand Up @@ -788,6 +800,16 @@ func (r *FAReplicaResource) generateGenericFAReplicaModel(ctx context.Context, f
}
}

tags := []commonApi.Tag{}
for _, tag := range fAReplicaResourceModel.Tags {
tags = append(tags, commonApi.Tag{
Color: tag.Color.ValueStringPointer(),
TagId: tag.TagId.ValueString(),
TagName: tag.TagName.ValueString(),
})
}
cluster.Tags = tags

return cluster, nil
}

Expand Down

0 comments on commit b9397c7

Please sign in to comment.