@@ -171,9 +171,9 @@ func convertDynamicRepSpecs(resourceb *hclwrite.Body, dSpec dynamicBlock, diskSi
171
171
}
172
172
173
173
// Create the for expression for the flattened replication_specs
174
- outerFor := buildForExpression (nSpec , hcl .GetAttrExpr (dSpec .forEach ))
175
- innerFor := buildForExpressionWithIndex ("i" , fmt .Sprintf ("range(%s)" , numShardsExpr ))
176
- forExpr := fmt .Sprintf ("%s [\n %s" , outerFor , innerFor )
174
+ outerFor := buildForExpr (nSpec , hcl .GetAttrExpr (dSpec .forEach ))
175
+ innerFor := buildForExpr ("i" , fmt .Sprintf ("range(%s)" , numShardsExpr ))
176
+ forExpr := fmt .Sprintf ("%s [\n %s " , outerFor , innerFor )
177
177
tokens := hcl .TokensFromExpr (forExpr )
178
178
tokens = append (tokens , hcl .TokensObject (dSpec .content .Body ())... )
179
179
tokens = append (tokens , hcl .TokensFromExpr ("\n ]\n ]" )... )
@@ -191,7 +191,7 @@ func convertDynamicRepSpecs(resourceb *hclwrite.Body, dSpec dynamicBlock, diskSi
191
191
}
192
192
193
193
// Create the for expression without num_shards
194
- forExpr := buildForExpression (nSpec , hcl .GetAttrExpr (dSpec .forEach ))
194
+ forExpr := buildForExpr (nSpec , hcl .GetAttrExpr (dSpec .forEach ))
195
195
tokens := hcl .TokensFromExpr (forExpr )
196
196
tokens = append (tokens , hcl .TokensObject (dSpec .content .Body ())... )
197
197
tokens = hcl .EncloseBracketsNewLines (tokens )
@@ -257,7 +257,7 @@ func convertDynamicRepSpecsWithDynamicConfig(resourceb *hclwrite.Body, dSpec, dC
257
257
processRegionConfigBlocks (regionConfigBody , dConfig .content .Body ().Blocks (), diskSizeGB )
258
258
259
259
// Build the region_configs for expression
260
- regionForExpr := buildForExpression (nRegion , configForEach )
260
+ regionForExpr := buildForExpr (nRegion , configForEach )
261
261
regionTokens := hcl .TokensFromExpr (regionForExpr )
262
262
regionTokens = append (regionTokens , hcl .TokensObject (regionConfigBody )... )
263
263
@@ -273,13 +273,13 @@ func convertDynamicRepSpecsWithDynamicConfig(resourceb *hclwrite.Body, dSpec, dC
273
273
repSpecBody .SetAttributeRaw (nConfig , hcl .EncloseBracketsNewLines (regionTokens ))
274
274
275
275
// Build the inner for expression with range
276
- innerForExpr := buildForExpressionWithIndex ("i" , fmt .Sprintf ("range(%s)" , numShardsExpr ))
276
+ innerForExpr := buildForExpr ("i" , fmt .Sprintf ("range(%s)" , numShardsExpr ))
277
277
innerTokens := hcl .TokensFromExpr (innerForExpr )
278
278
innerTokens = append (innerTokens , hcl .TokensObject (repSpecBody )... )
279
279
280
280
// Build the outer for expression
281
- outerForExpr := buildForExpression (nSpec , hcl .GetAttrExpr (dSpec .forEach ))
282
- outerTokens := hcl .TokensFromExpr (outerForExpr )
281
+ outerForExpr := buildForExpr (nSpec , hcl .GetAttrExpr (dSpec .forEach ))
282
+ outerTokens := hcl .TokensFromExpr (fmt . Sprintf ( "%s " , outerForExpr ) )
283
283
outerTokens = append (outerTokens , hcl .EncloseBracketsNewLines (innerTokens )... )
284
284
285
285
// Apply flatten to the entire expression
@@ -339,16 +339,16 @@ func convertDynamicRepSpecsWithoutNumShards(resourceb *hclwrite.Body, dSpec, dCo
339
339
configForEach := fmt .Sprintf ("%s.%s" , nSpec , nConfig )
340
340
341
341
// Build the region_configs for expression
342
- regionForExpr := buildForExpression (nRegion , configForEach )
342
+ regionForExpr := buildForExpr (nRegion , configForEach )
343
343
regionTokens := hcl .TokensFromExpr (regionForExpr )
344
344
regionTokens = append (regionTokens , hcl .TokensObject (configb )... )
345
345
346
346
repSpecb .SetAttributeRaw (nConfig , hcl .EncloseBracketsNewLines (regionTokens ))
347
347
348
348
// Build the for expression as an array wrapped in flatten
349
349
// Format: flatten([for spec in ... : [ { ... } ] ])
350
- forExpr := buildForExpression (nSpec , hcl .GetAttrExpr (dSpec .forEach ))
351
- innerTokens := hcl .TokensFromExpr (forExpr )
350
+ forExpr := buildForExpr (nSpec , hcl .GetAttrExpr (dSpec .forEach ))
351
+ innerTokens := hcl .TokensFromExpr (fmt . Sprintf ( "%s " , forExpr ) )
352
352
innerTokens = append (innerTokens , hcl .TokensArraySingle (repSpecb )... )
353
353
354
354
// Apply flatten to the entire expression
@@ -406,7 +406,7 @@ func convertDynamicConfig(repSpecs *hclwrite.Body, dConfig dynamicBlock, diskSiz
406
406
processAllSpecs (dConfig .content .Body (), diskSizeGB )
407
407
408
408
// Build the for expression
409
- forExpr := buildForExpression (nRegion , hcl .GetAttrExpr (dConfig .forEach ))
409
+ forExpr := buildForExpr (nRegion , hcl .GetAttrExpr (dConfig .forEach ))
410
410
tokens := hcl .TokensFromExpr (forExpr )
411
411
tokens = append (tokens , hcl .TokensObject (dConfig .content .Body ())... )
412
412
tokens = hcl .EncloseBracketsNewLines (tokens )
0 commit comments