KEYCLOAK-17897 Parse CLI arguments with multiple =
To support cases like --db-url=jdbc:mariadb://localhost/kc?a=1
Reverts a part of commit 04415d34ea
This commit is contained in:
parent
ce4f31a8c3
commit
0bf347e26d
2 changed files with 13 additions and 2 deletions
|
@ -98,11 +98,14 @@ public class ConfigArgsConfigSource extends PropertiesConfigSource {
|
|||
|
||||
String value;
|
||||
|
||||
if (keyValue.length == 2) {
|
||||
if (keyValue.length == 1) {
|
||||
continue;
|
||||
} else if (keyValue.length == 2) {
|
||||
// the argument has a simple value. Eg.: key=pair
|
||||
value = keyValue[1];
|
||||
} else {
|
||||
continue;
|
||||
// to support cases like --db-url=jdbc:mariadb://localhost/kc?a=1
|
||||
value = arg.substring(key.length() + 1);
|
||||
}
|
||||
|
||||
key = NS_KEYCLOAK_PREFIX + key.substring(2);
|
||||
|
|
|
@ -179,6 +179,14 @@ public class ConfigurationTest {
|
|||
assertEquals("jdbc:mariadb://localhost/keycloak", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDatabaseUrlProperties() {
|
||||
System.setProperty("kc.config.args", "--db=mariadb,--db-url=jdbc:mariadb:aurora://foo/bar?a=1&b=2");
|
||||
SmallRyeConfig config = createConfig();
|
||||
assertEquals(MariaDBDialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
|
||||
assertEquals("jdbc:mariadb:aurora://foo/bar?a=1&b=2", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDatabaseDefaults() {
|
||||
System.setProperty("kc.config.args", "--db=h2-file");
|
||||
|
|
Loading…
Reference in a new issue