From 56dc532987c7e6cb5ba175f747bad64e8077f856 Mon Sep 17 00:00:00 2001 From: Heng Lu Date: Mon, 18 Mar 2024 10:58:10 +0800 Subject: [PATCH] `azurerm_backup_policy_file_share`, `azurerm_backup_policy_vm` - fix a bug that `include_last_days` is not working when `days` is empty --- .../recoveryservices/backup_policy_file_share_resource.go | 4 ++-- .../services/recoveryservices/backup_policy_vm_resource.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/recoveryservices/backup_policy_file_share_resource.go b/internal/services/recoveryservices/backup_policy_file_share_resource.go index 463aadd67c85..94d9e63a279b 100644 --- a/internal/services/recoveryservices/backup_policy_file_share_resource.go +++ b/internal/services/recoveryservices/backup_policy_file_share_resource.go @@ -326,7 +326,7 @@ func expandBackupProtectionPolicyFileShareRetentionMonthly(d *pluginsdk.Resource scheduleFormat := protectionpolicies.RetentionScheduleFormatWeekly var weekly *protectionpolicies.WeeklyRetentionFormat = nil var daily *protectionpolicies.DailyRetentionFormat = nil - if v, ok := block["days"]; ok && v.(*pluginsdk.Set).Len() > 0 { + if v, ok := block["days"]; ok && v.(*pluginsdk.Set).Len() > 0 || block["include_last_days"].(bool) { scheduleFormat = protectionpolicies.RetentionScheduleFormatDaily daily = expandBackupProtectionPolicyFileShareRetentionDailyFormat(block) } else { @@ -357,7 +357,7 @@ func expandBackupProtectionPolicyFileShareRetentionYearly(d *pluginsdk.ResourceD scheduleFormat := protectionpolicies.RetentionScheduleFormatWeekly var weekly *protectionpolicies.WeeklyRetentionFormat = nil var daily *protectionpolicies.DailyRetentionFormat = nil - if v, ok := block["days"]; ok && v.(*pluginsdk.Set).Len() > 0 { + if v, ok := block["days"]; ok && v.(*pluginsdk.Set).Len() > 0 || block["include_last_days"].(bool) { scheduleFormat = protectionpolicies.RetentionScheduleFormatDaily daily = expandBackupProtectionPolicyFileShareRetentionDailyFormat(block) } else { diff --git a/internal/services/recoveryservices/backup_policy_vm_resource.go b/internal/services/recoveryservices/backup_policy_vm_resource.go index 722223dc10e8..bdfd54eedcf0 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource.go @@ -453,7 +453,7 @@ func expandBackupProtectionPolicyVMRetentionMonthly(d *pluginsdk.ResourceData, t scheduleFormat := protectionpolicies.RetentionScheduleFormatWeekly var weekly *protectionpolicies.WeeklyRetentionFormat = nil var daily *protectionpolicies.DailyRetentionFormat = nil - if v, ok := block["days"]; ok && v.(*pluginsdk.Set).Len() > 0 { + if v, ok := block["days"]; ok && v.(*pluginsdk.Set).Len() > 0 || block["include_last_days"].(bool) { scheduleFormat = protectionpolicies.RetentionScheduleFormatDaily daily = expandBackupProtectionPolicyVMRetentionDailyFormat(block) } else { @@ -484,7 +484,7 @@ func expandBackupProtectionPolicyVMRetentionYearly(d *pluginsdk.ResourceData, ti scheduleFormat := protectionpolicies.RetentionScheduleFormatWeekly var weekly *protectionpolicies.WeeklyRetentionFormat = nil var daily *protectionpolicies.DailyRetentionFormat = nil - if v, ok := block["days"]; ok && v.(*pluginsdk.Set).Len() > 0 { + if v, ok := block["days"]; ok && v.(*pluginsdk.Set).Len() > 0 || block["include_last_days"].(bool) { scheduleFormat = protectionpolicies.RetentionScheduleFormatDaily daily = expandBackupProtectionPolicyVMRetentionDailyFormat(block) } else {