File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,12 @@ import (
88 "github.com/hashicorp/hcl/v2/hclwrite"
99)
1010
11+ const (
12+ resourceType = "resource"
13+ cluster = "mongodbatlas_cluster"
14+ advCluster = "mongodbatlas_advanced_cluster"
15+ )
16+
1117// ClusterToAdvancedCluster transforms all cluster definition in a
1218// Terraform config file into an advanced_cluster definition.
1319// All other resources and data sources are left untouched.
@@ -18,16 +24,15 @@ func ClusterToAdvancedCluster(config []byte) ([]byte, error) {
1824 return nil , err
1925 }
2026 for _ , resource := range parser .Body ().Blocks () {
21- isResource := resource .Type () == "resource"
2227 labels := resource .Labels ()
2328 resourceName := labels [0 ]
24- if ! isResource || resourceName != "mongodbatlas_cluster" {
29+ if resource . Type () != resourceType || resourceName != cluster {
2530 continue
2631 }
2732 resourceBody := resource .Body ()
2833
2934 // TODO: Do the full transformation
30- labels [0 ] = "mongodbatlas_advanced_cluster"
35+ labels [0 ] = advCluster
3136 resource .SetLabels (labels )
3237 resourceBody .AppendNewline ()
3338 appendComment (resourceBody , "Generated by atlas-cli-plugin-terraform." )
You can’t perform that action at this time.
0 commit comments