Skip to content

Commit

Permalink
Make key names consistent with prior resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitingjr authored and johnaohara committed Sep 20, 2024
1 parent 8852c36 commit b140688
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ public class Const {
public static final String HORREUM_DEV_AMQP_ENABLED = "horreum.dev-services.amqp.enabled";
public static final String HORREUM_DEV_AMQP_IMAGE = "horreum.dev-services.amqp.image";
public static final String HORREUM_DEV_AMQP_NETWORK_ALIAS = "horreum.dev-services.amqp.network-alias";
public static final String HORREUM_DEV_AMQP_MAPPED_PORT = "horreum.dev-services.amqp.mapped.port";
public static final String HORREUM_DEV_AMQP_MAPPED_HOST = "horreum.dev-services.amqp.mapped.host";

public static final String DEFAULT_DB_USERNAME = "dbadmin";
public static final String DEFAULT_DB_PASSWORD = "secret";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public Map<String, String> start(Optional<Network> network) {
String mappedPort = amqpContainer.getMappedPort(5672).toString();
String host = inContainer ? networkAlias : "localhost";

return Map.of(HORREUM_DEV_AMQP_MAPPED_PORT, mappedPort,
HORREUM_DEV_AMQP_MAPPED_HOST, host);
return Map.of("artemis.container.name", host,
"artemis.container.port", mappedPort);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class HorreumResource implements ResourceLifecycleManager {

private static GenericContainer<?> horreumContainer;
private StringBuilder javaOptions = new StringBuilder();
private boolean inContainer = false;

private String networkAlias = "";

Expand All @@ -27,25 +27,30 @@ public void init(Map<String, String> initArgs) {

final String HORREUM_IMAGE = initArgs.get(HORREUM_DEV_HORREUM_HORREUM_IMAGE);

inContainer = initArgs.containsKey("inContainer") && initArgs.get("inContainer").equals("true");
networkAlias = initArgs.get(HORREUM_DEV_HORREUM_NETWORK_ALIAS);
Network network = HorreumResources.getNetwork();

horreumContainer = (initArgs.containsKey(HORREUM_DEV_HORREUM_CONTAINER_PORT))
? new FixedHostPortGenericContainer<>(HORREUM_IMAGE)
.withFixedExposedPort(Integer.parseInt(initArgs.get(HORREUM_DEV_HORREUM_CONTAINER_PORT)), 8080)
: new GenericContainer<>(HORREUM_IMAGE).withExposedPorts(8080);
String keycloakHost = initArgs.get("keycloak.host");
String keycloakHostUrl = initArgs.get("keycloak.host");
String jdbcUrl = initArgs.get("quarkus.datasource.jdbc.url");
if (inContainer) {
String keycloakNetworkAlias = initArgs.get(HORREUM_DEV_KEYCLOAK_NETWORK_ALIAS);
keycloakHostUrl = "http://".concat(keycloakNetworkAlias).concat(":8080/");
String postgresNetworkAlias = initArgs.get(HORREUM_DEV_POSTGRES_NETWORK_ALIAS);
jdbcUrl = "jdbc:postgresql://".concat(postgresNetworkAlias).concat(":5432/horreum?loggerLevel=OFF");
}

keycloakHost = keycloakHost.replace("localhost", networkAlias);
String keycloakUrl = String.format("%s/realms/horreum", keycloakHost);
String keycloakUrl = String.format("%s/realms/horreum", keycloakHostUrl);
String horreumUrl = "http://" + networkAlias + ":8081";
String jdbcUrl = initArgs.get("quarkus.datasource.jdbc.url");
jdbcUrl = jdbcUrl.replace("localhost", networkAlias);

horreumContainer
.withEnv("horreum.keycloak.url", keycloakHost)
.withEnv("horreum.keycloak.url", keycloakUrl)
.withEnv("quarkus.oidc.auth-server-url", keycloakUrl)
.withEnv("quarkus.keycloak.admin-client.server-url", keycloakHost)
.withEnv("quarkus.keycloak.admin-client.server-url", keycloakHostUrl)
.withEnv("quarkus.keycloak.admin-client.client-id", "horreum")
.withEnv("quarkus.keycloak.admin-client.realm", "horreum")
.withEnv("quarkus.keycloak.admin-client.client-secret", "**********")
Expand Down Expand Up @@ -86,6 +91,7 @@ public Map<String, String> start(Optional<Network> network) {

horreumContainer.start();
String horreumContainerName = horreumContainer.getContainerName().replaceAll("/", "");
horreumContainerName = inContainer ? networkAlias : horreumContainerName;
Integer port = horreumContainer.getMappedPort(8080);

return Map.of("horreum.container.name", horreumContainerName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public Map<String, String> start(Optional<Network> network) {

boolean https = keycloakContainer.getExposedPorts().contains(8443);
String mappedPort = keycloakContainer.getMappedPort(https ? 8443 : 8080).toString();

String keycloakHost = String.format(https ? "https://%s:%s" : "http://%s:%s", keycloakContainer.getHost(), mappedPort);

return Map.of(
Expand Down

0 comments on commit b140688

Please sign in to comment.