Skip to content

Commit

Permalink
azurerm_cosmosdb_postgresql_cluster: fix naming convention and wron…
Browse files Browse the repository at this point in the history
…g nil handling
  • Loading branch information
reastyn committed Mar 15, 2024
1 parent 1533adc commit 011d413
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
13 changes: 7 additions & 6 deletions internal/services/cosmos/cosmosdb_postgresql_cluster_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type CosmosDbPostgreSQLClusterModel struct {
SourceLocation string `tfschema:"source_location"`
SourceResourceId string `tfschema:"source_resource_id"`
MaintenanceWindow []MaintenanceWindow `tfschema:"maintenance_window"`
ServerNames []ServerNameItem `tfschema:"server_names"`
ServerNames []ServerNameItem `tfschema:"servers"`
NodeCount int64 `tfschema:"node_count"`
NodePublicIPAccessEnabled bool `tfschema:"node_public_ip_access_enabled"`
NodeServerEdition string `tfschema:"node_server_edition"`
Expand Down Expand Up @@ -310,7 +310,7 @@ func (r CosmosDbPostgreSQLClusterResource) Attributes() map[string]*pluginsdk.Sc
Type: pluginsdk.TypeString,
Computed: true,
},
"server_names": {
"servers": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Resource{
Expand Down Expand Up @@ -580,7 +580,7 @@ func (r CosmosDbPostgreSQLClusterResource) Read() sdk.ResourceFunc {
state.CoordinatorServerEdition = pointer.From(props.CoordinatorServerEdition)
state.CoordinatorStorageQuotaInMb = pointer.From(props.CoordinatorStorageQuotaInMb)
state.CoordinatorVCoreCount = pointer.From(props.CoordinatorVCores)
state.ServerNames = formatServerNames(props.ServerNames)
state.ServerNames = flattenServerNames(props.ServerNames)
state.HaEnabled = pointer.From(props.EnableHa)
state.NodeCount = pointer.From(props.NodeCount)
state.NodePublicIPAccessEnabled = pointer.From(props.NodeEnablePublicIPAccess)
Expand Down Expand Up @@ -660,12 +660,13 @@ func flattenMaintenanceWindow(input *clusters.MaintenanceWindow) []MaintenanceWi
}
}

func formatServerNames(input *[]clusters.ServerNameItem) []ServerNameItem {
func flattenServerNames(input *[]clusters.ServerNameItem) []ServerNameItem {
var output []ServerNameItem

if input == nil {
return nil
return output
}

var output []ServerNameItem
for _, v := range *input {
output = append(output, ServerNameItem{
FullyQualifiedDomainName: *v.FullyQualifiedDomainName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func TestAccCosmosDbPostgreSQLCluster_basic(t *testing.T) {
Config: r.basic(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("server_names.0.fqdn").IsNotEmpty(),
check.That(data.ResourceName).Key("server_names.0.name").IsNotEmpty(),
check.That(data.ResourceName).Key("servers.0.fqdn").IsNotEmpty(),
check.That(data.ResourceName).Key("servers.0.name").IsNotEmpty(),
),
},
data.ImportStep("administrator_login_password"),
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/cosmosdb_postgresql_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `earliest_restore_time` - The earliest restore point time (ISO8601 format) for the Azure Cosmos DB for PostgreSQL Cluster.

* `server_names` - The name of the servers and its fully qualified domain name
* `servers` - The name of the servers and its fully qualified domain name

## Timeouts

Expand Down

0 comments on commit 011d413

Please sign in to comment.