Skip to content

Commit

Permalink
Merge pull request #299 from sabre1041/fix-subgroup-npe
Browse files Browse the repository at this point in the history
Corrected NPE to manage subgroups in keycloak 23
  • Loading branch information
raffaelespazzoli authored Dec 14, 2023
2 parents fc4181e + 16cc976 commit 8dab904
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/syncer/keycloak.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,12 @@ func (k *KeycloakSyncer) Sync() ([]userv1.Group, error) {
parentGroups := []string{}

for _, group := range k.CachedGroups {
groupSubGroups := *group.SubGroups
for _, subgroup := range groupSubGroups {
if *subgroup.Name == *cachedGroup.Name {
parentGroups = append(parentGroups, *group.Name)
if group.SubGroups != nil {
groupSubGroups := *group.SubGroups
for _, subgroup := range groupSubGroups {
if *subgroup.Name == *cachedGroup.Name {
parentGroups = append(parentGroups, *group.Name)
}
}
}
}
Expand Down Expand Up @@ -282,7 +284,7 @@ func (k *KeycloakSyncer) processGroupsAndMembers(group, parentGroup *gocloak.Gro
}

// Process Subgroups
if redhatcopv1alpha1.SubSyncScope == scope {
if redhatcopv1alpha1.SubSyncScope == scope && group.SubGroups != nil {
groupSubGroups := *group.SubGroups
for _, subGroup := range groupSubGroups {
if _, subGroupFound := k.CachedGroups[*subGroup.ID]; !subGroupFound {
Expand Down

0 comments on commit 8dab904

Please sign in to comment.