Skip to content

Commit

Permalink
Merge pull request #1 from myc2h6o/desautorotate_ref
Browse files Browse the repository at this point in the history
Resolve reference error and remove unnecessary test check
  • Loading branch information
Tbohunek authored Oct 19, 2021
2 parents 957dbe8 + a694dfd commit 22e12b1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 27 deletions.
4 changes: 2 additions & 2 deletions internal/services/compute/disk_encryption_set_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func dataSourceDiskEncryptionSetRead(d *pluginsdk.ResourceData, meta interface{}
d.Set("location", azure.NormalizeLocation(*location))
}

if props := resp.Properties; props != nil {
d.Set("auto_key_rotation_enabled", props.rotationToLatestKeyVersionEnabled)
if props := resp.EncryptionSetProperties; props != nil {
d.Set("auto_key_rotation_enabled", props.RotationToLatestKeyVersionEnabled)
}

return tags.FlattenAndSet(d, resp.Tags)
Expand Down
15 changes: 4 additions & 11 deletions internal/services/compute/disk_encryption_set_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,15 @@ func TestAccDataSourceDiskEncryptionSet_update(t *testing.T) {
r := DiskEncryptionSetDataSource{}
data.DataSourceTest(t, []acceptance.TestStep{
{
Config: r.update(data),
Config: r.basic(data),
},
{
Config: r.update(data),
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("location").Exists(),
check.That(data.ResourceName).Key("auto_key_rotation_enabled").HasValue("true"),
),
},
{
Config: r.update(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).Key("location").Exists(),
check.That(data.ResourceName).Key("auto_key_rotation_enabled").HasValue("false"),
),
},
})
}

Expand All @@ -62,13 +55,13 @@ data "azurerm_disk_encryption_set" "test" {
`, DiskEncryptionSetResource{}.basic(data))
}

func (DiskEncryptionSetDataSource) update(data acceptance.TestData) string {
func (DiskEncryptionSetDataSource) complete(data acceptance.TestData) string {
return fmt.Sprintf(`
%s
data "azurerm_disk_encryption_set" "test" {
name = azurerm_disk_encryption_set.test.name
resource_group_name = azurerm_disk_encryption_set.test.resource_group_name
}
`, DiskEncryptionSetResource{}.update(data))
`, DiskEncryptionSetResource{}.complete(data))
}
5 changes: 3 additions & 2 deletions internal/services/compute/disk_encryption_set_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func resourceDiskEncryptionSetCreate(d *pluginsdk.ResourceData, meta interface{}
ID: utils.String(keyVaultDetails.keyVaultId),
},
},
RotationToLatestKeyVersionEnabled: &rotationToLatestKeyVersionEnabled,
},
Identity: expandDiskEncryptionSetIdentity(identityRaw),
Tags: tags.Expand(t),
Expand Down Expand Up @@ -201,7 +202,7 @@ func resourceDiskEncryptionSetRead(d *pluginsdk.ResourceData, meta interface{})
keyVaultKeyId = *props.ActiveKey.KeyURL
}
d.Set("key_vault_key_id", keyVaultKeyId)
d.Set("auto_key_rotation_enabled", props.rotationToLatestKeyVersionEnabled)
d.Set("auto_key_rotation_enabled", props.RotationToLatestKeyVersionEnabled)
}

if err := d.Set("identity", flattenDiskEncryptionSetIdentity(resp.Identity)); err != nil {
Expand Down Expand Up @@ -255,7 +256,7 @@ func resourceDiskEncryptionSetUpdate(d *pluginsdk.ResourceData, meta interface{}
update.DiskEncryptionSetUpdateProperties = &compute.DiskEncryptionSetUpdateProperties{}
}

update.DiskEncryptionSetUpdateProperties.rotationToLatestKeyVersionEnabled = utils.Bool(d.Get("auto_key_rotation_enabled").(bool))
update.DiskEncryptionSetUpdateProperties.RotationToLatestKeyVersionEnabled = utils.Bool(d.Get("auto_key_rotation_enabled").(bool))
}

future, err := client.Update(ctx, id.ResourceGroup, id.Name, update)
Expand Down
12 changes: 0 additions & 12 deletions internal/services/compute/disk_encryption_set_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ func TestAccDiskEncryptionSet_complete(t *testing.T) {
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("auto_key_rotation_enabled").HasValue("true"),
),
},
data.ImportStep(),
{
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("auto_key_rotation_enabled").HasValue("false"),
),
},
data.ImportStep(),
Expand All @@ -86,15 +77,13 @@ func TestAccDiskEncryptionSet_update(t *testing.T) {
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("auto_key_rotation_enabled").HasValue("true"),
),
},
data.ImportStep(),
{
Config: r.complete(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("auto_key_rotation_enabled").HasValue("false"),
),
},
data.ImportStep(),
Expand Down Expand Up @@ -126,7 +115,6 @@ func TestAccDiskEncryptionSet_keyRotate(t *testing.T) {
Config: r.keyRotate(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("auto_key_rotation_enabled").HasValue("true"),
),
},
data.ImportStep(),
Expand Down

0 comments on commit 22e12b1

Please sign in to comment.