Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support service name in cluster resources #590

Merged
merged 3 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/data-sources/biganimal_cluster/data-source.tf
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,7 @@ output "service_account_ids" {
output "volume_snapshot_backup" {
value = coalesce(data.biganimal_cluster.this.post_gis, false)
}

output "service_name" {
value = data.biganimal_cluster.this.service_name
}
22 changes: 22 additions & 0 deletions pkg/provider/data_source_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,24 @@ func (c *clusterDataSource) Schema(ctx context.Context, req datasource.SchemaReq
"Pausing a high availability cluster shuts down all cluster nodes",
Optional: true,
},
"tags": schema.SetNestedAttribute{
Description: "Show existing tags associated with this resource",
Optional: true,
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
"tag_id": schema.StringAttribute{
Computed: true,
},
"tag_name": schema.StringAttribute{
Computed: true,
},
"color": schema.StringAttribute{
Computed: true,
},
},
},
},
"transparent_data_encryption": schema.SingleNestedAttribute{
MarkdownDescription: "Transparent Data Encryption (TDE) key",
Optional: true,
Expand Down Expand Up @@ -366,6 +384,10 @@ func (c *clusterDataSource) Schema(ctx context.Context, req datasource.SchemaReq
MarkdownDescription: "Transparent data encryption action.",
Computed: true,
},
"service_name": schema.StringAttribute{
MarkdownDescription: "Cluster connection service name.",
Computed: true,
},
},
}
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/provider/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type ClusterResourceModel struct {
TransparentDataEncryptionAction types.String `tfsdk:"transparent_data_encryption_action"`
VolumeSnapshot types.Bool `tfsdk:"volume_snapshot_backup"`
Tags []commonTerraform.Tag `tfsdk:"tags"`
ServiceName types.String `tfsdk:"service_name"`

Timeouts timeouts.Value `tfsdk:"timeouts"`
}
Expand Down Expand Up @@ -569,6 +570,11 @@ func (c *clusterResource) Schema(ctx context.Context, req resource.SchemaRequest
Computed: true,
PlanModifiers: []planmodifier.String{plan_modifier.CustomTDEAction()},
},
"service_name": schema.StringAttribute{
MarkdownDescription: "Cluster connection service name.",
Computed: true,
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()},
},
},
}
}
Expand Down Expand Up @@ -845,6 +851,7 @@ func readCluster(ctx context.Context, client *api.ClusterClient, tfClusterResour
tfClusterResource.ReadOnlyConnections = types.BoolPointerValue(responseCluster.ReadOnlyConnections)
tfClusterResource.ConnectionUri = types.StringPointerValue(&connection.PgUri)
tfClusterResource.RoConnectionUri = types.StringPointerValue(&connection.ReadOnlyPgUri)
tfClusterResource.ServiceName = types.StringPointerValue(&connection.ServiceName)
tfClusterResource.CspAuth = types.BoolPointerValue(responseCluster.CSPAuth)
tfClusterResource.LogsUrl = responseCluster.LogsUrl
tfClusterResource.MetricsUrl = responseCluster.MetricsUrl
Expand Down
Loading