Skip to content

Commit 12b8e05

Browse files
committed
terraform fmt
1 parent bb8ec13 commit 12b8e05

6 files changed

+21
-22
lines changed

internal/convert/adv2v2.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,9 @@ func convertDynamicRepSpecsWithoutNumShards(resourceb *hclwrite.Body, dSpec, dCo
394394

395395
// Build the for expression as an array wrapped in flatten
396396
// Format: flatten([for spec in ... : [ { ... } ] ])
397-
forExpr := fmt.Sprintf("for %s in %s : [\n ", nSpec, hcl.GetAttrExpr(dSpec.forEach))
397+
forExpr := fmt.Sprintf("for %s in %s : ", nSpec, hcl.GetAttrExpr(dSpec.forEach))
398398
innerTokens := hcl.TokensFromExpr(forExpr)
399-
innerTokens = append(innerTokens, hcl.TokensObject(repSpecb)...)
400-
innerTokens = append(innerTokens, hcl.TokensFromExpr("\n ]")...)
399+
innerTokens = append(innerTokens, hcl.TokensArraySingle(repSpecb)...)
401400

402401
// Apply flatten to the entire expression
403402
tokens := hcl.TokensFuncFlatten(innerTokens)

internal/convert/testdata/adv2v2/dynamic_replication_specs_different_var_name.out.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ resource "mongodbatlas_advanced_cluster" "different_var_names_no_zone_name_no_nu
3030
cluster_type = var.cluster_type
3131
replication_specs = flatten([
3232
for spec in var.my_rep_specs : [
33-
{
34-
region_configs = [
35-
for region in spec.region_configs : {
36-
priority = region.prio
37-
provider_name = region.provider_name
38-
region_name = region.my_region_name
39-
electable_specs = {
40-
instance_size = region.instance_size
41-
node_count = region.my_electable_node_count
33+
{
34+
region_configs = [
35+
for region in spec.region_configs : {
36+
priority = region.prio
37+
provider_name = region.provider_name
38+
region_name = region.my_region_name
39+
electable_specs = {
40+
instance_size = region.instance_size
41+
node_count = region.my_electable_node_count
42+
}
4243
}
43-
}
44-
]
45-
}
44+
]
45+
}
4646
]
4747
])
4848

internal/convert/testdata/clu2adv/autoscaling.in.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ resource "mongodbatlas_cluster" "autoscaling" {
22
project_id = var.project_id
33
name = var.cluster_name
44
disk_size_gb = 100
5-
num_shards = 1
5+
num_shards = 1
66
cluster_type = "REPLICASET"
77

88
replication_specs {

internal/convert/testdata/clu2adv/autoscaling_missing_attribute.in.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ resource "mongodbatlas_cluster" "autoscaling" {
22
project_id = var.project_id
33
name = var.cluster_name
44
disk_size_gb = 100
5-
num_shards = 1
5+
num_shards = 1
66
cluster_type = "REPLICASET"
77

88
replication_specs {

internal/convert/testdata/clu2adv/free_cluster_missing_attribute.in.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ resource "resource1" "res1" {
44

55
resource "mongodbatlas_cluster" "free_cluster" { # comment in the resource
66
# comment in own line in the beginning
7-
count = local.use_free_cluster ? 1 : 0
8-
project_id = var.project_id # inline comment kept
9-
name = var.cluster_name
7+
count = local.use_free_cluster ? 1 : 0
8+
project_id = var.project_id # inline comment kept
9+
name = var.cluster_name
1010
# comment in own line in the middle is deleted
1111
provider_name = "TENANT" # inline comment for attribute moved is not kept
1212
provider_region_name = var.region

internal/convert/testdata/clu2adv/replication_specs_missing_regions_config.in.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ resource "mongodbatlas_cluster" "autoscaling" {
22
project_id = var.project_id
33
name = var.cluster_name
44
disk_size_gb = 100
5-
num_shards = 1
5+
num_shards = 1
66
cluster_type = "REPLICASET"
77

88
replication_specs {
99
num_shards = 1
1010
}
11-
11+
1212
//Provider Settings "block"
1313
provider_name = "AWS"
1414
provider_auto_scaling_compute_min_instance_size = "M10"

0 commit comments

Comments
 (0)