Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sinbai committed Oct 23, 2024
1 parent ff9f543 commit bf6ee7f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func resourceDataProtectionBackupPolicyPostgreSQL() *pluginsdk.Resource {
},

CustomizeDiff: pluginsdk.CustomizeDiffShim(func(ctx context.Context, diff *pluginsdk.ResourceDiff, v interface{}) error {
if !features.FourPointOhBeta() {
if !features.FivePointOhBeta() {
retentionRules := diff.Get("retention_rule")
defaultRetentionDuration := diff.Get("default_retention_duration")
defaultRetentionRule := diff.Get("default_retention_rule")
Expand All @@ -200,20 +200,22 @@ func resourceDataProtectionBackupPolicyPostgreSQL() *pluginsdk.Resource {
}),
}

if !features.FourPointOhBeta() {
if !features.FivePointOhBeta() {
resource.Schema["default_retention_duration"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
ExactlyOneOf: []string{"default_retention_duration", "default_retention_rule"},
Deprecated: "`default_retention_duration` should be removed in favour of the `default_retention_rule.0.life_cycle.#.duration` property in version 4.0 of the AzureRM Provider.",
ValidateFunc: validate.ISO8601Duration,
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Computed: true,
ConflictsWith: []string{"default_retention_rule"},
Deprecated: "`default_retention_duration` should be removed in favour of the `default_retention_rule.0.life_cycle.#.duration` property in version 5.0 of the AzureRM Provider.",
ValidateFunc: validate.ISO8601Duration,
}
resource.Schema["retention_rule"].Elem.(*pluginsdk.Resource).Schema["duration"] = &pluginsdk.Schema{
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
Deprecated: "`retention_rule.#.duration` should be removed in favour of the `retention_rule.#.life_cycle.#.duration` property in version 4.0 of the AzureRM Provider.",
Computed: true,
Deprecated: "`retention_rule.#.duration` should be removed in favour of the `retention_rule.#.life_cycle.#.duration` property in version 5.0 of the AzureRM Provider.",
ValidateFunc: validate.ISO8601Duration,
}
resource.Schema["retention_rule"].Elem.(*pluginsdk.Resource).Schema["life_cycle"] = &pluginsdk.Schema{
Expand Down Expand Up @@ -259,7 +261,7 @@ func resourceDataProtectionBackupPolicyPostgreSQL() *pluginsdk.Resource {
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
// since the following feedback from the service team, the current possible values only support `ArchiveStore`.
// However, in view of possible support for `VaultStore` in the future, the `data_store_type` property is exposed for users to set in version 4.0.
// However, in view of possible support for `VaultStore` in the future, the `data_store_type` property is exposed for users to set in version 5.0.
// feedback from the service team: Theoretically all 3 values possible. But currently only logical combination is from VaultStore to ArchiveStore. So in target data store it can only be ArchiveStore. OperationalStore isn’t supported for this workload.
string(backuppolicies.DataStoreTypesArchiveStore),
}, false),
Expand All @@ -272,11 +274,12 @@ func resourceDataProtectionBackupPolicyPostgreSQL() *pluginsdk.Resource {
}

resource.Schema["default_retention_rule"] = &pluginsdk.Schema{
Type: pluginsdk.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
ExactlyOneOf: []string{"default_retention_duration", "default_retention_rule"},
Type: pluginsdk.TypeList,
Optional: true,
ForceNew: true,
Computed: true,
MaxItems: 1,
ConflictsWith: []string{"default_retention_duration"},
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"life_cycle": {
Expand Down Expand Up @@ -322,7 +325,7 @@ func resourceDataProtectionBackupPolicyPostgreSQL() *pluginsdk.Resource {
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
// since the following feedback from the service team, the current possible values only support `ArchiveStore`.
// In view of possible support for `VaultStore` in the future, the `data_store_type` property is exposed for users to set in version 4.0.
// In view of possible support for `VaultStore` in the future, the `data_store_type` property is exposed for users to set in version 5.0.
// feedback from the service team: Theoretically all 3 values possible. But currently only logical combination is from VaultStore to ArchiveStore. So in target data store it can only be ArchiveStore. OperationalStore isn’t supported for this workload.
string(backuppolicies.DataStoreTypesArchiveStore),
}, false),
Expand Down Expand Up @@ -380,7 +383,7 @@ func resourceDataProtectionBackupPolicyPostgreSQL() *pluginsdk.Resource {
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
// since the following feedback from the service team, the current possible values only support `ArchiveStore`.
// However, in view of possible support for `VaultStore` in the future, the `data_store_type` property is exposed for users to set in version 4.0.
// However, in view of possible support for `VaultStore` in the future, the `data_store_type` property is exposed for users to set in version 5.0.
// feedback from the service team: Theoretically all 3 values possible. But currently only logical combination is from VaultStore to ArchiveStore. So in target data store it can only be ArchiveStore. OperationalStore isn’t supported for this workload.
string(backuppolicies.DataStoreTypesArchiveStore),
}, false),
Expand Down Expand Up @@ -442,7 +445,7 @@ func resourceDataProtectionBackupPolicyPostgreSQL() *pluginsdk.Resource {
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
// since the following feedback from the service team, the current possible values only support `ArchiveStore`.
// In view of possible support for `VaultStore` in the future, the `data_store_type` property is exposed for users to set in version 4.0.
// In view of possible support for `VaultStore` in the future, the `data_store_type` property is exposed for users to set in version 5.0.
// feedback from the service team: Theoretically all 3 values possible. But currently only logical combination is from VaultStore to ArchiveStore. So in target data store it can only be ArchiveStore. OperationalStore isn’t supported for this workload.
string(backuppolicies.DataStoreTypesArchiveStore),
}, false),
Expand Down Expand Up @@ -491,7 +494,7 @@ func resourceDataProtectionBackupPolicyPostgreSQLCreate(d *pluginsdk.ResourceDat
policyRules := make([]backuppolicies.BasePolicyRule, 0)
policyRules = append(policyRules, expandBackupPolicyPostgreSQLAzureBackupRuleArray(d.Get("backup_repeating_time_intervals").([]interface{}), d.Get("time_zone").(string), taggingCriteria)...)

if v, ok := d.GetOk("default_retention_duration"); ok && !features.FourPointOhBeta() {
if v, ok := d.GetOk("default_retention_duration"); ok && !features.FivePointOhBeta() {
policyRules = append(policyRules, expandBackupPolicyPostgreSQLDefaultAzureRetentionRule(v))
policyRules = append(policyRules, expandBackupPolicyPostgreSQLAzureRetentionRuleArray(d.Get("retention_rule").([]interface{}))...)
} else {
Expand Down Expand Up @@ -544,7 +547,7 @@ func resourceDataProtectionBackupPolicyPostgreSQLRead(d *pluginsdk.ResourceData,
return fmt.Errorf("setting `backup_rule`: %+v", err)
}

if _, ok := d.GetOk("default_retention_duration"); ok && !features.FourPointOhBeta() {
if _, ok := d.GetOk("default_retention_duration"); ok && !features.FivePointOhBeta() {
if err := d.Set("default_retention_duration", flattenBackupPolicyPostgreSQLDefaultRetentionRuleDuration(&props.PolicyRules)); err != nil {
return fmt.Errorf("setting `default_retention_duration`: %+v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import (

type DataProtectionBackupPolicyPostgreSQLResource struct{}

func TestAccDataProtectionBackupPolicyPostgreSQL_basicDeprecatedInV4(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("this test requires 3.0 mode")
func TestAccDataProtectionBackupPolicyPostgreSQL_basicDeprecatedInV5(t *testing.T) {
if features.FivePointOhBeta() {
t.Skip("this test requires 4.0 mode")
}
data := acceptance.BuildTestData(t, "azurerm_data_protection_backup_policy_postgresql", "test")
r := DataProtectionBackupPolicyPostgreSQLResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicDeprecatedInV4(data),
Config: r.basicDeprecatedInV5(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -59,20 +59,20 @@ func TestAccDataProtectionBackupPolicyPostgreSQL_basic(t *testing.T) {
})
}

func TestAccDataProtectionBackupPolicyPostgreSQL_requiresImportDeprecatedInV4(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("this test requires 3.0 mode")
func TestAccDataProtectionBackupPolicyPostgreSQL_requiresImportDeprecatedInV5(t *testing.T) {
if features.FivePointOhBeta() {
t.Skip("this test requires 4.0 mode")
}
data := acceptance.BuildTestData(t, "azurerm_data_protection_backup_policy_postgresql", "test")
r := DataProtectionBackupPolicyPostgreSQLResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.basicDeprecatedInV4(data),
Config: r.basicDeprecatedInV5(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.RequiresImportErrorStep(r.requiresImportDeprecatedInV4),
data.RequiresImportErrorStep(r.requiresImportDeprecatedInV5),
})
}

Expand All @@ -90,15 +90,15 @@ func TestAccDataProtectionBackupPolicyPostgreSQL_requiresImport(t *testing.T) {
})
}

func TestAccDataProtectionBackupPolicyPostgreSQL_completeDeprecatedInV4(t *testing.T) {
if features.FourPointOhBeta() {
t.Skip("this test requires 3.0 mode")
func TestAccDataProtectionBackupPolicyPostgreSQL_completeDeprecatedInV5(t *testing.T) {
if features.FivePointOhBeta() {
t.Skip("this test requires 4.0 mode")
}
data := acceptance.BuildTestData(t, "azurerm_data_protection_backup_policy_postgresql", "test")
r := DataProtectionBackupPolicyPostgreSQLResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.completeDeprecatedInV4(data),
Config: r.completeDeprecatedInV5(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -180,7 +180,7 @@ resource "azurerm_data_protection_backup_vault" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (r DataProtectionBackupPolicyPostgreSQLResource) basicDeprecatedInV4(data acceptance.TestData) string {
func (r DataProtectionBackupPolicyPostgreSQLResource) basicDeprecatedInV5(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -218,8 +218,8 @@ resource "azurerm_data_protection_backup_policy_postgresql" "test" {
`, template, data.RandomInteger)
}

func (r DataProtectionBackupPolicyPostgreSQLResource) requiresImportDeprecatedInV4(data acceptance.TestData) string {
config := r.basicDeprecatedInV4(data)
func (r DataProtectionBackupPolicyPostgreSQLResource) requiresImportDeprecatedInV5(data acceptance.TestData) string {
config := r.basicDeprecatedInV5(data)
return fmt.Sprintf(`
%s
Expand Down Expand Up @@ -256,7 +256,7 @@ resource "azurerm_data_protection_backup_policy_postgresql" "import" {
`, config)
}

func (r DataProtectionBackupPolicyPostgreSQLResource) completeDeprecatedInV4(data acceptance.TestData) string {
func (r DataProtectionBackupPolicyPostgreSQLResource) completeDeprecatedInV5(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%s
Expand Down
5 changes: 5 additions & 0 deletions website/docs/5.0-upgrade-guide.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ Please follow the format in the example below for listing breaking changes in re
* The deprecated `example_old_property` property has been removed in favour of the `example_new_property` property.
* The deprecated `example_property_with_no_replacement` property has been removed.
* The `example_property_with_changed_default` property now defaults to `NewDefault`.

### `azurerm_data_protection_backup_policy_postgresql`

* The deprecated `default_retention_duration` property has been removed in favour of the `default_retention_rule.0.life_cycle.#.duration` property.
* The deprecated `retention_rule.#.duration` property has been removed in favour of the `retention_rule.#.life_cycle.#.duration` property.
```


Expand Down

0 comments on commit bf6ee7f

Please sign in to comment.