Skip to content

Commit ab86332

Browse files
committed
initial fillReplicationSpecsWithDynamicBlock
1 parent 08116f2 commit ab86332

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

internal/convert/convert.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,15 @@ func fillCluster(resourceb *hclwrite.Body) error {
195195
}
196196

197197
func fillReplicationSpecs(resourceb *hclwrite.Body, root attrVals) error {
198+
d, err := fillReplicationSpecsWithDynamicBlock(resourceb, root)
199+
if err != nil {
200+
return err
201+
}
202+
if d.IsPresent() {
203+
resourceb.RemoveBlock(d.block)
204+
resourceb.SetAttributeRaw(nRepSpecs, d.tokens)
205+
return nil
206+
}
198207
// at least one replication_specs exists here, if not it would be a free tier cluster
199208
var specbs []*hclwrite.Body
200209
for {
@@ -317,6 +326,15 @@ func fillBlockOpt(resourceb *hclwrite.Body, name string) {
317326
resourceb.SetAttributeRaw(name, hcl.TokensObject(block.Body()))
318327
}
319328

329+
// fillReplicationSpecsWithDynamicBlock used for dynamic blocks in replication_specs
330+
func fillReplicationSpecsWithDynamicBlock(resourceb *hclwrite.Body, root attrVals) (dynamicBlock, error) {
331+
d, err := getDynamicBlock(resourceb, nRepSpecs)
332+
if err != nil || !d.IsPresent() {
333+
return dynamicBlock{}, err
334+
}
335+
return d, nil
336+
}
337+
320338
// fillReplicationSpecsWithDynamicRegionConfigs is used for dynamic blocks in region_configs
321339
func fillReplicationSpecsWithDynamicRegionConfigs(specbSrc *hclwrite.Body, root attrVals) (dynamicBlock, error) {
322340
d, err := getDynamicBlock(specbSrc, nConfigSrc)

0 commit comments

Comments
 (0)