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

azurerm_mobile_network_sim_group - update schema #20474

Merged
merged 2 commits into from
Feb 23, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/services/mobilenetwork/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func resourceMobileNetworkChildWaitForDeletion(ctx context.Context, id string, g
return nil
}

// tracked on https://github.com/Azure/azure-rest-api-specs/issues/22634
// some resources defined both systemAssigned and userAssigned Identity type in Swagger but only support userAssigned Identity,
// so add a workaround to convert type here.
func expandMobileNetworkLegacyToUserAssignedIdentity(input []identity.ModelUserAssigned) (*identity.LegacySystemAndUserAssignedMap, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (r SimGroupResource) Arguments() map[string]*pluginsdk.Schema {
ValidateFunc: validation.IsURLWithHTTPorHTTPS,
},

"identity": commonschema.SystemOrUserAssignedIdentityOptional(),
"identity": commonschema.UserAssignedIdentityOptional(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also need to update the Expand and Flatten functions to account for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the typed model is correct so I think these functions are ok?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so if the service were to support system assigned, the provider would crash due to the flattened schema not matching what's defined in the schema - we'll need to ensure these are all using the user assigned values here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think it will crash? with the flatten code accept both SystemAssigned and UserAssigned but only use the UserAssgined one .

func flattenMobileNetworkUserAssignedToNetworkLegacyIdentity(input *identity.LegacySystemAndUserAssignedMap) ([]identity.ModelUserAssigned, error) {
	if input == nil {
		return nil, nil
	}
	tmp := identity.UserAssignedMap{
		Type:        input.Type,
		IdentityIds: input.IdentityIds,
	}
	output, err := identity.FlattenUserAssignedMapToModel(&tmp)
	if err != nil {
		return nil, fmt.Errorf("expanding `identity`: %+v", err)
	}
	return *output, nil
}


"location": commonschema.Location(),

Expand Down