Ability to import realm from local file
hohwille opened this issue · 6 comments
Description
You have hardwired in your code that realm files must be on the classpath:
I would like to reuse the config file I already have in my project for docker compose without duplicating it into
src/test/resources
.I can manually inject it into the container like this:
byte[] data = Files.readAllBytes(Path.of("../docker/keycloak/import/realm.json"));
KEYCLOAK.withCopyToContainer(Transferable.of(data), "/opt/keycloak/data/import/realm.json");
However, I cannot set the --import-realm
option then:
It would be awesome to have a way to specify a regular file to import as realm e.g. like this:
KEYCLOAK.withRealmImportFile("file:../docker/keycloak/import/realm.json");
Or otherwise have a way to add custom entries to commandParts
e.g. via withCommand
.
Motivation
So that I am not forced to redundantly add the realm config I already have for docker compose into src/test/resources
.
Details
Already provided in description.
you can use .withFileSystemBind("../docker/realm-export.json", "/opt/keycloak/data/import/realm-export.json",
Hi @hohwille
I can think of setting the --import-realm
flag as default, even if not import file is available. This wouldn't hurt if there's no file and one can simply set any file outside the classpath (with copy or bind) as import file.
Would that be ok for you?
Hi @hohwille I can think of setting the
--import-realm
flag as default, even if not import file is available. This wouldn't hurt if there's no file and one can simply set any file outside the classpath (with copy or bind) as import file. Would that be ok for you?
That would indeed be a great option.
You could also think about adding a withRealmImportFile
that takes a MoutableFile
as argument and make the String arg variant of this method use MountableFile.forClasspathResource(importFile)
and delegate to the MoutableFile
one.