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:
Tjeu Kayim 2021-04-29 10:44:33 +02:00 committed by Pedro Igor
parent ce4f31a8c3
commit 0bf347e26d
2 changed files with 13 additions and 2 deletions

View file

@ -98,11 +98,14 @@ public class ConfigArgsConfigSource extends PropertiesConfigSource {
String value; 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 // the argument has a simple value. Eg.: key=pair
value = keyValue[1]; value = keyValue[1];
} else { } 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); key = NS_KEYCLOAK_PREFIX + key.substring(2);

View file

@ -179,6 +179,14 @@ public class ConfigurationTest {
assertEquals("jdbc:mariadb://localhost/keycloak", config.getConfigValue("quarkus.datasource.jdbc.url").getValue()); 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 @Test
public void testDatabaseDefaults() { public void testDatabaseDefaults() {
System.setProperty("kc.config.args", "--db=h2-file"); System.setProperty("kc.config.args", "--db=h2-file");