Allow importing realms during startup#10754
Conversation
There was a problem hiding this comment.
@pedroigor Not looked at the code yet, but first review round about the --dir export:
I ran kc.sh export --dir=. after setting up the initial admin user using start-dev.
expectation:
master-realm.json and master-user.json appear in the bin directory. Success msg is shown.
Outcome:
- Success-MSG is shown
Suggestion: It states for users org.keycloak.exportimport.dir.DirExportProvider] (main) Users 0-0 exported - can we make this a bit more concise? e.g. "Successfully exported {count} users to file {filename} in dir {dir}"? Users 0-0 sounds a bit weird imo.
- files get created, but users-file has a "0" at the end. so called
master-users-0.json- I think it would be better when we have onlymaster-users.jsonas you state below in the docs when there are <50 users to export, and then go on withmaster-users-1.jsonfor chunks > 1 if any?
General question: This PR allows to use separate commands for import/export. to really allow to "startup and import" in one step, one would now run the container image using...? first import, then start-dev afterwards? Looking at https://www.keycloak.org/server/containers I just wonder how this would fit in the examples for the entrypoint / development mode, and I guess it wouldn't without spinning up the container twice, right? I am wondering if that's really the desired behaviour here. I would've thought it's an env config like KC_IMPORT_DIR=dir/with/my/files and when starting up the container using start/start-dev and this environment var is set, import happens automagically?!
ok forget that last one, just read about the import-realm being a subcommand of start/start-dev :)
There was a problem hiding this comment.
done with the smoke tests for "export to dir" part for now.
tested:
- export to dir works in general
- specifying a file instead of a directory throws error
- specifying --users-per-file=0 throws an error (division to zero, maybe we want to change the message? I still need types for the CLI ;) )
- different user export modes are working (see specific comments and my comment about the success msg and file ending for that one, i'd like to remove the -0 to stay consistent)
- test "non-usual characters and emojis" in username: get exported correctly. see image with list of users i tried:
DGuhr
left a comment
There was a problem hiding this comment.
Overall very nice, thanks for that 👍 All of the change requests are minor ones i guess. Will start the actual code review later on
I'm confused, could you elaborate more, please? |
Example: For the striked through part: forget about it, as said. |
|
Didn't test the export yet, but auto-import on server startup works for me. 👍 |
|
@stianst it's a pity that you didn't add this functionality in release |
|
@eabykov yes, it is targeted for 18 |
17.0.2? |
|
17.1.0? |
@tpischke-bedag It wasn't me who compiled Milestones 🤣 |
keycloak.importsystem propertyimport-realmoption to bothstartandstart-devcommands to import realm configuration files from thedata/importdirectory. No need to manually specify files, reducing the chance of errors, and reducing the number of steps when importing realms using containers.Closes #9261