Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-yechenwei committed Jun 30, 2021
2 parents 3e9557b + 61dcff2 commit e91a70c
Show file tree
Hide file tree
Showing 83 changed files with 6,584 additions and 1,818 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/issue-opened.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: github/issue-labeler@v2
- uses: github/issue-labeler@v2.4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/labeler-issue-triage.yml
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
## 2.66.0 (Unreleased)

FEATURES:

* **New Resouce** `azurerm_api_management_api_operation_tag` [GH-12384]
* **New Resouce** `azurerm_data_factory_linked_custom_service` [GH-12224]
* **New Resouce** `azurerm_express_route_connection` [GH-11320]
* Cognitive Service now supports purging soft delete accounts [GH-12281]

ENHANCEMENTS:

* dependencies: updating `cognitive` to use API Version `2021-03-01` [GH-12281]
* `azurerm_api_management_backend` - support for the `client_certificate_id` property [GH-12402]
* `azurerm_batch_account` - support for the `public_network_access_enabled` property [GH-12401]
* `azurerm_lighthouse_definition` - support for the `plan` block [GH-12360]
* `azurerm_site_recovery_replicated_vm` - Add support for `target_disk_encryption_set_id` in `managed_disk` [GH-12374]

BUG FIXES:

* `azurerm_app_service` - fix app_setting and SCM setting ordering [GH-12280]
* `azurerm_hdinsight_kafka_cluster` - will no longer panic from an empty `component_version` property [GH-12261]
* `azurerm_spatial_anchors_account` - the `tags` property can now be updated without creating a new resource [GH-11985]



## 2.65.0 (June 25, 2021)

FEATURES:
Expand All @@ -20,7 +43,7 @@ ENHANCEMENTS:
* `azurerm_linux_virtual_machine` - updating `proximity_placement_group_id` will no longer create a new resoruce ([#11790](https://github.com/terraform-providers/terraform-provider-azurerm/issues/11790))
* `azurerm_security_center_assessment_metadata` - support for the `categories` property ([#12278](https://github.com/terraform-providers/terraform-provider-azurerm/issues/12278))
* `azurerm_windows_virtual_machine` - updating `proximity_placement_group_id` will no longer create a new resoruce ([#11790](https://github.com/terraform-providers/terraform-provider-azurerm/issues/11790))
*

BUG FIXES:

* `azurerm_data_factory` - fix a bug where the `name` property was stored with the wrong casing ([#12128](https://github.com/terraform-providers/terraform-provider-azurerm/issues/12128))
Expand Down
3 changes: 3 additions & 0 deletions azurerm/internal/features/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package features
func Default() UserFeatures {
return UserFeatures{
// NOTE: ensure all nested objects are fully populated
CognitiveAccount: CognitiveAccountFeatures{
PurgeSoftDeleteOnDestroy: true,
},
KeyVault: KeyVaultFeatures{
PurgeSoftDeleteOnDestroy: true,
RecoverSoftDeletedKeyVaults: true,
Expand Down
5 changes: 5 additions & 0 deletions azurerm/internal/features/user_flags.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package features

type UserFeatures struct {
CognitiveAccount CognitiveAccountFeatures
VirtualMachine VirtualMachineFeatures
VirtualMachineScaleSet VirtualMachineScaleSetFeatures
KeyVault KeyVaultFeatures
Expand All @@ -9,6 +10,10 @@ type UserFeatures struct {
LogAnalyticsWorkspace LogAnalyticsWorkspaceFeatures
}

type CognitiveAccountFeatures struct {
PurgeSoftDeleteOnDestroy bool
}

type VirtualMachineFeatures struct {
DeleteOSDiskOnDeletion bool
GracefulShutdown bool
Expand Down
25 changes: 25 additions & 0 deletions azurerm/internal/provider/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ func schemaFeatures(supportLegacyTestSuite bool) *pluginsdk.Schema {
// specifying the block otherwise) - however for 2+ they should be optional
features := map[string]*pluginsdk.Schema{
// lintignore:XS003
"cognitive_account": {
Type: pluginsdk.TypeList,
Optional: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"purge_soft_delete_on_destroy": {
Type: pluginsdk.TypeBool,
Optional: true,
Default: true,
},
},
},
},

"key_vault": {
Type: pluginsdk.TypeList,
Optional: true,
Expand Down Expand Up @@ -145,6 +160,16 @@ func expandFeatures(input []interface{}) features.UserFeatures {

val := input[0].(map[string]interface{})

if raw, ok := val["cognitive_account"]; ok {
items := raw.([]interface{})
if len(items) > 0 && items[0] != nil {
cognitiveRaw := items[0].(map[string]interface{})
if v, ok := cognitiveRaw["purge_soft_delete_on_destroy"]; ok {
features.CognitiveAccount.PurgeSoftDeleteOnDestroy = v.(bool)
}
}
}

if raw, ok := val["key_vault"]; ok {
items := raw.([]interface{})
if len(items) > 0 && items[0] != nil {
Expand Down
84 changes: 84 additions & 0 deletions azurerm/internal/provider/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func TestExpandFeatures(t *testing.T) {
Name: "Empty Block",
Input: []interface{}{},
Expected: features.UserFeatures{
CognitiveAccount: features.CognitiveAccountFeatures{
PurgeSoftDeleteOnDestroy: true,
},
KeyVault: features.KeyVaultFeatures{
PurgeSoftDeleteOnDestroy: true,
RecoverSoftDeletedKeyVaults: true,
Expand Down Expand Up @@ -46,6 +49,11 @@ func TestExpandFeatures(t *testing.T) {
Name: "Complete Enabled",
Input: []interface{}{
map[string]interface{}{
"cognitive_account": []interface{}{
map[string]interface{}{
"purge_soft_delete_on_destroy": true,
},
},
"key_vault": []interface{}{
map[string]interface{}{
"purge_soft_delete_on_destroy": true,
Expand Down Expand Up @@ -83,6 +91,9 @@ func TestExpandFeatures(t *testing.T) {
},
},
Expected: features.UserFeatures{
CognitiveAccount: features.CognitiveAccountFeatures{
PurgeSoftDeleteOnDestroy: true,
},
KeyVault: features.KeyVaultFeatures{
PurgeSoftDeleteOnDestroy: true,
RecoverSoftDeletedKeyVaults: true,
Expand Down Expand Up @@ -111,6 +122,11 @@ func TestExpandFeatures(t *testing.T) {
Name: "Complete Disabled",
Input: []interface{}{
map[string]interface{}{
"cognitive_account": []interface{}{
map[string]interface{}{
"purge_soft_delete_on_destroy": false,
},
},
"key_vault": []interface{}{
map[string]interface{}{
"purge_soft_delete_on_destroy": false,
Expand Down Expand Up @@ -148,6 +164,9 @@ func TestExpandFeatures(t *testing.T) {
},
},
Expected: features.UserFeatures{
CognitiveAccount: features.CognitiveAccountFeatures{
PurgeSoftDeleteOnDestroy: false,
},
KeyVault: features.KeyVaultFeatures{
PurgeSoftDeleteOnDestroy: false,
RecoverSoftDeletedKeyVaults: false,
Expand Down Expand Up @@ -183,6 +202,71 @@ func TestExpandFeatures(t *testing.T) {
}
}

func TestExpandFeaturesCognitiveServices(t *testing.T) {
testData := []struct {
Name string
Input []interface{}
EnvVars map[string]interface{}
Expected features.UserFeatures
}{
{
Name: "Empty Block",
Input: []interface{}{
map[string]interface{}{
"cognitive_account": []interface{}{},
},
},
Expected: features.UserFeatures{
CognitiveAccount: features.CognitiveAccountFeatures{
PurgeSoftDeleteOnDestroy: true,
},
},
},
{
Name: "Purge on Destroy Enabled",
Input: []interface{}{
map[string]interface{}{
"cognitive_account": []interface{}{
map[string]interface{}{
"purge_soft_delete_on_destroy": true,
},
},
},
},
Expected: features.UserFeatures{
CognitiveAccount: features.CognitiveAccountFeatures{
PurgeSoftDeleteOnDestroy: true,
},
},
},
{
Name: "Purge on Destroy Disabled",
Input: []interface{}{
map[string]interface{}{
"cognitive_account": []interface{}{
map[string]interface{}{
"purge_soft_delete_on_destroy": false,
},
},
},
},
Expected: features.UserFeatures{
CognitiveAccount: features.CognitiveAccountFeatures{
PurgeSoftDeleteOnDestroy: false,
},
},
},
}

for _, testCase := range testData {
t.Logf("[DEBUG] Test Case: %q", testCase.Name)
result := expandFeatures(testCase.Input)
if !reflect.DeepEqual(result.CognitiveAccount, testCase.Expected.CognitiveAccount) {
t.Fatalf("Expected %+v but got %+v", result.CognitiveAccount, testCase.Expected.CognitiveAccount)
}
}
}

func TestExpandFeaturesKeyVault(t *testing.T) {
testData := []struct {
Name string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ resource "azurerm_api_management" "test" {
resource_group_name = azurerm_resource_group.test.name
publisher_name = "pub1"
publisher_email = "[email protected]"
sku_name = "Developer_1"
sku_name = "Consumption_0"
}
resource "azurerm_api_management_api" "test" {
Expand Down
Loading

0 comments on commit e91a70c

Please sign in to comment.