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

dependencies: update to latest go-azure-sdk v0.20240923.1151247 and implement discriminated child models #27491

Merged
merged 6 commits into from
Sep 25, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ require (
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/hashicorp/go-azure-helpers v0.70.1
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240906.1232634
github.com/hashicorp/go-azure-sdk/sdk v0.20240906.1232634
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240923.1151247
github.com/hashicorp/go-azure-sdk/sdk v0.20240923.1151247
github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-uuid v1.0.3
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-azure-helpers v0.70.1 h1:7hlnRrZobMZxpOzdlNEsayzAayj/KRG4wpDS1jgo4GM=
github.com/hashicorp/go-azure-helpers v0.70.1/go.mod h1:BmbF4JDYXK5sEmFeU5hcn8Br21uElcqLfdQxjatwQKw=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240906.1232634 h1:hsjAS5gcfhn5FdCiZ08nuAsvQJtlTEsGxJDxqBT6zoA=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240906.1232634/go.mod h1:0IyF1dmWLHTZak+t9eQeg0VZ7rA/5du4swTm99NX+6I=
github.com/hashicorp/go-azure-sdk/sdk v0.20240906.1232634 h1:FGtv7+jcrx2m35qEKjK177zRXoBmPn3WntuqtqjcHwM=
github.com/hashicorp/go-azure-sdk/sdk v0.20240906.1232634/go.mod h1:dMKF6bXrgGmy1d3pLzkmBpG2JIHgSAV2/OMSCEgyMwE=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240923.1151247 h1:G0gRbm6sT00wzkQeCexQzdH58QO6Liwd19V0wJSoVCA=
github.com/hashicorp/go-azure-sdk/resource-manager v0.20240923.1151247/go.mod h1:JBcndQhypLhEDHUK7HNmM2e8WrEAnEua7SiJuw/z/po=
github.com/hashicorp/go-azure-sdk/sdk v0.20240923.1151247 h1:kzNr/Oqfn72C+k9rL5/G/T3maNo1d87u1aAgjNsKOEQ=
github.com/hashicorp/go-azure-sdk/sdk v0.20240923.1151247/go.mod h1:dMKF6bXrgGmy1d3pLzkmBpG2JIHgSAV2/OMSCEgyMwE=
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
Expand Down
33 changes: 33 additions & 0 deletions internal/services/authorization/models.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package authorization

import "github.com/hashicorp/go-azure-sdk/resource-manager/authorization/2020-10-01/rolemanagementpolicies"

var _ rolemanagementpolicies.RoleManagementPolicyRule = RoleManagementPolicyRule{}

// RoleManagementPolicyRule is a temporary workaround because the child models for rolemanagementpolicies.RoleManagementPolicyRule
// do not yet exist, due to issues resolving these child types in the Pandora importer.
// TODO: replace this type with the correct child models from the SDK package, once they are implemented
type RoleManagementPolicyRule struct {
Id *string `json:"id,omitempty"`
RuleType rolemanagementpolicies.RoleManagementPolicyRuleType `json:"ruleType"`

ClaimValue *string `json:"claimValue,omitempty"`
EnabledRules *[]string `json:"enabledRules,omitempty"`
IsDefaultRecipientsEnabled *bool `json:"isDefaultRecipientsEnabled"`
IsEnabled *bool `json:"isEnabled,omitempty"`
IsExpirationRequired *bool `json:"isExpirationRequired,omitempty"`
MaximumDuration *string `json:"maximumDuration,omitempty"`
NotificationLevel *string `json:"notificationLevel"`
NotificationRecipients *[]string `json:"notificationRecipients"`
NotificationType *string `json:"notificationType"`
RecipientType *string `json:"recipientType"`
Setting map[string]interface{} `json:"setting,omitempty"`
Target map[string]interface{} `json:"target,omitempty"`
}

func (r RoleManagementPolicyRule) RoleManagementPolicyRule() rolemanagementpolicies.BaseRoleManagementPolicyRuleImpl {
return rolemanagementpolicies.BaseRoleManagementPolicyRuleImpl{
Id: r.Id,
RuleType: r.RuleType,
}
}
94 changes: 47 additions & 47 deletions internal/services/authorization/role_management_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ func buildRoleManagementPolicyForUpdate(metadata *sdk.ResourceMetaData, rolePoli
target = targetRaw.(map[string]interface{})
}

updatedRules = append(updatedRules, map[string]interface{}{
"id": id,
"ruleType": ruleType,
"target": target,
"isExpirationRequired": expirationRequired,
"maximumDuration": maximumDuration,
updatedRules = append(updatedRules, RoleManagementPolicyRule{
Id: pointer.To(id),
RuleType: rolemanagementpolicies.RoleManagementPolicyRuleType(ruleType),
Target: target,
IsExpirationRequired: pointer.To(expirationRequired),
MaximumDuration: pointer.To(maximumDuration),
})
}
}
Expand Down Expand Up @@ -143,11 +143,11 @@ func buildRoleManagementPolicyForUpdate(metadata *sdk.ResourceMetaData, rolePoli
target = targetRaw.(map[string]interface{})
}

updatedRules = append(updatedRules, map[string]interface{}{
"id": id,
"ruleType": ruleType,
"target": target,
"enabledRules": enabledRules,
updatedRules = append(updatedRules, RoleManagementPolicyRule{
Id: pointer.To(id),
RuleType: rolemanagementpolicies.RoleManagementPolicyRuleType(ruleType),
Target: target,
EnabledRules: pointer.To(enabledRules),
})
}
}
Expand Down Expand Up @@ -187,12 +187,12 @@ func buildRoleManagementPolicyForUpdate(metadata *sdk.ResourceMetaData, rolePoli
target = targetRaw.(map[string]interface{})
}

updatedRules = append(updatedRules, map[string]interface{}{
"id": id,
"ruleType": ruleType,
"target": target,
"isExpirationRequired": expirationRequired,
"maximumDuration": maximumDuration,
updatedRules = append(updatedRules, RoleManagementPolicyRule{
Id: pointer.To(id),
RuleType: rolemanagementpolicies.RoleManagementPolicyRuleType(ruleType),
Target: target,
IsExpirationRequired: pointer.To(expirationRequired),
MaximumDuration: pointer.To(maximumDuration),
})
}
}
Expand All @@ -214,11 +214,11 @@ func buildRoleManagementPolicyForUpdate(metadata *sdk.ResourceMetaData, rolePoli
maximumDuration = model.ActivationRules[0].MaximumDuration
}

updatedRules = append(updatedRules, map[string]interface{}{
"id": id,
"ruleType": ruleType,
"target": target,
"maximumDuration": maximumDuration,
updatedRules = append(updatedRules, RoleManagementPolicyRule{
Id: pointer.To(id),
RuleType: rolemanagementpolicies.RoleManagementPolicyRuleType(ruleType),
Target: target,
MaximumDuration: pointer.To(maximumDuration),
})
}
}
Expand Down Expand Up @@ -288,11 +288,11 @@ func buildRoleManagementPolicyForUpdate(metadata *sdk.ResourceMetaData, rolePoli
target = targetRaw.(map[string]interface{})
}

updatedRules = append(updatedRules, map[string]interface{}{
"id": id,
"ruleType": ruleType,
"target": target,
"setting": map[string]interface{}{
updatedRules = append(updatedRules, RoleManagementPolicyRule{
Id: pointer.To(id),
RuleType: rolemanagementpolicies.RoleManagementPolicyRuleType(ruleType),
Target: target,
Setting: map[string]interface{}{
"isApprovalRequired": approvalReqd,
"approvalStages": approvalStages,
},
Expand Down Expand Up @@ -327,12 +327,12 @@ func buildRoleManagementPolicyForUpdate(metadata *sdk.ResourceMetaData, rolePoli
target = targetRaw.(map[string]interface{})
}

updatedRules = append(updatedRules, map[string]interface{}{
"id": id,
"ruleType": ruleType,
"target": target,
"isEnabled": isEnabled,
"claimValue": claimValue,
updatedRules = append(updatedRules, RoleManagementPolicyRule{
Id: pointer.To(id),
RuleType: rolemanagementpolicies.RoleManagementPolicyRuleType(ruleType),
Target: target,
IsEnabled: pointer.To(isEnabled),
ClaimValue: pointer.To(claimValue),
})
}
}
Expand Down Expand Up @@ -366,11 +366,11 @@ func buildRoleManagementPolicyForUpdate(metadata *sdk.ResourceMetaData, rolePoli
target = targetRaw.(map[string]interface{})
}

updatedRules = append(updatedRules, map[string]interface{}{
"id": id,
"ruleType": ruleType,
"target": target,
"enabledRules": enabledRules,
updatedRules = append(updatedRules, RoleManagementPolicyRule{
Id: pointer.To(id),
RuleType: rolemanagementpolicies.RoleManagementPolicyRuleType(ruleType),
Target: target,
EnabledRules: pointer.To(enabledRules),
})
}
}
Expand Down Expand Up @@ -595,15 +595,15 @@ func expandNotificationSettings(rule rolemanagementpolicies.RawRoleManagementPol
notificationType = notificationTypeRaw.(string)
}

return map[string]interface{}{
"id": id,
"ruleType": ruleType,
"target": target,
"recipientType": recipientType,
"notificationType": notificationType,
"notificationLevel": level,
"isDefaultRecipientsEnabled": defaultRecipients,
"notificationRecipients": additionalRecipients,
return RoleManagementPolicyRule{
Id: pointer.To(id),
RuleType: rolemanagementpolicies.RoleManagementPolicyRuleType(ruleType),
Target: target,
RecipientType: pointer.To(recipientType),
NotificationType: pointer.To(notificationType),
NotificationLevel: pointer.To(level),
IsDefaultRecipientsEnabled: pointer.To(defaultRecipients),
NotificationRecipients: pointer.To(additionalRecipients),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ func dataSourceDataShareDatasetBlobStorageRead(d *pluginsdk.ResourceData, meta i
d.Set("data_share_id", shareId.ID())

if model := resp.Model; model != nil {
m := *model
if ds, ok := m.(dataset.BlobDataSet); ok {
if ds, ok := model.(dataset.BlobDataSet); ok {
props := ds.Properties
d.Set("container_name", props.ContainerName)
if err := d.Set("storage_account", flattenAzureRmDataShareDataSetBlobStorageAccount(props.StorageAccountName, props.ResourceGroup, props.SubscriptionId)); err != nil {
Expand All @@ -113,15 +112,15 @@ func dataSourceDataShareDatasetBlobStorageRead(d *pluginsdk.ResourceData, meta i
d.Set("file_path", props.FilePath)
d.Set("display_name", props.DataSetId)

} else if ds, ok := m.(dataset.BlobFolderDataSet); ok {
} else if ds, ok := model.(dataset.BlobFolderDataSet); ok {
props := ds.Properties
d.Set("container_name", props.ContainerName)
if err := d.Set("storage_account", flattenAzureRmDataShareDataSetBlobStorageAccount(props.StorageAccountName, props.ResourceGroup, props.SubscriptionId)); err != nil {
return fmt.Errorf("setting `storage_account`: %+v", err)
}
d.Set("folder_path", props.Prefix)
d.Set("display_name", props.DataSetId)
} else if ds, ok := m.(dataset.BlobContainerDataSet); ok {
} else if ds, ok := model.(dataset.BlobContainerDataSet); ok {
props := ds.Properties
d.Set("container_name", props.ContainerName)
if err := d.Set("storage_account", flattenAzureRmDataShareDataSetBlobStorageAccount(props.StorageAccountName, props.ResourceGroup, props.SubscriptionId)); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,7 @@ func resourceDataShareDataSetBlobStorageRead(d *pluginsdk.ResourceData, meta int
d.Set("data_share_id", shareId.ID())

if model := resp.Model; model != nil {
m := *model
if ds, ok := m.(dataset.BlobDataSet); ok {
if ds, ok := model.(dataset.BlobDataSet); ok {
props := ds.Properties
d.Set("container_name", props.ContainerName)
if err := d.Set("storage_account", flattenAzureRmDataShareDataSetBlobStorageAccount(props.StorageAccountName, props.ResourceGroup, props.SubscriptionId)); err != nil {
Expand All @@ -208,15 +207,15 @@ func resourceDataShareDataSetBlobStorageRead(d *pluginsdk.ResourceData, meta int
d.Set("file_path", props.FilePath)
d.Set("display_name", props.DataSetId)

} else if ds, ok := m.(dataset.BlobFolderDataSet); ok {
} else if ds, ok := model.(dataset.BlobFolderDataSet); ok {
props := ds.Properties
d.Set("container_name", props.ContainerName)
if err := d.Set("storage_account", flattenAzureRmDataShareDataSetBlobStorageAccount(props.StorageAccountName, props.ResourceGroup, props.SubscriptionId)); err != nil {
return fmt.Errorf("setting `storage_account`: %+v", err)
}
d.Set("folder_path", props.Prefix)
d.Set("display_name", props.DataSetId)
} else if ds, ok := m.(dataset.BlobContainerDataSet); ok {
} else if ds, ok := model.(dataset.BlobContainerDataSet); ok {
props := ds.Properties
d.Set("container_name", props.ContainerName)
if err := d.Set("storage_account", flattenAzureRmDataShareDataSetBlobStorageAccount(props.StorageAccountName, props.ResourceGroup, props.SubscriptionId)); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,13 @@ func (t DataShareDataSetBlobStorageResource) Exists(ctx context.Context, clients
}

if model := resp.Model; model != nil {
ds := *model
if _, ok := ds.(dataset.BlobDataSet); ok {
if _, ok := model.(dataset.BlobDataSet); ok {
return utils.Bool(true), nil
}
if _, ok := ds.(dataset.BlobFolderDataSet); ok {
if _, ok := model.(dataset.BlobFolderDataSet); ok {
return utils.Bool(true), nil
}
if _, ok := ds.(dataset.BlobContainerDataSet); ok {
if _, ok := model.(dataset.BlobContainerDataSet); ok {
return utils.Bool(true), nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,19 @@ func dataSourceDataShareDatasetDataLakeGen2Read(d *pluginsdk.ResourceData, meta
d.Set("share_id", shareId.ID())

if model := resp.Model; model != nil {
m := *model
if ds, ok := m.(dataset.ADLSGen2FileDataSet); ok {
if ds, ok := model.(dataset.ADLSGen2FileDataSet); ok {
props := ds.Properties
d.Set("storage_account_id", commonids.NewStorageAccountID(props.SubscriptionId, props.ResourceGroup, props.StorageAccountName).ID())
d.Set("file_system_name", props.FileSystem)
d.Set("file_path", props.FilePath)
d.Set("display_name", props.DataSetId)
} else if ds, ok := m.(dataset.ADLSGen2FolderDataSet); ok {
} else if ds, ok := model.(dataset.ADLSGen2FolderDataSet); ok {
props := ds.Properties
d.Set("storage_account_id", commonids.NewStorageAccountID(props.SubscriptionId, props.ResourceGroup, props.StorageAccountName).ID())
d.Set("file_system_name", props.FileSystem)
d.Set("folder_path", props.FolderPath)
d.Set("display_name", props.DataSetId)
} else if ds, ok := m.(dataset.ADLSGen2FileSystemDataSet); ok {
} else if ds, ok := model.(dataset.ADLSGen2FileSystemDataSet); ok {
props := ds.Properties
d.Set("storage_account_id", commonids.NewStorageAccountID(props.SubscriptionId, props.ResourceGroup, props.StorageAccountName).ID())
d.Set("file_system_name", props.FileSystem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,19 @@ func resourceDataShareDataSetDataLakeGen2Read(d *pluginsdk.ResourceData, meta in
d.Set("share_id", shareId.ID())

if model := resp.Model; model != nil {
m := *model
if ds, ok := m.(dataset.ADLSGen2FileDataSet); ok {
if ds, ok := model.(dataset.ADLSGen2FileDataSet); ok {
props := ds.Properties
d.Set("storage_account_id", commonids.NewStorageAccountID(props.SubscriptionId, props.ResourceGroup, props.StorageAccountName).ID())
d.Set("file_system_name", props.FileSystem)
d.Set("file_path", props.FilePath)
d.Set("display_name", props.DataSetId)
} else if ds, ok := m.(dataset.ADLSGen2FolderDataSet); ok {
} else if ds, ok := model.(dataset.ADLSGen2FolderDataSet); ok {
props := ds.Properties
d.Set("storage_account_id", commonids.NewStorageAccountID(props.SubscriptionId, props.ResourceGroup, props.StorageAccountName).ID())
d.Set("file_system_name", props.FileSystem)
d.Set("folder_path", props.FolderPath)
d.Set("display_name", props.DataSetId)
} else if ds, ok := m.(dataset.ADLSGen2FileSystemDataSet); ok {
} else if ds, ok := model.(dataset.ADLSGen2FileSystemDataSet); ok {
props := ds.Properties
d.Set("storage_account_id", commonids.NewStorageAccountID(props.SubscriptionId, props.ResourceGroup, props.StorageAccountName).ID())
d.Set("file_system_name", props.FileSystem)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,13 @@ func (t DataShareDataSetDataLakeGen2Resource) Exists(ctx context.Context, client
}

if model := resp.Model; model != nil {
ds := *model
if _, ok := ds.(dataset.ADLSGen2FileDataSet); ok {
if _, ok := model.(dataset.ADLSGen2FileDataSet); ok {
return utils.Bool(true), nil
}
if _, ok := ds.(dataset.ADLSGen2FolderDataSet); ok {
if _, ok := model.(dataset.ADLSGen2FolderDataSet); ok {
return utils.Bool(true), nil
}
if _, ok := ds.(dataset.ADLSGen2FileSystemDataSet); ok {
if _, ok := model.(dataset.ADLSGen2FileSystemDataSet); ok {
return utils.Bool(true), nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ func dataSourceDataShareDatasetKustoClusterRead(d *pluginsdk.ResourceData, meta
d.Set("share_id", shareId.ID())

if model := resp.Model; model != nil {
m := *model
if ds, ok := m.(dataset.KustoClusterDataSet); ok {
if ds, ok := model.(dataset.KustoClusterDataSet); ok {
props := ds.Properties
// TODO parse kusto id
d.Set("kusto_cluster_id", props.KustoClusterResourceId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ func resourceDataShareDataSetKustoClusterRead(d *pluginsdk.ResourceData, meta in
d.Set("share_id", shareId.ID())

if model := resp.Model; model != nil {
m := *model
if ds, ok := m.(dataset.KustoClusterDataSet); ok {
if ds, ok := model.(dataset.KustoClusterDataSet); ok {
props := ds.Properties
// TODO parse kusto id
d.Set("kusto_cluster_id", props.KustoClusterResourceId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ func (t ShareKustoClusterDataSetResource) Exists(ctx context.Context, clients *c
}

if model := resp.Model; model != nil {
ds := *model
if _, ok := ds.(dataset.KustoClusterDataSet); ok {
if _, ok := model.(dataset.KustoClusterDataSet); ok {
return utils.Bool(true), nil
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ func dataSourceDataShareDatasetKustoDatabaseRead(d *pluginsdk.ResourceData, meta
d.Set("share_id", shareId.ID())

if model := resp.Model; model != nil {
m := *model
if ds, ok := m.(dataset.KustoDatabaseDataSet); ok {
if ds, ok := model.(dataset.KustoDatabaseDataSet); ok {
props := ds.Properties
d.Set("kusto_database_id", props.KustoDatabaseResourceId)
d.Set("display_name", props.DataSetId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ func resourceDataShareDataSetKustoDatabaseRead(d *pluginsdk.ResourceData, meta i
d.Set("share_id", shareId.ID())

if model := resp.Model; model != nil {
m := *model
if ds, ok := m.(dataset.KustoDatabaseDataSet); ok {
if ds, ok := model.(dataset.KustoDatabaseDataSet); ok {
props := ds.Properties
d.Set("kusto_database_id", props.KustoDatabaseResourceId)
d.Set("display_name", props.DataSetId)
Expand Down
Loading
Loading