Skip to content

Commit db532d0

Browse files
committed
extract consts
1 parent c946233 commit db532d0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

internal/hcl/hcl.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff 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.")

0 commit comments

Comments
 (0)