@@ -11,22 +11,22 @@ import (
1111)
1212
1313const (
14- resourceType = "resource"
15- cluster = "mongodbatlas_cluster"
16- advCluster = "mongodbatlas_advanced_cluster"
17- strReplicationSpecs = "replication_specs"
18- strRegionConfigs = "region_configs"
19- strElectableSpecs = "electable_specs"
20- strProviderRegionName = "provider_region_name"
21- strRegionName = "region_name"
22- strProviderName = "provider_name"
23- strBackingProviderName = "backing_provider_name"
24- strProviderInstanceSizeName = "provider_instance_size_name"
25- strInstanceSize = "instance_size"
26- strClusterType = "cluster_type"
27- strPriority = "priority"
28-
29- errFreeCluster = "free cluster (because no " + strReplicationSpecs + ")"
14+ resourceType = "resource"
15+ cluster = "mongodbatlas_cluster"
16+ advCluster = "mongodbatlas_advanced_cluster"
17+ nameReplicationSpecs = "replication_specs"
18+ nameRegionConfigs = "region_configs"
19+ nameElectableSpecs = "electable_specs"
20+ nameProviderRegionName = "provider_region_name"
21+ nameRegionName = "region_name"
22+ nameProviderName = "provider_name"
23+ nameBackingProviderName = "backing_provider_name"
24+ nameProviderInstanceSizeName = "provider_instance_size_name"
25+ nameInstanceSize = "instance_size"
26+ nameClusterType = "cluster_type"
27+ namePriority = "priority"
28+
29+ errFreeCluster = "free cluster (because no " + nameReplicationSpecs + ")"
3030)
3131
3232// ClusterToAdvancedCluster transforms all mongodbatlas_cluster definitions in a
@@ -63,36 +63,36 @@ func ClusterToAdvancedCluster(config []byte) ([]byte, error) {
6363}
6464
6565func isFreeTier (body * hclwrite.Body ) bool {
66- return body .FirstMatchingBlock (strReplicationSpecs , nil ) == nil
66+ return body .FirstMatchingBlock (nameReplicationSpecs , nil ) == nil
6767}
6868
6969func fillFreeTier (body * hclwrite.Body ) error {
7070 const (
7171 valClusterType = "REPLICASET"
7272 valPriority = 7
7373 )
74- body .SetAttributeValue (strClusterType , cty .StringVal (valClusterType ))
74+ body .SetAttributeValue (nameClusterType , cty .StringVal (valClusterType ))
7575 regionConfig := hclwrite .NewEmptyFile ()
7676 regionConfigBody := regionConfig .Body ()
7777 setAttrInt (regionConfigBody , "priority" , valPriority )
78- if err := moveAttribute (strProviderRegionName , strRegionName , body , regionConfigBody , errFreeCluster ); err != nil {
78+ if err := moveAttribute (nameProviderRegionName , nameRegionName , body , regionConfigBody , errFreeCluster ); err != nil {
7979 return err
8080 }
81- if err := moveAttribute (strProviderName , strProviderName , body , regionConfigBody , errFreeCluster ); err != nil {
81+ if err := moveAttribute (nameProviderName , nameProviderName , body , regionConfigBody , errFreeCluster ); err != nil {
8282 return err
8383 }
84- if err := moveAttribute (strBackingProviderName , strBackingProviderName , body , regionConfigBody , errFreeCluster ); err != nil {
84+ if err := moveAttribute (nameBackingProviderName , nameBackingProviderName , body , regionConfigBody , errFreeCluster ); err != nil {
8585 return err
8686 }
8787 electableSpec := hclwrite .NewEmptyFile ()
88- if err := moveAttribute (strProviderInstanceSizeName , strInstanceSize , body , electableSpec .Body (), errFreeCluster ); err != nil {
88+ if err := moveAttribute (nameProviderInstanceSizeName , nameInstanceSize , body , electableSpec .Body (), errFreeCluster ); err != nil {
8989 return err
9090 }
91- regionConfigBody .SetAttributeRaw (strElectableSpecs , tokensObject (electableSpec ))
91+ regionConfigBody .SetAttributeRaw (nameElectableSpecs , tokensObject (electableSpec ))
9292
9393 replicationSpec := hclwrite .NewEmptyFile ()
94- replicationSpec .Body ().SetAttributeRaw (strRegionConfigs , tokensArrayObject (regionConfig ))
95- body .SetAttributeRaw (strReplicationSpecs , tokensArrayObject (replicationSpec ))
94+ replicationSpec .Body ().SetAttributeRaw (nameRegionConfigs , tokensArrayObject (regionConfig ))
95+ body .SetAttributeRaw (nameReplicationSpecs , tokensArrayObject (replicationSpec ))
9696 return nil
9797}
9898
0 commit comments