Skip to content

Commit 64af43f

Browse files
Merge pull request #8672 from terraform-providers/f/template-deployment-resources
New Resources: `azurerm_(resource_group|subscription)_template_deployment`
2 parents 8738619 + d5d088f commit 64af43f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+9458
-2332
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package features
2+
3+
// DeprecatedInThreePointOh returns the deprecation message if the provider
4+
// is running in 3.0 mode - otherwise is returns an empty string (such that
5+
// this deprecation should be ignored).
6+
//
7+
// This will be used to signify resources which will be Deprecated in 3.0,
8+
// but not Removed (which will happen in a later, presumably 4.x release).
9+
func DeprecatedInThreePointOh(deprecationMessage string) string {
10+
if !ThreePointOh() {
11+
return ""
12+
}
13+
14+
return deprecationMessage
15+
}
16+
17+
// ThreePointOh returns whether this provider is running in 3.0 mode
18+
// that is to say - that functionality which requires/changes in 3.0
19+
// should be conditionally toggled on
20+
//
21+
// At this point in time this exists just to be able to place this
22+
// infrastructure as required - but in time we'll flip this through
23+
// a Beta and then GA at 3.0 release.
24+
func ThreePointOh() bool {
25+
return false
26+
}

azurerm/internal/features/user_flags.go

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type UserFeatures struct {
55
VirtualMachineScaleSet VirtualMachineScaleSetFeatures
66
KeyVault KeyVaultFeatures
77
Network NetworkFeatures
8+
TemplateDeployment TemplateDeploymentFeatures
89
}
910

1011
type VirtualMachineFeatures struct {
@@ -23,3 +24,7 @@ type KeyVaultFeatures struct {
2324
type NetworkFeatures struct {
2425
RelaxedLocking bool
2526
}
27+
28+
type TemplateDeploymentFeatures struct {
29+
DeleteNestedItemsDuringDeletion bool
30+
}

azurerm/internal/provider/features.go

+56-30
Original file line numberDiff line numberDiff line change
@@ -9,63 +9,76 @@ func schemaFeatures(supportLegacyTestSuite bool) *schema.Schema {
99
// NOTE: if there's only one nested field these want to be Required (since there's no point
1010
// specifying the block otherwise) - however for 2+ they should be optional
1111
features := map[string]*schema.Schema{
12-
"virtual_machine": {
12+
"key_vault": {
1313
Type: schema.TypeList,
1414
Optional: true,
1515
MaxItems: 1,
1616
Elem: &schema.Resource{
1717
Schema: map[string]*schema.Schema{
18-
"delete_os_disk_on_deletion": {
18+
"recover_soft_deleted_key_vaults": {
1919
Type: schema.TypeBool,
20-
Required: true,
20+
Optional: true,
21+
},
22+
23+
"purge_soft_delete_on_destroy": {
24+
Type: schema.TypeBool,
25+
Optional: true,
2126
},
2227
},
2328
},
2429
},
2530

26-
"virtual_machine_scale_set": {
31+
"network": {
2732
Type: schema.TypeList,
2833
Optional: true,
2934
MaxItems: 1,
3035
Elem: &schema.Resource{
3136
Schema: map[string]*schema.Schema{
32-
"roll_instances_when_required": {
37+
"relaxed_locking": {
3338
Type: schema.TypeBool,
3439
Required: true,
3540
},
3641
},
3742
},
3843
},
3944

40-
"key_vault": {
45+
"template_deployment": {
4146
Type: schema.TypeList,
4247
Optional: true,
4348
MaxItems: 1,
4449
Elem: &schema.Resource{
4550
Schema: map[string]*schema.Schema{
46-
"recover_soft_deleted_key_vaults": {
51+
"delete_nested_items_during_deletion": {
4752
Type: schema.TypeBool,
48-
Optional: true,
53+
Required: true,
4954
},
55+
},
56+
},
57+
},
5058

51-
"purge_soft_delete_on_destroy": {
59+
"virtual_machine": {
60+
Type: schema.TypeList,
61+
Optional: true,
62+
MaxItems: 1,
63+
Elem: &schema.Resource{
64+
Schema: map[string]*schema.Schema{
65+
"delete_os_disk_on_deletion": {
5266
Type: schema.TypeBool,
53-
Optional: true,
67+
Required: true,
5468
},
5569
},
5670
},
5771
},
5872

59-
"network": {
73+
"virtual_machine_scale_set": {
6074
Type: schema.TypeList,
6175
Optional: true,
6276
MaxItems: 1,
6377
Elem: &schema.Resource{
6478
Schema: map[string]*schema.Schema{
65-
"relaxed_locking": {
79+
"roll_instances_when_required": {
6680
Type: schema.TypeBool,
67-
Optional: true,
68-
Default: false,
81+
Required: true,
6982
},
7083
},
7184
},
@@ -99,19 +112,22 @@ func expandFeatures(input []interface{}) features.UserFeatures {
99112
// these are the defaults if omitted from the config
100113
features := features.UserFeatures{
101114
// NOTE: ensure all nested objects are fully populated
102-
VirtualMachine: features.VirtualMachineFeatures{
103-
DeleteOSDiskOnDeletion: true,
104-
},
105-
VirtualMachineScaleSet: features.VirtualMachineScaleSetFeatures{
106-
RollInstancesWhenRequired: true,
107-
},
108115
KeyVault: features.KeyVaultFeatures{
109116
PurgeSoftDeleteOnDestroy: true,
110117
RecoverSoftDeletedKeyVaults: true,
111118
},
112119
Network: features.NetworkFeatures{
113120
RelaxedLocking: false,
114121
},
122+
TemplateDeployment: features.TemplateDeploymentFeatures{
123+
DeleteNestedItemsDuringDeletion: true,
124+
},
125+
VirtualMachine: features.VirtualMachineFeatures{
126+
DeleteOSDiskOnDeletion: true,
127+
},
128+
VirtualMachineScaleSet: features.VirtualMachineScaleSetFeatures{
129+
RollInstancesWhenRequired: true,
130+
},
115131
}
116132

117133
if len(input) == 0 || input[0] == nil {
@@ -133,6 +149,26 @@ func expandFeatures(input []interface{}) features.UserFeatures {
133149
}
134150
}
135151

152+
if raw, ok := val["network"]; ok {
153+
items := raw.([]interface{})
154+
if len(items) > 0 {
155+
networkRaw := items[0].(map[string]interface{})
156+
if v, ok := networkRaw["relaxed_locking"]; ok {
157+
features.Network.RelaxedLocking = v.(bool)
158+
}
159+
}
160+
}
161+
162+
if raw, ok := val["template_deployment"]; ok {
163+
items := raw.([]interface{})
164+
if len(items) > 0 {
165+
networkRaw := items[0].(map[string]interface{})
166+
if v, ok := networkRaw["delete_nested_items_during_deletion"]; ok {
167+
features.TemplateDeployment.DeleteNestedItemsDuringDeletion = v.(bool)
168+
}
169+
}
170+
}
171+
136172
if raw, ok := val["virtual_machine"]; ok {
137173
items := raw.([]interface{})
138174
if len(items) > 0 {
@@ -153,15 +189,5 @@ func expandFeatures(input []interface{}) features.UserFeatures {
153189
}
154190
}
155191

156-
if raw, ok := val["network"]; ok {
157-
items := raw.([]interface{})
158-
if len(items) > 0 {
159-
networkRaw := items[0].(map[string]interface{})
160-
if v, ok := networkRaw["relaxed_locking"]; ok {
161-
features.Network.RelaxedLocking = v.(bool)
162-
}
163-
}
164-
}
165-
166192
return features
167193
}

0 commit comments

Comments
 (0)