Skip to content

Commit

Permalink
Merge pull request #17 from hashicorp/main
Browse files Browse the repository at this point in the history
[pull] main from hashicorp:main
  • Loading branch information
heoelri authored Aug 11, 2021
2 parents a3767b2 + 1844d2f commit 01a486d
Show file tree
Hide file tree
Showing 625 changed files with 1,815 additions and 356 deletions.
2 changes: 1 addition & 1 deletion .teamcity/components/settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ var serviceTestConfigurationOverrides = mapOf(
"springcloud" to testConfiguration(parallelism = 5),

// Currently have a quota of 10 nodes, 3 nodes required per test
"vmware" to testConfiguration(parallelism = 1)
"vmware" to testConfiguration(parallelism = 3)
)
2 changes: 1 addition & 1 deletion CHANGELOG-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -3088,4 +3088,4 @@ BUG FIXES:

---

For information on v1.44.0 and prior releases, please see [the v1.44.0 changelog](https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/CHANGELOG-v1.md).
For information on v1.44.0 and prior releases, please see [the v1.44.0 changelog](https://github.com/terraform-providers/terraform-provider-azurerm/blob/main/CHANGELOG-v1.md).
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
## 2.72.0 (Unreleased)

UPGRADE NOTES

* This version of the Azure Provider introduces the `prevent_deletion_if_contains_resources` feature flag (which is disabled by default) which (when enabled) means that Terraform will check for Resources nested within the Resource Group during the deletion of the Resource Group and require that these Resources are deleted first. This avoids the unintentional deletion of unmanaged Resources within a Resource Group - and is defaulted off in 2.x versions of the Azure Provider but **will be enabled by default in version 3.0 of the Azure Provider**, see [the `features` block documentation](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs#features) for more information. [GH-12657]


FEATURES:

* **New Resource:** `azurerm_video_analyzer` [GH-12665]
* **New Resource:** `azurerm_video_analyzer_edge_module` [GH-12911]

ENHANCEMENTS:

* `azurerm_function_app` - add support for `dotnet_framework_version` in [GH-12883]
* `azurerm_resource_group` - conditionally (based on the `prevent_deletion_if_contains_resources` features flag - see the 'Upgrade Notes' section) checking for nested Resources during deletion of the Resource Group and raising an error if Resources are found [GH-12657]

BUG FIXES:

Expand Down Expand Up @@ -155,6 +166,6 @@ BUG FIXES:

---

For information on changes between the v2.69.0 and v2.0.0 releases, please see [the previous v2.x changelog entries](https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/CHANGELOG-v2.md).
For information on changes between the v2.69.0 and v2.0.0 releases, please see [the previous v2.x changelog entries](https://github.com/terraform-providers/terraform-provider-azurerm/blob/main/CHANGELOG-v2.md).

For information on changes in version v1.44.0 and prior releases, please see [the v1.x changelog](https://github.com/terraform-providers/terraform-provider-azurerm/blob/master/CHANGELOG-v1.md).
For information on changes in version v1.44.0 and prior releases, please see [the v1.x changelog](https://github.com/terraform-providers/terraform-provider-azurerm/blob/main/CHANGELOG-v1.md).
5 changes: 5 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ debugacc: fmtcheck
TF_ACC=1 dlv test $(TEST) --headless --listen=:2345 --api-version=2 -- -test.v $(TESTARGS)

website-lint:
@echo "==> Checking documentation for .html.markdown extension present"
@if ! find website/docs -type f -not -name "*.html.markdown" -print -exec false {} +; then \
echo "ERROR: file extension should be .html.markdown"; \
exit 1; \
fi
@echo "==> Checking documentation spelling..."
@misspell -error -source=text -i hdinsight,exportfs website/
@echo "==> Checking documentation for errors..."
Expand Down
3 changes: 3 additions & 0 deletions internal/features/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func Default() UserFeatures {
Network: NetworkFeatures{
RelaxedLocking: false,
},
ResourceGroup: ResourceGroupFeatures{
PreventDeletionIfContainsResources: false,
},
TemplateDeployment: TemplateDeploymentFeatures{
DeleteNestedItemsDuringDeletion: true,
},
Expand Down
5 changes: 5 additions & 0 deletions internal/features/user_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type UserFeatures struct {
Network NetworkFeatures
TemplateDeployment TemplateDeploymentFeatures
LogAnalyticsWorkspace LogAnalyticsWorkspaceFeatures
ResourceGroup ResourceGroupFeatures
}

type CognitiveAccountFeatures struct {
Expand Down Expand Up @@ -41,3 +42,7 @@ type TemplateDeploymentFeatures struct {
type LogAnalyticsWorkspaceFeatures struct {
PermanentlyDeleteOnDestroy bool
}

type ResourceGroupFeatures struct {
PreventDeletionIfContainsResources bool
}
8 changes: 4 additions & 4 deletions internal/identity/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const (
type ExpandedConfig struct {
// Type is the type of User Assigned Identity, either `None`, `SystemAssigned`, `UserAssigned`
// or `SystemAssigned, UserAssigned`
Type Type
PrincipalId *string
TenantId *string
UserAssignedIdentityIds *[]string
Type Type `tfschema:"type"`
PrincipalId string `tfschema:"principal_id"`
TenantId string `tfschema:"tenant_id"`
UserAssignedIdentityIds []string `tfschema:"identity_ids"`
}

type Identity interface {
Expand Down
278 changes: 278 additions & 0 deletions internal/identity/sdk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
package identity

type userAssignedIdentity struct {
ResourceId *string `json:"resourceId,omitempty"`
userAssignedIdentityInfo
}

type userAssignedIdentityInfo struct {
ClientId *string `json:"clientId,omitempty"`
PrincipalId *string `json:"principalId,omitempty"`
}

type ExpandedConfigCaster interface {
ToExpandedConfig() ExpandedConfig
FromExpandedConfig(ExpandedConfig)
}

var _ ExpandedConfigCaster = &SystemAssignedIdentity{}

type SystemAssignedIdentity struct {
Type Type `json:"type,omitempty"`
TenantId *string `json:"tenantId,omitempty"`
PrincipalId *string `json:"principalId,omitempty"`
}

func (s *SystemAssignedIdentity) ToExpandedConfig() ExpandedConfig {
if s == nil {
return ExpandedConfig{}
}
principalId := ""
if s.PrincipalId != nil {
principalId = *s.PrincipalId
}
tenantId := ""
if s.TenantId != nil {
tenantId = *s.TenantId
}
return ExpandedConfig{
Type: s.Type,
PrincipalId: principalId,
TenantId: tenantId,
}
}

func (s *SystemAssignedIdentity) FromExpandedConfig(config ExpandedConfig) {
if s == nil {
return
}
*s = SystemAssignedIdentity{
Type: config.Type,
TenantId: &config.TenantId,
PrincipalId: &config.PrincipalId,
}
}

var _ ExpandedConfigCaster = &UserAssignedIdentityList{}

type UserAssignedIdentityList struct {
Type Type `json:"type,omitempty"`
UserAssignedIdentities *[]userAssignedIdentity `json:"userAssignedIdentities,omitempty"`
}

func (u *UserAssignedIdentityList) ToExpandedConfig() ExpandedConfig {
if u == nil {
return ExpandedConfig{}
}
out := ExpandedConfig{
Type: u.Type,
}

if u.UserAssignedIdentities == nil {
return out
}

var identities []string
for _, id := range *u.UserAssignedIdentities {
if id.ResourceId == nil {
continue
}
identities = append(identities, *id.PrincipalId)
}
out.UserAssignedIdentityIds = identities

return out
}

func (u *UserAssignedIdentityList) FromExpandedConfig(config ExpandedConfig) {
if u == nil {
return
}
*u = UserAssignedIdentityList{
Type: config.Type,
}

if len(config.UserAssignedIdentityIds) == 0 {
return
}

var identities []userAssignedIdentity
for _, id := range config.UserAssignedIdentityIds {
identities = append(identities, userAssignedIdentity{
ResourceId: &id,
})
}
u.UserAssignedIdentities = &identities
}

var _ ExpandedConfigCaster = &UserAssignedIdentityMap{}

type UserAssignedIdentityMap struct {
Type Type `json:"type,omitempty"`
UserAssignedIdentities map[string]*userAssignedIdentityInfo `json:"userAssignedIdentities,omitempty"`
}

func (u *UserAssignedIdentityMap) ToExpandedConfig() ExpandedConfig {
if u == nil {
return ExpandedConfig{}
}
out := ExpandedConfig{
Type: u.Type,
}

var identities []string
for k := range u.UserAssignedIdentities {
identities = append(identities, k)
}

out.UserAssignedIdentityIds = identities

return out
}

func (u *UserAssignedIdentityMap) FromExpandedConfig(config ExpandedConfig) {
if u == nil {
return
}

*u = UserAssignedIdentityMap{
Type: config.Type,
}

if len(config.UserAssignedIdentityIds) == 0 {
return
}

u.UserAssignedIdentities = map[string]*userAssignedIdentityInfo{}
for _, id := range config.UserAssignedIdentityIds {
// The user assigned identity information is not used by the provider. So simply assign the value to nil.
u.UserAssignedIdentities[id] = nil
}
}

var _ ExpandedConfigCaster = &SystemUserAssignedIdentityList{}

type SystemUserAssignedIdentityList struct {
Type Type `json:"type,omitempty"`
TenantId *string `json:"tenantId,omitempty"`
PrincipalId *string `json:"principalId,omitempty"`
UserAssignedIdentities *[]userAssignedIdentity `json:"userAssignedIdentities,omitempty"`
}

func (s *SystemUserAssignedIdentityList) ToExpandedConfig() ExpandedConfig {
if s == nil {
return ExpandedConfig{}
}
principalId := ""
if s.PrincipalId != nil {
principalId = *s.PrincipalId
}
tenantId := ""
if s.TenantId != nil {
tenantId = *s.TenantId
}

out := ExpandedConfig{
Type: s.Type,
PrincipalId: principalId,
TenantId: tenantId,
}

if s.UserAssignedIdentities == nil {
return out
}

var identities []string
for _, id := range *s.UserAssignedIdentities {
if id.ResourceId == nil {
continue
}
identities = append(identities, *id.ResourceId)
}
out.UserAssignedIdentityIds = identities

return out
}

func (s *SystemUserAssignedIdentityList) FromExpandedConfig(config ExpandedConfig) {
if s == nil {
return
}

*s = SystemUserAssignedIdentityList{
Type: config.Type,
TenantId: &config.TenantId,
PrincipalId: &config.PrincipalId,
}

if len(config.UserAssignedIdentityIds) == 0 {
return
}

var identities []userAssignedIdentity
for _, id := range config.UserAssignedIdentityIds {
identities = append(identities, userAssignedIdentity{
ResourceId: &id,
})
}
s.UserAssignedIdentities = &identities
}

var _ ExpandedConfigCaster = &SystemUserAssignedIdentityMap{}

type SystemUserAssignedIdentityMap struct {
Type Type `json:"type,omitempty"`
TenantId *string `json:"tenantId,omitempty"`
PrincipalId *string `json:"principalId,omitempty"`
UserAssignedIdentities map[string]*userAssignedIdentityInfo `json:"userAssignedIdentities,omitempty"`
}

func (s *SystemUserAssignedIdentityMap) ToExpandedConfig() ExpandedConfig {
if s == nil {
return ExpandedConfig{}
}
principalId := ""
if s.PrincipalId != nil {
principalId = *s.PrincipalId
}
tenantId := ""
if s.TenantId != nil {
tenantId = *s.TenantId
}

out := ExpandedConfig{
Type: s.Type,
PrincipalId: principalId,
TenantId: tenantId,
}

var identities []string
for k := range s.UserAssignedIdentities {
identities = append(identities, k)
}
out.UserAssignedIdentityIds = identities

return out
}

func (s *SystemUserAssignedIdentityMap) FromExpandedConfig(config ExpandedConfig) {
if s == nil {
return
}

*s = SystemUserAssignedIdentityMap{
Type: config.Type,
TenantId: &config.TenantId,
PrincipalId: &config.PrincipalId,
}

if len(config.UserAssignedIdentityIds) == 0 {
return
}

s.UserAssignedIdentities = map[string]*userAssignedIdentityInfo{}
for _, id := range config.UserAssignedIdentityIds {
// The user assigned identity information is not used by the provider. So simply assign the value to nil.
s.UserAssignedIdentities[id] = nil
}
}
12 changes: 2 additions & 10 deletions internal/identity/system_assigned.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,11 @@ func (s SystemAssigned) Flatten(input *ExpandedConfig) []interface{} {
return []interface{}{}
}

coalesce := func(input *string) string {
if input == nil {
return ""
}

return *input
}

return []interface{}{
map[string]interface{}{
"type": input.Type,
"principal_id": coalesce(input.PrincipalId),
"tenant_id": coalesce(input.TenantId),
"principal_id": input.PrincipalId,
"tenant_id": input.TenantId,
},
}
}
Expand Down
Loading

0 comments on commit 01a486d

Please sign in to comment.