@@ -19,7 +19,6 @@ import (
19
19
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/constant"
20
20
"github.com/mongodb/terraform-provider-mongodbatlas/internal/common/conversion"
21
21
"github.com/mongodb/terraform-provider-mongodbatlas/internal/config"
22
- "github.com/mwielbut/pointy"
23
22
"github.com/spf13/cast"
24
23
matlas "go.mongodb.org/atlas/mongodbatlas"
25
24
"golang.org/x/exp/slices"
@@ -370,7 +369,7 @@ func resourceMongoDBAtlasAdvancedClusterCreate(ctx context.Context, d *schema.Re
370
369
}
371
370
372
371
if v , ok := d .GetOk ("backup_enabled" ); ok {
373
- request .BackupEnabled = pointy . Bool (v .(bool ))
372
+ request .BackupEnabled = conversion . Pointer (v .(bool ))
374
373
}
375
374
if _ , ok := d .GetOk ("bi_connector_config" ); ok {
376
375
biConnector , err := ExpandBiConnectorConfig (d )
@@ -380,7 +379,7 @@ func resourceMongoDBAtlasAdvancedClusterCreate(ctx context.Context, d *schema.Re
380
379
request .BiConnector = biConnector
381
380
}
382
381
if v , ok := d .GetOk ("disk_size_gb" ); ok {
383
- request .DiskSizeGB = pointy . Float64 (v .(float64 ))
382
+ request .DiskSizeGB = conversion . Pointer (v .(float64 ))
384
383
}
385
384
if v , ok := d .GetOk ("encryption_at_rest_provider" ); ok {
386
385
request .EncryptionAtRestProvider = v .(string )
@@ -398,13 +397,13 @@ func resourceMongoDBAtlasAdvancedClusterCreate(ctx context.Context, d *schema.Re
398
397
request .MongoDBMajorVersion = FormatMongoDBMajorVersion (v .(string ))
399
398
}
400
399
if v , ok := d .GetOk ("pit_enabled" ); ok {
401
- request .PitEnabled = pointy . Bool (v .(bool ))
400
+ request .PitEnabled = conversion . Pointer (v .(bool ))
402
401
}
403
402
if v , ok := d .GetOk ("root_cert_type" ); ok {
404
403
request .RootCertType = v .(string )
405
404
}
406
405
if v , ok := d .GetOk ("termination_protection_enabled" ); ok {
407
- request .TerminationProtectionEnabled = pointy . Bool (v .(bool ))
406
+ request .TerminationProtectionEnabled = conversion . Pointer (v .(bool ))
408
407
}
409
408
if v , ok := d .GetOk ("version_release_system" ); ok {
410
409
request .VersionReleaseSystem = v .(string )
@@ -458,7 +457,7 @@ func resourceMongoDBAtlasAdvancedClusterCreate(ctx context.Context, d *schema.Re
458
457
// To pause a cluster
459
458
if v := d .Get ("paused" ).(bool ); v {
460
459
request = & matlas.AdvancedCluster {
461
- Paused : pointy . Bool (v ),
460
+ Paused : conversion . Pointer (v ),
462
461
}
463
462
464
463
_ , _ , err = updateAdvancedCluster (ctx , conn , request , projectID , d .Get ("name" ).(string ), timeout )
@@ -646,7 +645,7 @@ func resourceMongoDBAtlasAdvancedClusterUpdate(ctx context.Context, d *schema.Re
646
645
clusterChangeDetect := new (matlas.AdvancedCluster )
647
646
648
647
if d .HasChange ("backup_enabled" ) {
649
- cluster .BackupEnabled = pointy . Bool (d .Get ("backup_enabled" ).(bool ))
648
+ cluster .BackupEnabled = conversion . Pointer (d .Get ("backup_enabled" ).(bool ))
650
649
}
651
650
652
651
if d .HasChange ("bi_connector_config" ) {
@@ -658,7 +657,7 @@ func resourceMongoDBAtlasAdvancedClusterUpdate(ctx context.Context, d *schema.Re
658
657
}
659
658
660
659
if d .HasChange ("disk_size_gb" ) {
661
- cluster .DiskSizeGB = pointy . Float64 (d .Get ("disk_size_gb" ).(float64 ))
660
+ cluster .DiskSizeGB = conversion . Pointer (d .Get ("disk_size_gb" ).(float64 ))
662
661
}
663
662
664
663
if d .HasChange ("encryption_at_rest_provider" ) {
@@ -682,7 +681,7 @@ func resourceMongoDBAtlasAdvancedClusterUpdate(ctx context.Context, d *schema.Re
682
681
}
683
682
684
683
if d .HasChange ("pit_enabled" ) {
685
- cluster .PitEnabled = pointy . Bool (d .Get ("pit_enabled" ).(bool ))
684
+ cluster .PitEnabled = conversion . Pointer (d .Get ("pit_enabled" ).(bool ))
686
685
}
687
686
688
687
if d .HasChange ("replication_specs" ) {
@@ -694,7 +693,7 @@ func resourceMongoDBAtlasAdvancedClusterUpdate(ctx context.Context, d *schema.Re
694
693
}
695
694
696
695
if d .HasChange ("termination_protection_enabled" ) {
697
- cluster .TerminationProtectionEnabled = pointy . Bool (d .Get ("termination_protection_enabled" ).(bool ))
696
+ cluster .TerminationProtectionEnabled = conversion . Pointer (d .Get ("termination_protection_enabled" ).(bool ))
698
697
}
699
698
700
699
if d .HasChange ("version_release_system" ) {
@@ -706,7 +705,7 @@ func resourceMongoDBAtlasAdvancedClusterUpdate(ctx context.Context, d *schema.Re
706
705
}
707
706
708
707
if d .HasChange ("paused" ) && ! d .Get ("paused" ).(bool ) {
709
- cluster .Paused = pointy . Bool (d .Get ("paused" ).(bool ))
708
+ cluster .Paused = conversion . Pointer (d .Get ("paused" ).(bool ))
710
709
}
711
710
712
711
timeout := d .Timeout (schema .TimeoutUpdate )
@@ -743,7 +742,7 @@ func resourceMongoDBAtlasAdvancedClusterUpdate(ctx context.Context, d *schema.Re
743
742
744
743
if d .Get ("paused" ).(bool ) {
745
744
clusterRequest := & matlas.AdvancedCluster {
746
- Paused : pointy . Bool (true ),
745
+ Paused : conversion . Pointer (true ),
747
746
}
748
747
749
748
_ , _ , err := updateAdvancedCluster (ctx , conn , clusterRequest , projectID , clusterName , timeout )
@@ -765,7 +764,7 @@ func resourceMongoDBAtlasAdvancedClusterDelete(ctx context.Context, d *schema.Re
765
764
var options * matlas.DeleteAdvanceClusterOptions
766
765
if v , ok := d .GetOkExists ("retain_backups_enabled" ); ok {
767
766
options = & matlas.DeleteAdvanceClusterOptions {
768
- RetainBackups : pointy . Bool (v .(bool )),
767
+ RetainBackups : conversion . Pointer (v .(bool )),
769
768
}
770
769
}
771
770
@@ -886,7 +885,7 @@ func expandRegionConfig(tfMap map[string]any) *matlas.AdvancedRegionConfig {
886
885
887
886
providerName := tfMap ["provider_name" ].(string )
888
887
apiObject := & matlas.AdvancedRegionConfig {
889
- Priority : pointy . Int (cast .ToInt (tfMap ["priority" ])),
888
+ Priority : conversion . Pointer (cast .ToInt (tfMap ["priority" ])),
890
889
ProviderName : providerName ,
891
890
RegionName : tfMap ["region_name" ].(string ),
892
891
}
@@ -946,7 +945,7 @@ func expandRegionConfigSpec(tfList []any, providerName string) *matlas.Specs {
946
945
947
946
if providerName == "AWS" {
948
947
if v , ok := tfMap ["disk_iops" ]; ok && v .(int ) > 0 {
949
- apiObject .DiskIOPS = pointy . Int64 (cast .ToInt64 (v .(int )))
948
+ apiObject .DiskIOPS = conversion . Pointer (cast .ToInt64 (v .(int )))
950
949
}
951
950
if v , ok := tfMap ["ebs_volume_type" ]; ok {
952
951
apiObject .EbsVolumeType = v .(string )
@@ -956,7 +955,7 @@ func expandRegionConfigSpec(tfList []any, providerName string) *matlas.Specs {
956
955
apiObject .InstanceSize = v .(string )
957
956
}
958
957
if v , ok := tfMap ["node_count" ]; ok {
959
- apiObject .NodeCount = pointy . Int (v .(int ))
958
+ apiObject .NodeCount = conversion . Pointer (v .(int ))
960
959
}
961
960
962
961
return apiObject
@@ -974,13 +973,13 @@ func expandRegionConfigAutoScaling(tfList []any) *matlas.AdvancedAutoScaling {
974
973
compute := & matlas.Compute {}
975
974
976
975
if v , ok := tfMap ["disk_gb_enabled" ]; ok {
977
- diskGB .Enabled = pointy . Bool (v .(bool ))
976
+ diskGB .Enabled = conversion . Pointer (v .(bool ))
978
977
}
979
978
if v , ok := tfMap ["compute_enabled" ]; ok {
980
- compute .Enabled = pointy . Bool (v .(bool ))
979
+ compute .Enabled = conversion . Pointer (v .(bool ))
981
980
}
982
981
if v , ok := tfMap ["compute_scale_down_enabled" ]; ok {
983
- compute .ScaleDownEnabled = pointy . Bool (v .(bool ))
982
+ compute .ScaleDownEnabled = conversion . Pointer (v .(bool ))
984
983
}
985
984
if v , ok := tfMap ["compute_min_instance_size" ]; ok {
986
985
value := compute .ScaleDownEnabled
@@ -1011,19 +1010,19 @@ func flattenAdvancedReplicationSpec(ctx context.Context, apiObject *matlas.Advan
1011
1010
tfMap ["num_shards" ] = apiObject .NumShards
1012
1011
tfMap ["id" ] = apiObject .ID
1013
1012
if tfMapObject != nil {
1014
- object , containerIds , err := flattenAdvancedReplicationSpecRegionConfigs (ctx , apiObject .RegionConfigs , tfMapObject ["region_configs" ].([]any ), d , conn )
1013
+ object , containerIDs , err := flattenAdvancedReplicationSpecRegionConfigs (ctx , apiObject .RegionConfigs , tfMapObject ["region_configs" ].([]any ), d , conn )
1015
1014
if err != nil {
1016
1015
return nil , err
1017
1016
}
1018
1017
tfMap ["region_configs" ] = object
1019
- tfMap ["container_id" ] = containerIds
1018
+ tfMap ["container_id" ] = containerIDs
1020
1019
} else {
1021
- object , containerIds , err := flattenAdvancedReplicationSpecRegionConfigs (ctx , apiObject .RegionConfigs , nil , d , conn )
1020
+ object , containerIDs , err := flattenAdvancedReplicationSpecRegionConfigs (ctx , apiObject .RegionConfigs , nil , d , conn )
1022
1021
if err != nil {
1023
1022
return nil , err
1024
1023
}
1025
1024
tfMap ["region_configs" ] = object
1026
- tfMap ["container_id" ] = containerIds
1025
+ tfMap ["container_id" ] = containerIDs
1027
1026
}
1028
1027
tfMap ["zone_name" ] = apiObject .ZoneName
1029
1028
@@ -1149,7 +1148,7 @@ func flattenAdvancedReplicationSpecRegionConfigs(ctx context.Context, apiObjects
1149
1148
}
1150
1149
1151
1150
var tfList []map [string ]any
1152
- containerIds := make (map [string ]string )
1151
+ containerIDs := make (map [string ]string )
1153
1152
1154
1153
for i , apiObject := range apiObjects {
1155
1154
if apiObject == nil {
@@ -1171,12 +1170,12 @@ func flattenAdvancedReplicationSpecRegionConfigs(ctx context.Context, apiObjects
1171
1170
}
1172
1171
if result := getAdvancedClusterContainerID (containers , apiObject ); result != "" {
1173
1172
// Will print as "providerName:regionName" = "containerId" in terraform show
1174
- containerIds [fmt .Sprintf ("%s:%s" , apiObject .ProviderName , apiObject .RegionName )] = result
1173
+ containerIDs [fmt .Sprintf ("%s:%s" , apiObject .ProviderName , apiObject .RegionName )] = result
1175
1174
}
1176
1175
}
1177
1176
}
1178
1177
1179
- return tfList , containerIds , nil
1178
+ return tfList , containerIDs , nil
1180
1179
}
1181
1180
1182
1181
func flattenAdvancedReplicationSpecRegionConfigSpec (apiObject * matlas.Specs , providerName string , tfMapObjects []any ) []map [string ]any {
0 commit comments