in internal/provider/architecture_data_source.go [521:565]
func convertPolicyAssignmentIdentityToSdkType(typ types.String, ids types.Set, resp *datasource.ReadResponse) *armpolicy.Identity {
if !isKnown(typ) {
return nil
}
var identity *armpolicy.Identity
switch typ.ValueString() {
case "SystemAssigned":
identity = to.Ptr(armpolicy.Identity{
Type: to.Ptr(armpolicy.ResourceIdentityTypeSystemAssigned),
})
case "UserAssigned":
if ids.IsUnknown() {
return nil
}
var id string
if len(ids.Elements()) != 1 {
resp.Diagnostics.AddError(
"convertPolicyAssignmentIdentityToSdkType: error",
"one (and only one) identity id is required for user assigned identity",
)
return nil
}
idStr, ok := ids.Elements()[0].(types.String)
if !ok {
resp.Diagnostics.AddError(
"convertPolicyAssignmentIdentityToSdkType: error",
"unable to convert identity id to string",
)
return nil
}
id = idStr.ValueString()
identity = to.Ptr(armpolicy.Identity{
Type: to.Ptr(armpolicy.ResourceIdentityTypeUserAssigned),
UserAssignedIdentities: map[string]*armpolicy.UserAssignedIdentitiesValue{id: {}},
})
default:
resp.Diagnostics.AddError(
"convertPolicyAssignmentIdentityToSdkType: error",
fmt.Sprintf("unknown identity type: %s", typ.ValueString()),
)
return nil
}
return identity
}