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

Ciam 6580 issue 471 hiearchical groups #472

Merged
merged 7 commits into from
Aug 16, 2023

Conversation

eatikrh
Copy link
Contributor

@eatikrh eatikrh commented Aug 9, 2023

This PR creates hierarchical groups using the configuration parameters: groups-count-each-level, groups-hierarchy-depth, groups-with-hierarchy. Boolean parameter groups-with-hierarchy is "false" by default. With the default values it works as before.

With groups-with-hierarchy=true, it ignores groups-per-realm parameter and creates the group tree structure as defined by the other parameters. This will be groups-count-each-level ^ groups-hierarchy-depth.

The implementation honors groups-per-transaction.

We adopted a subgroup naming convention that uses "." in the group names which allows finding the parent group even if it was created in a previous transaction.

Closes #471

@eatikrh eatikrh force-pushed the CIAM-6580-issue-471-hiearchical-groups branch from b5363b3 to 6814ccc Compare August 9, 2023 21:31
@kami619 kami619 requested a review from ahus1 August 9, 2023 21:39
@eatikrh eatikrh force-pushed the CIAM-6580-issue-471-hiearchical-groups branch from 6814ccc to 539129e Compare August 9, 2023 21:59
Copy link
Contributor

@ahus1 ahus1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @eatikrh - thank you for providing this PR. I pushed one review commit with aligns some code formatting and avoids star imports.

I also found that

name1.split(GROUP_NAME_SEPARATOR);

might not lead to the results you want to see, as the parameter is a regex. Passing in a dot (.) would match any character. I've suggested

name1.split(Pattern.quote(GROUP_NAME_SEPARATOR));

instead.

There is also one unused parameter. Please have a look.

Once you're ok with the code, please have a team member of your team test this code if it delivers the results you want to see (I've seen you've discussed it with @mposolda in the parent issue), and then let them add a comment/review here. Then it can be merged by one of the maintainers of this project.

Thanks!

@@ -972,12 +979,49 @@ private void createClients(RealmContext context, Task task, KeycloakSession sess
task.debug(logger, "Created %d clients in realm %s", context.getClientCount(), context.getRealm().getName());
}

private void createGroups(RealmContext context, int startIndex, int endIndex, KeycloakSession session) {
private String getGroupName(boolean hiearchicalGroups, int hierarchyDepth, int countGroupsAtEachLevel, String prefix, int currentCount) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter hierarchyDepth is not used, please review/test the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ahus1
Thank you for the review and the fixes. Yes "." is tricky in regex. I removed the unused parameter and a typo.

@ahus1 ahus1 self-assigned this Aug 10, 2023
@eatikrh
Copy link
Contributor Author

eatikrh commented Aug 10, 2023

@mposolda can please also take a look at this PR? Also do we have a Code Style template for IntelliJ?
Thanks

@ahus1
Copy link
Contributor

ahus1 commented Aug 10, 2023

@eatikrh - there is no code style for this ... once this PR is merged, I'll see that we add a minimal Checkstyle configuration.

@ahus1 ahus1 removed their assignment Aug 10, 2023
Copy link
Contributor

@mposolda mposolda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eatikrh Thanks for the PR! It looks great. I've added one comment inline regarding some docs for new parameters.

Also it can be ideal to add some documentation with examples into this file https://github.com/keycloak/keycloak-benchmark/blob/22799bc65e39f8e353f2fb57a6938d051682b015/doc/dataset/modules/ROOT/pages/using-provider.adoc . Is it possible to add some new section like Create many groups with some examples for hierarchical and non-hierarchical groups?

Copy link
Contributor

@mposolda mposolda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eatikrh This looks perfect to me, Thanks!

@ahus1 Do you have any more feedback to this? To me, this PR looks good, so feel free to merge whenever this PR looks ok to you.

Copy link
Contributor

@ahus1 ahus1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes. I updated the docs a little as I am a fan of AsciiDoc description lists.

@ahus1 ahus1 merged commit db3d7c1 into keycloak:main Aug 16, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend DatasetResourceProvider to create hierarchical groups with many subgroups
3 participants