Skip to content

Commit

Permalink
another crash fix
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed May 10, 2024
1 parent 565ecfc commit d19b455
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions internal/services/policies/group_role_management_policy_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,21 +461,23 @@ func (r GroupRoleManagementPolicyResource) Read() sdk.ResourceFunc {

primaryApprovers := make([]GroupRoleManagementPolicyApprover, 0)

if approvers := (*rule.Setting.ApprovalStages)[0].PrimaryApprovers; approvers != nil {
for _, approver := range *approvers {
switch {
case pointer.From(approver.ODataType) == "#microsoft.graph.singleUser":
primaryApprovers = append(primaryApprovers, GroupRoleManagementPolicyApprover{
ID: pointer.ToString(approver.UserID),
Type: "singleUser",
})
case pointer.From(approver.ODataType) == "#microsoft.graph.groupMembers":
primaryApprovers = append(primaryApprovers, GroupRoleManagementPolicyApprover{
ID: pointer.ToString(approver.GroupID),
Type: "groupMembers",
})
default:
return fmt.Errorf("unknown approver type: %s", *approver.ODataType)
if rule.Setting != nil && rule.Setting.ApprovalStages != nil {
if approvers := (*rule.Setting.ApprovalStages)[0].PrimaryApprovers; approvers != nil {
for _, approver := range *approvers {
switch {
case pointer.From(approver.ODataType) == "#microsoft.graph.singleUser":
primaryApprovers = append(primaryApprovers, GroupRoleManagementPolicyApprover{
ID: pointer.ToString(approver.UserID),
Type: "singleUser",
})
case pointer.From(approver.ODataType) == "#microsoft.graph.groupMembers":
primaryApprovers = append(primaryApprovers, GroupRoleManagementPolicyApprover{
ID: pointer.ToString(approver.GroupID),
Type: "groupMembers",
})
default:
return fmt.Errorf("unknown approver type: %s", *approver.ODataType)
}
}
}
}
Expand Down

0 comments on commit d19b455

Please sign in to comment.