Skip to content

Commit

Permalink
Remove quarkus-keycloak-admin-resteasy-client from horreum-infra-comm…
Browse files Browse the repository at this point in the history
…on: Fixes #2016
  • Loading branch information
johnaohara committed Sep 21, 2024
1 parent b140688 commit 69ec5d3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

import java.util.Map;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;

import io.hyperfoil.tools.horreum.infra.common.SelfSignedCert;
Expand Down Expand Up @@ -53,6 +55,8 @@ public Map<String, String> start() {

SelfSignedCert postgresSelfSignedCert = new SelfSignedCert("RSA", "SHA256withRSA", "localhost", 123);

Config config = ConfigProvider.getConfig();

//todo: pick up from configuration
Map<String, String> containerArgs = Map.ofEntries(
Map.entry(HORREUM_DEV_KEYCLOAK_ENABLED, "true"),
Expand All @@ -67,8 +71,11 @@ public Map<String, String> start() {
Map.entry(HORREUM_DEV_KEYCLOAK_DB_PASSWORD, DEFAULT_KC_DB_PASSWORD),
Map.entry(HORREUM_DEV_KEYCLOAK_ADMIN_USERNAME, DEFAULT_KC_ADMIN_USERNAME),
Map.entry(HORREUM_DEV_KEYCLOAK_ADMIN_PASSWORD, DEFAULT_KC_ADMIN_PASSWORD),
Map.entry("horreum.bootstrap.password", HORREUM_BOOTSTRAP_PASSWORD) // well known bootstrap password instead of a random one
);
Map.entry("horreum.bootstrap.password", HORREUM_BOOTSTRAP_PASSWORD), // well known bootstrap password instead of a random one
Map.entry("quarkus.http.port",
config.getOptionalValue("quarkus.http.port", String.class).orElse("8080")),
Map.entry("quarkus.http.host",
config.getOptionalValue("quarkus.http.host", String.class).orElse("localhost")));
return startContainers(containerArgs);
} catch (Exception e) {
log.fatal("Could not start Horreum services", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.Optional;
import java.util.function.BooleanSupplier;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;

import io.hyperfoil.tools.horreum.dev.services.deployment.config.DevServicesConfig;
Expand Down Expand Up @@ -106,6 +108,12 @@ public void startHorreumContainers(
containerArgs.put(HORREUM_DEV_POSTGRES_SSL_CERTIFICATE_KEY, postgresSelfSignedCert.getKeyString());
}

Config config = ConfigProvider.getConfig();
containerArgs.put("quarkus.http.port",
config.getOptionalValue("quarkus.http.port", String.class).orElse("8080"));
containerArgs.put("quarkus.http.host",
config.getOptionalValue("quarkus.http.host", String.class).orElse("localhost"));

Map<String, String> envvars = HorreumResources
.startContainers(Collections.unmodifiableMap(containerArgs));

Expand Down
5 changes: 3 additions & 2 deletions infra/horreum-infra-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-keycloak-admin-resteasy-client</artifactId>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>${keycloak.version}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import org.bouncycastle.openssl.PEMKeyPair;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.logging.Logger;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.keycloak.admin.client.Keycloak;
Expand Down Expand Up @@ -149,9 +147,8 @@ public static Map<String, String> startContainers(Map<String, String> initArgs)

//update running keycloak realm with dev services configuration
try {
Config config = ConfigProvider.getConfig();
String httpPort = config.getOptionalValue("quarkus.http.port", String.class).orElse("8080");
String httpHost = config.getOptionalValue("quarkus.http.host", String.class).orElse("localhost");
String httpPort = initArgs.get("quarkus.http.port");
String httpHost = initArgs.get("quarkus.http.host");

ClientRepresentation uiClient = keycloak.realm(HORREUM_REALM).clients().findByClientId("horreum-ui").get(0);
uiClient.getWebOrigins().add("http://".concat(httpHost).concat(":").concat(httpPort));
Expand Down
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@

<module.skipCopyDependencies>false</module.skipCopyDependencies>

<keycloak.version>25.0.2</keycloak.version>
<dev.images.postgres>postgres:16</dev.images.postgres>
<dev.images.keycloak>quay.io/keycloak/keycloak:25.0.2</dev.images.keycloak>
<dev.images.keycloak>quay.io/keycloak/keycloak:${keycloak.version}</dev.images.keycloak>

<horreum.version>${project.version}</horreum.version>
<major-version>0.16</major-version>
Expand Down

0 comments on commit 69ec5d3

Please sign in to comment.