Skip to content

Commit 8dab904

Browse files
Merge pull request #299 from sabre1041/fix-subgroup-npe
Corrected NPE to manage subgroups in keycloak 23
2 parents fc4181e + 16cc976 commit 8dab904

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pkg/syncer/keycloak.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,12 @@ func (k *KeycloakSyncer) Sync() ([]userv1.Group, error) {
227227
parentGroups := []string{}
228228

229229
for _, group := range k.CachedGroups {
230-
groupSubGroups := *group.SubGroups
231-
for _, subgroup := range groupSubGroups {
232-
if *subgroup.Name == *cachedGroup.Name {
233-
parentGroups = append(parentGroups, *group.Name)
230+
if group.SubGroups != nil {
231+
groupSubGroups := *group.SubGroups
232+
for _, subgroup := range groupSubGroups {
233+
if *subgroup.Name == *cachedGroup.Name {
234+
parentGroups = append(parentGroups, *group.Name)
235+
}
234236
}
235237
}
236238
}
@@ -282,7 +284,7 @@ func (k *KeycloakSyncer) processGroupsAndMembers(group, parentGroup *gocloak.Gro
282284
}
283285

284286
// Process Subgroups
285-
if redhatcopv1alpha1.SubSyncScope == scope {
287+
if redhatcopv1alpha1.SubSyncScope == scope && group.SubGroups != nil {
286288
groupSubGroups := *group.SubGroups
287289
for _, subGroup := range groupSubGroups {
288290
if _, subGroupFound := k.CachedGroups[*subGroup.ID]; !subGroupFound {

0 commit comments

Comments
 (0)