Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_data_protection_backup_vault - fix invalid memory address or nil pointer dereference issue #27762

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ func resourceDataProtectionBackupVaultRead(d *pluginsdk.ResourceData, meta inter
}
crossRegionStoreEnabled := false
if featureSetting := model.Properties.FeatureSettings; featureSetting != nil {
if featureSetting := model.Properties.FeatureSettings; featureSetting != nil {
if pointer.From(featureSetting.CrossRegionRestoreSettings.State) == backupvaults.CrossRegionRestoreStateEnabled {
if crossRegionRestore := featureSetting.CrossRegionRestoreSettings; crossRegionRestore != nil {
if pointer.From(crossRegionRestore.State) == backupvaults.CrossRegionRestoreStateEnabled {
crossRegionStoreEnabled = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ func TestAccDataProtectionBackupVault_crossRegionRestore(t *testing.T) {
r := DataProtectionBackupVaultResource{}
data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.crossRegionRestore(data),
Config: r.crossRegionRestore(data, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.crossRegionRestore(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
Expand Down Expand Up @@ -192,7 +199,7 @@ resource "azurerm_data_protection_backup_vault" "test" {
`, template, data.RandomInteger)
}

func (r DataProtectionBackupVaultResource) crossRegionRestore(data acceptance.TestData) string {
func (r DataProtectionBackupVaultResource) crossRegionRestore(data acceptance.TestData, enabled bool) string {
template := r.template(data)
return fmt.Sprintf(`
%s
Expand All @@ -203,9 +210,9 @@ resource "azurerm_data_protection_backup_vault" "test" {
location = azurerm_resource_group.test.location
datastore_type = "VaultStore"
redundancy = "GeoRedundant"
cross_region_restore_enabled = true
cross_region_restore_enabled = %t
}
`, template, data.RandomInteger)
`, template, data.RandomInteger, enabled)
}

func (r DataProtectionBackupVaultResource) requiresImport(data acceptance.TestData) string {
Expand Down
Loading