Skip to content

Commit

Permalink
KEYCLOAK-19711 Change Locations of h2-db files and gzip files
Browse files Browse the repository at this point in the history
  • Loading branch information
DGuhr authored and pedroigor committed Nov 4, 2021
1 parent adda65d commit 29b1aec
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class Environment {
public static final String CLI_ARGS = "kc.config.args";
public static final String PROFILE ="kc.profile";
public static final String ENV_PROFILE ="KC_PROFILE";
public static final String DATA_PATH = "/data";

private Environment() {}

Expand All @@ -60,6 +61,10 @@ public static Path getHomePath() {
return null;
}

public static String getDataDir() {
return getHomeDir() + DATA_PATH;
}

public static Path getProvidersPath() {
Path homePath = Environment.getHomePath();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ public File getTmpDirectory() {
throw new RuntimeException("It was not possible to create temporary directory keycloak-quarkus-tmp", ioex);
}
} else {
tmpDir = new File(homeDir, "tmp");
String dataDir = Environment.getDataDir();
tmpDir = new File(dataDir, "tmp");
tmpDir.mkdir();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private enum Vendor {
public String apply(String alias) {
if ("h2-file".equalsIgnoreCase(alias)) {
return "jdbc:h2:file:${kc.home.dir:${kc.db.url.path:~}}" + File.separator + "${kc.data.dir:data}"
+ File.separator + "keycloakdb${kc.db.url.properties:;;AUTO_SERVER=TRUE}";
+ File.separator + "h2" + File.separator + "keycloakdb${kc.db.url.properties:;;AUTO_SERVER=TRUE}";
}
return "jdbc:h2:mem:keycloakdb${kc.db.url.properties:}";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void testDatabaseDefaults() {
System.setProperty(CLI_ARGS, "--db=h2-file");
SmallRyeConfig config = createConfig();
assertEquals(QuarkusH2Dialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
assertEquals("jdbc:h2:file:~/data/keycloakdb;;AUTO_SERVER=TRUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
assertEquals("jdbc:h2:file:~/data/h2/keycloakdb;;AUTO_SERVER=TRUE", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());

System.setProperty(CLI_ARGS, "--db=h2-mem");
config = createConfig();
Expand All @@ -250,7 +250,7 @@ public void testDatabaseProperties() {
System.setProperty(CLI_ARGS, "--db=h2-file");
SmallRyeConfig config = createConfig();
assertEquals(QuarkusH2Dialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
assertEquals("jdbc:h2:file:test-dir" + File.separator + "data" + File.separator + "keycloakdb;;test=test;test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
assertEquals("jdbc:h2:file:test-dir" + File.separator + "data" + File.separator + "h2" + File.separator + "keycloakdb;;test=test;test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());

System.setProperty("kc.db.url.properties", "?test=test&test1=test1");
System.setProperty(CLI_ARGS, "--db=mariadb");
Expand Down

0 comments on commit 29b1aec

Please sign in to comment.