From c9b84959757148431c0e7b947e28b71568acb2eb Mon Sep 17 00:00:00 2001 From: "Elena Xin (Centific Technologies Inc)" Date: Thu, 1 Feb 2024 18:17:05 +0800 Subject: [PATCH] update code --- ...ckup_policy_kubernetes_cluster_resource.go | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/internal/services/dataprotection/azurerm_data_protection_backup_policy_kubernetes_cluster_resource.go b/internal/services/dataprotection/azurerm_data_protection_backup_policy_kubernetes_cluster_resource.go index 8dac4e1a9cf5b..3073a73925558 100644 --- a/internal/services/dataprotection/azurerm_data_protection_backup_policy_kubernetes_cluster_resource.go +++ b/internal/services/dataprotection/azurerm_data_protection_backup_policy_kubernetes_cluster_resource.go @@ -293,7 +293,9 @@ func (r DataProtectionBackupPolicyKubernatesClusterResource) Create() sdk.Resour policyRules := make([]backuppolicies.BasePolicyRule, 0) policyRules = append(policyRules, expandBackupPolicyKubernetesClusterAzureBackupRuleArray(model.BackupRepeatingTimeIntervals, model.TimeZone, taggingCriteria)...) - policyRules = append(policyRules, expandBackupPolicyKubernetesClusterDefaultRetentionRule(model.DefaultRetentionRule)) + if v := expandBackupPolicyKubernetesClusterDefaultRetentionRule(model.DefaultRetentionRule); v != nil { + policyRules = append(policyRules, pointer.From(v)) + } policyRules = append(policyRules, expandBackupPolicyKubernetesClusterAzureRetentionRules(model.RetentionRule)...) parameters := backuppolicies.BaseBackupPolicyResource{ @@ -397,18 +399,15 @@ func expandBackupPolicyKubernetesClusterAzureBackupRuleArray(input []string, tim return results } -func expandBackupPolicyKubernetesClusterDefaultRetentionRule(input []DefaultRetentionRule) backuppolicies.BasePolicyRule { - results := backuppolicies.AzureRetentionRule{} +func expandBackupPolicyKubernetesClusterDefaultRetentionRule(input []DefaultRetentionRule) *backuppolicies.AzureRetentionRule { if len(input) == 0 { - return results + return nil + } + return &backuppolicies.AzureRetentionRule{ + Name: "Default", + IsDefault: pointer.To(true), + Lifecycles: expandBackupPolicyKubernetesClusterLifeCycle(input[0].LifeCycle), } - - lifeCycle := expandBackupPolicyKubernetesClusterLifeCycle(input[0].LifeCycle) - results.Name = "Default" - results.IsDefault = pointer.To(true) - results.Lifecycles = lifeCycle - - return results } func expandBackupPolicyKubernetesClusterAzureRetentionRules(input []RetentionRule) []backuppolicies.BasePolicyRule {