Unable to add "--import-realm" to import embedded realm files #97
Replies: 2 comments 3 replies
-
Hi, thanks for starting this discussion. |
Beta Was this translation helpful? Give feedback.
-
Other suggestion to not change the API at all:
public KeycloakContainer withRealmImportFile(String importFile) {
this.importFiles.add(importFile);
return self();
}
public KeycloakContainer withRealmImportFiles(String... files) {
Arrays.stream(files).forEach(this::withRealmImportFile);
return self();
}
if (importFiles != null) {
for (String importFile : importFiles) {
// TODO: a strategy for files with the same name but in the different dirs
String importFileInContainer = DEFAULT_REALM_IMPORT_FILES_LOCATION + FilenameUtils.getName(importFile);
withCopyFileToContainer(MountableFile.forClasspathResource(importFile), importFileInContainer);
}
commandParts.add("--import-realm");
} Which then allows to perform a call to |
Beta Was this translation helpful? Give feedback.
-
I am using a custom build keycloak image that we use for our local development, but also during unit testing. This docker image contains a realm-export.json file inside the
/opt/keycloak/data/import
folder that I would like to be picked up during start-up of the testcontainer.I've gone into the code and see that there are 2 configuration options:
which will later on be used in the
configure method
:This requires you to explicitly define a realm file from your project however, and does not allow you to just enable the
--import-realm
trigger to pick up the already embedded realm file(s) inside of the keycloak image used.Unless I'm missing something and there is in fact a way to do this, I would like to suggest to enable this possibility:
useRealmImport
that can be set by a method on the KeycloakContainer class of the same namewithRealmImportFile
orwithRealmImportFiles
would also automatically set this new boolean flagconfigure
method:commandParts.add("--import-realm");
commandParts.add("--import-realm");
from the existing!importFiles.isEmpty()
if-conditionalI could make a PR for this if you agree.
Beta Was this translation helpful? Give feedback.
All reactions