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

feat: handle ManagerLevel property for requestorManager type #1453

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ resource "azuread_access_package_assignment_policy" "test" {
object_id = azuread_group.test.object_id
subject_type = "groupMembers"
}
alternative_approver{
subject_type = "requestorManager"
manager_level = 2
}
}
}

Expand Down
11 changes: 8 additions & 3 deletions internal/services/identitygovernance/identitygovernance.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,17 @@ func expandUserSets(input []interface{}) *[]msgraph.UserSet {
userSets := make([]msgraph.UserSet, 0)
for _, v := range input {
v_map := v.(map[string]interface{})
oDataType, needId := userSetODataType(v_map["subject_type"].(string))
oDataType, needId, needManagerLevel := userSetODataType(v_map["subject_type"].(string))
userSet := msgraph.UserSet{
ODataType: oDataType,
IsBackup: pointer.To(v_map["backup"].(bool)),
}
if needId {
userSet.ID = pointer.To(v_map["object_id"].(string))
}
if needManagerLevel {
userSet.ManagerLevel = pointer.To(v_map["manager_level"].(int32))
}

userSets = append(userSets, userSet)
}
Expand All @@ -201,9 +204,10 @@ func flattenUserSets(input *[]msgraph.UserSet) []interface{} {
return userSets
}

func userSetODataType(in string) (*string, bool) {
func userSetODataType(in string) (*string, bool, bool) {
odataType := odata.TypeSingleUser
needId := true
needManagerLevel := false
switch in {
case odata.ShortTypeGroupMembers:
odataType = odata.TypeGroupMembers
Expand All @@ -212,6 +216,7 @@ func userSetODataType(in string) (*string, bool) {
case odata.ShortTypeRequestorManager:
odataType = odata.TypeRequestorManager
needId = false
needManagerLevel = true
case odata.ShortTypeInternalSponsors:
odataType = odata.TypeInternalSponsors
needId = false
Expand All @@ -220,7 +225,7 @@ func userSetODataType(in string) (*string, bool) {
needId = false
}

return &odataType, needId
return &odataType, needId, needManagerLevel
}

func userSetShortType(in string) *string {
Expand Down