Skip to content

Commit

Permalink
filter role assignment on scope (#24077)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhang3 committed Dec 12, 2023
1 parent 5b950fd commit 9dac883
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"regexp"
"strconv"
"strings"
"time"

// nolint: staticcheck
Expand Down Expand Up @@ -180,7 +181,8 @@ func (r PimActiveRoleAssignmentResource) Create() sdk.ResourceFunc {
return fmt.Errorf("listing role assignments on scope %s: %+v", id, err)
}
for _, item := range items.Items {
if *item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect {
if *item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, id.Scope) {
return metadata.ResourceRequiresImport(r.ResourceType(), id)
}
}
Expand Down Expand Up @@ -262,8 +264,10 @@ func (r PimActiveRoleAssignmentResource) Read() sdk.ResourceFunc {
}
var instance *roleassignmentscheduleinstances.RoleAssignmentScheduleInstance
for _, item := range items.Items {
if *item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect {
if *item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, id.Scope) {
instance = &item
break
}
}
if instance == nil {
Expand Down Expand Up @@ -629,9 +633,11 @@ func waitForActiveRoleAssignment(ctx context.Context, client *roleassignmentsche

for _, item := range items.Items {
if *item.Properties.RoleDefinitionId == roleDefinitionId &&
*item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect {
*item.Properties.MemberType == roleassignmentscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, scope) {
state = "Found"
result = item
break
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"regexp"
"strconv"
"strings"
"time"

// nolint: staticcheck
Expand Down Expand Up @@ -180,7 +181,8 @@ func (r PimEligibleRoleAssignmentResource) Create() sdk.ResourceFunc {
return fmt.Errorf("listing role assignments on scope %s: %+v", id, err)
}
for _, item := range items.Items {
if *item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect {
if *item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, id.Scope) {
return metadata.ResourceRequiresImport(r.ResourceType(), id)
}
}
Expand Down Expand Up @@ -262,8 +264,10 @@ func (r PimEligibleRoleAssignmentResource) Read() sdk.ResourceFunc {
}
var instance *roleeligibilityscheduleinstances.RoleEligibilityScheduleInstance
for _, item := range items.Items {
if *item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect {
if *item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, id.Scope) {
instance = &item
break
}
}
if instance == nil {
Expand Down Expand Up @@ -629,9 +633,11 @@ func waitForEligibleRoleAssignmentSchedule(ctx context.Context, client *roleelig

for _, item := range items.Items {
if *item.Properties.RoleDefinitionId == roleDefinitionId &&
*item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect {
*item.Properties.MemberType == roleeligibilityscheduleinstances.MemberTypeDirect &&
strings.EqualFold(*item.Properties.Scope, scope) {
state = "Found"
result = item
break
}
}

Expand Down

0 comments on commit 9dac883

Please sign in to comment.