Skip to content

Commit ac4b716

Browse files
Shravan Thatikondaganbaras
authored andcommitted
Bug Fix - Database vmcluster update to include cloudautomationupdate only when changed
1 parent 4a76161 commit ac4b716

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

internal/service/database/database_cloud_vm_cluster_resource.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ func (s *DatabaseCloudVmClusterResourceCrud) Update() error {
908908
}
909909
}
910910

911-
if cloudAutomationUpdateDetails, ok := s.D.GetOkExists("cloud_automation_update_details"); ok {
911+
if cloudAutomationUpdateDetails, ok := s.D.GetOkExists("cloud_automation_update_details"); ok && s.D.HasChange("cloud_automation_update_details") {
912912
if tmpList := cloudAutomationUpdateDetails.([]interface{}); len(tmpList) > 0 {
913913
fieldKeyFormat := fmt.Sprintf("%s.%d.%%s", "cloud_automation_update_details", 0)
914914
tmp, err := s.mapToCloudAutomationUpdateDetails(fieldKeyFormat)
@@ -1370,8 +1370,7 @@ func (s *DatabaseCloudVmClusterResourceCrud) mapToCloudAutomationUpdateDetails(f
13701370
result.ApplyUpdateTimePreference = &tmp
13711371
}
13721372
}
1373-
1374-
if freezePeriod, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "freeze_period")); ok {
1373+
if freezePeriod, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "freeze_period")); ok && s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "freeze_period")) {
13751374
if tmpList := freezePeriod.([]interface{}); len(tmpList) > 0 {
13761375
fieldKeyFormatNextLevel := fmt.Sprintf("%s.%d.%%s", fmt.Sprintf(fieldKeyFormat, "freeze_period"), 0)
13771376
tmp, err := s.mapToCloudAutomationFreezePeriod(fieldKeyFormatNextLevel)
@@ -1387,7 +1386,7 @@ func (s *DatabaseCloudVmClusterResourceCrud) mapToCloudAutomationUpdateDetails(f
13871386
result.IsEarlyAdoptionEnabled = &tmp
13881387
}
13891388

1390-
if isFreezePeriodEnabled, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_freeze_period_enabled")); ok {
1389+
if isFreezePeriodEnabled, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_freeze_period_enabled")); ok && s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "is_freeze_period_enabled")) {
13911390
tmp := isFreezePeriodEnabled.(bool)
13921391
result.IsFreezePeriodEnabled = &tmp
13931392
}

internal/service/database/database_vm_cluster_resource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ func (s *DatabaseVmClusterResourceCrud) Update() error {
633633
}
634634
request := oci_database.UpdateVmClusterRequest{}
635635

636-
if cloudAutomationUpdateDetails, ok := s.D.GetOkExists("cloud_automation_update_details"); ok {
636+
if cloudAutomationUpdateDetails, ok := s.D.GetOkExists("cloud_automation_update_details"); ok && s.D.HasChange("cloud_automation_update_details") { //
637637
if tmpList := cloudAutomationUpdateDetails.([]interface{}); len(tmpList) > 0 {
638638
fieldKeyFormat := fmt.Sprintf("%s.%d.%%s", "cloud_automation_update_details", 0)
639639
tmp, err := s.mapToCloudAutomationUpdateDetails(fieldKeyFormat)
@@ -962,7 +962,7 @@ func (s *DatabaseVmClusterResourceCrud) mapToCloudAutomationUpdateDetails(fieldK
962962
}
963963
}
964964

965-
if freezePeriod, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "freeze_period")); ok {
965+
if freezePeriod, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "freeze_period")); ok && s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "freeze_period")) {
966966
if tmpList := freezePeriod.([]interface{}); len(tmpList) > 0 {
967967
fieldKeyFormatNextLevel := fmt.Sprintf("%s.%d.%%s", fmt.Sprintf(fieldKeyFormat, "freeze_period"), 0)
968968
tmp, err := s.mapToCloudAutomationFreezePeriod(fieldKeyFormatNextLevel)
@@ -978,7 +978,7 @@ func (s *DatabaseVmClusterResourceCrud) mapToCloudAutomationUpdateDetails(fieldK
978978
result.IsEarlyAdoptionEnabled = &tmp
979979
}
980980

981-
if isFreezePeriodEnabled, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_freeze_period_enabled")); ok {
981+
if isFreezePeriodEnabled, ok := s.D.GetOkExists(fmt.Sprintf(fieldKeyFormat, "is_freeze_period_enabled")); ok && s.D.HasChange(fmt.Sprintf(fieldKeyFormat, "is_freeze_period_enabled")) {
982982
tmp := isFreezePeriodEnabled.(bool)
983983
result.IsFreezePeriodEnabled = &tmp
984984
}

0 commit comments

Comments
 (0)