From a9959f6c459554cc5000768e49943e29fd0fcf35 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Wed, 21 Jun 2023 17:53:45 +0200 Subject: [PATCH 1/2] Provide a way to push env variables to dev services containers Fixes #33864 --- .../spi/DevServicesDatasourceContainerConfig.java | 7 +++++++ .../devservices/DevServicesDatasourceProcessor.java | 1 + .../runtime/DevServicesBuildTimeConfig.java | 6 ++++++ .../db2/deployment/DB2DevServicesProcessor.java | 2 ++ .../deployment/MariaDBDevServicesProcessor.java | 3 +++ .../mssql/deployment/MSSQLDevServicesProcessor.java | 3 +++ .../mysql/deployment/MySQLDevServicesProcessor.java | 3 +++ .../deployment/OracleDevServicesProcessor.java | 2 ++ .../deployment/PostgresqlDevServicesProcessor.java | 3 +++ .../DevServicesElasticsearchProcessor.java | 2 ++ .../ElasticsearchDevServicesBuildTimeConfig.java | 12 ++++++++++-- .../devservices/InfinispanDevServiceProcessor.java | 1 + .../client/runtime/InfinispanDevServicesConfig.java | 12 ++++++++++-- .../client/deployment/DevServicesKafkaProcessor.java | 10 ++++++++-- .../deployment/KafkaDevServicesBuildTimeConfig.java | 6 ++++++ .../deployment/DevServicesKubernetesProcessor.java | 10 ++++++++-- .../KubernetesDevServicesBuildTimeConfig.java | 7 +++++++ .../deployment/DevServicesBuildTimeConfig.java | 6 ++++++ .../deployment/DevServicesMongoProcessor.java | 12 ++++++++---- .../devservices/keycloak/DevServicesConfig.java | 11 +++++++++-- .../keycloak/KeycloakDevServicesProcessor.java | 1 + .../redis/client/deployment/DevServicesConfig.java | 12 ++++++++++-- .../client/deployment/DevServicesRedisProcessor.java | 1 + .../ApicurioRegistryDevServicesBuildTimeConfig.java | 7 +++++++ .../DevServicesApicurioRegistryProcessor.java | 8 ++++++-- .../deployment/AmqpDevServicesBuildTimeConfig.java | 7 +++++++ .../amqp/deployment/AmqpDevServicesProcessor.java | 9 ++++++--- .../deployment/MqttDevServicesBuildTimeConfig.java | 7 +++++++ .../mqtt/deployment/MqttDevServicesProcessor.java | 8 ++++++-- .../RabbitMQDevServicesBuildTimeConfig.java | 6 ++++++ .../deployment/RabbitMQDevServicesProcessor.java | 8 ++++++-- 31 files changed, 168 insertions(+), 25 deletions(-) diff --git a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceContainerConfig.java b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceContainerConfig.java index e4b533af72e13..357a5105d2caf 100644 --- a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceContainerConfig.java +++ b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceContainerConfig.java @@ -7,6 +7,7 @@ public class DevServicesDatasourceContainerConfig { private final Optional imageName; + private final Map containerEnv; private final Map containerProperties; private final Map additionalJdbcUrlProperties; private final OptionalInt fixedExposedPort; @@ -18,6 +19,7 @@ public class DevServicesDatasourceContainerConfig { private final Map volumes; public DevServicesDatasourceContainerConfig(Optional imageName, + Map containerEnv, Map containerProperties, Map additionalJdbcUrlProperties, OptionalInt port, @@ -28,6 +30,7 @@ public DevServicesDatasourceContainerConfig(Optional imageName, Optional initScriptPath, Map volumes) { this.imageName = imageName; + this.containerEnv = containerEnv; this.containerProperties = containerProperties; this.additionalJdbcUrlProperties = additionalJdbcUrlProperties; this.fixedExposedPort = port; @@ -43,6 +46,10 @@ public Optional getImageName() { return imageName; } + public Map getContainerEnv() { + return containerEnv; + } + public Map getContainerProperties() { return containerProperties; } diff --git a/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java b/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java index bfeafc14aa2cf..972159252707b 100644 --- a/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java +++ b/extensions/datasource/deployment/src/main/java/io/quarkus/datasource/deployment/devservices/DevServicesDatasourceProcessor.java @@ -276,6 +276,7 @@ private RunningDevService startDevDb( try { DevServicesDatasourceContainerConfig containerConfig = new DevServicesDatasourceContainerConfig( dataSourceBuildTimeConfig.devservices.imageName, + dataSourceBuildTimeConfig.devservices.containerEnv, dataSourceBuildTimeConfig.devservices.containerProperties, dataSourceBuildTimeConfig.devservices.properties, dataSourceBuildTimeConfig.devservices.port, diff --git a/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DevServicesBuildTimeConfig.java b/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DevServicesBuildTimeConfig.java index a35e46039a823..d06573c422c20 100644 --- a/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DevServicesBuildTimeConfig.java +++ b/extensions/datasource/runtime/src/main/java/io/quarkus/datasource/runtime/DevServicesBuildTimeConfig.java @@ -28,6 +28,12 @@ public class DevServicesBuildTimeConfig { @ConfigItem public Optional imageName; + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; + /** * Generic properties that are passed for additional container configuration. *

diff --git a/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java b/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java index fc75323b23ced..d6431842fc7fa 100644 --- a/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java +++ b/extensions/devservices/db2/src/main/java/io/quarkus/devservices/db2/deployment/DB2DevServicesProcessor.java @@ -53,6 +53,8 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt Labels.addDataSourceLabel(container, datasourceName); Volumes.addVolumes(container, containerConfig.getVolumes()); + container.withEnv(containerConfig.getContainerEnv()); + containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam); containerConfig.getCommand().ifPresent(container::setCommand); containerConfig.getInitScriptPath().ifPresent(container::withInitScript); diff --git a/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java b/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java index e3b07f6d3125c..dfe710c68ae60 100644 --- a/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java +++ b/extensions/devservices/mariadb/src/main/java/io/quarkus/devservices/mariadb/deployment/MariaDBDevServicesProcessor.java @@ -36,6 +36,7 @@ public class MariaDBDevServicesProcessor { DevServicesDatasourceProviderBuildItem setupMariaDB( List devServicesSharedNetworkBuildItem) { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.MARIADB, new DevServicesDatasourceProvider() { + @SuppressWarnings("unchecked") @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, @@ -56,6 +57,8 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt Labels.addDataSourceLabel(container, datasourceName); Volumes.addVolumes(container, containerConfig.getVolumes()); + container.withEnv(containerConfig.getContainerEnv()); + if (containerConfig.getContainerProperties().containsKey(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)) { container.withConfigurationOverride( containerConfig.getContainerProperties().get(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)); diff --git a/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java b/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java index 3da12d579152f..7f32c0dd79b8d 100644 --- a/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java +++ b/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java @@ -31,6 +31,7 @@ public class MSSQLDevServicesProcessor { DevServicesDatasourceProviderBuildItem setupMSSQL( List devServicesSharedNetworkBuildItem) { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.MSSQL, new DevServicesDatasourceProvider() { + @SuppressWarnings("unchecked") @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, @@ -49,6 +50,8 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt Labels.addDataSourceLabel(container, datasourceName); Volumes.addVolumes(container, containerConfig.getVolumes()); + container.withEnv(containerConfig.getContainerEnv()); + containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam); containerConfig.getCommand().ifPresent(container::setCommand); containerConfig.getInitScriptPath().ifPresent(container::withInitScript); diff --git a/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java b/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java index f59ac3f9cb4a1..cd884aa83b520 100644 --- a/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java +++ b/extensions/devservices/mysql/src/main/java/io/quarkus/devservices/mysql/deployment/MySQLDevServicesProcessor.java @@ -35,6 +35,7 @@ public class MySQLDevServicesProcessor { DevServicesDatasourceProviderBuildItem setupMysql( List devServicesSharedNetworkBuildItem) { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.MYSQL, new DevServicesDatasourceProvider() { + @SuppressWarnings("unchecked") @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, @@ -55,6 +56,8 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt Labels.addDataSourceLabel(container, datasourceName); Volumes.addVolumes(container, containerConfig.getVolumes()); + container.withEnv(containerConfig.getContainerEnv()); + if (containerConfig.getContainerProperties().containsKey(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)) { container.withConfigurationOverride( containerConfig.getContainerProperties().get(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)); diff --git a/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java b/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java index 509f4dcd2b594..aca0d9aef329f 100644 --- a/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java +++ b/extensions/devservices/oracle/src/main/java/io/quarkus/devservices/oracle/deployment/OracleDevServicesProcessor.java @@ -60,6 +60,8 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt Labels.addDataSourceLabel(container, datasourceName); Volumes.addVolumes(container, containerConfig.getVolumes()); + container.withEnv(containerConfig.getContainerEnv()); + // We need to limit the maximum amount of CPUs being used by the container; // otherwise the hardcoded memory configuration of the DB might not be enough to successfully boot it. // See https://github.com/gvenzl/oci-oracle-xe/issues/64 diff --git a/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java b/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java index b4235ce941207..afaeb640fbfa8 100644 --- a/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java +++ b/extensions/devservices/postgresql/src/main/java/io/quarkus/devservices/postgresql/deployment/PostgresqlDevServicesProcessor.java @@ -42,6 +42,7 @@ ConsoleCommandBuildItem psqlCommand(DevServicesLauncherConfigResultBuildItem dev DevServicesDatasourceProviderBuildItem setupPostgres( List devServicesSharedNetworkBuildItem) { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.POSTGRESQL, new DevServicesDatasourceProvider() { + @SuppressWarnings("unchecked") @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, @@ -62,6 +63,8 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt Labels.addDataSourceLabel(container, datasourceName); Volumes.addVolumes(container, containerConfig.getVolumes()); + container.withEnv(containerConfig.getContainerEnv()); + containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam); containerConfig.getCommand().ifPresent(container::setCommand); containerConfig.getInitScriptPath().ifPresent(container::withInitScript); diff --git a/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/DevServicesElasticsearchProcessor.java b/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/DevServicesElasticsearchProcessor.java index 4f2a90061ad70..14de2679ed56f 100644 --- a/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/DevServicesElasticsearchProcessor.java +++ b/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/DevServicesElasticsearchProcessor.java @@ -207,6 +207,8 @@ private DevServicesResultBuildItem.RunningDevService startElasticsearch( container.setPortBindings(List.of(config.port.get() + ":" + config.port.get())); } timeout.ifPresent(container::withStartupTimeout); + + container.withEnv(config.containerEnv); container.addEnv("ES_JAVA_OPTS", config.javaOpts); // Disable security as else we would need to configure it correctly to avoid tons of WARNING in the log container.addEnv("xpack.security.enabled", "false"); diff --git a/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/ElasticsearchDevServicesBuildTimeConfig.java b/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/ElasticsearchDevServicesBuildTimeConfig.java index fee7078a2b84f..b70c670201752 100644 --- a/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/ElasticsearchDevServicesBuildTimeConfig.java +++ b/extensions/elasticsearch-rest-client-common/deployment/src/main/java/io/quarkus/elasticsearch/restclient/common/deployment/ElasticsearchDevServicesBuildTimeConfig.java @@ -1,5 +1,6 @@ package io.quarkus.elasticsearch.restclient.common.deployment; +import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -67,6 +68,12 @@ public class ElasticsearchDevServicesBuildTimeConfig { @ConfigItem(defaultValue = "elasticsearch") public String serviceName; + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; + @Override public boolean equals(Object o) { if (this == o) @@ -79,11 +86,12 @@ public boolean equals(Object o) { && Objects.equals(port, that.port) && Objects.equals(imageName, that.imageName) && Objects.equals(javaOpts, that.javaOpts) - && Objects.equals(serviceName, that.serviceName); + && Objects.equals(serviceName, that.serviceName) + && Objects.equals(containerEnv, that.containerEnv); } @Override public int hashCode() { - return Objects.hash(enabled, port, imageName, javaOpts, shared, serviceName); + return Objects.hash(enabled, port, imageName, javaOpts, shared, serviceName, containerEnv); } } diff --git a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/devservices/InfinispanDevServiceProcessor.java b/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/devservices/InfinispanDevServiceProcessor.java index a332c47b39a4f..f5e94548cdf32 100644 --- a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/devservices/InfinispanDevServiceProcessor.java +++ b/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/devservices/InfinispanDevServiceProcessor.java @@ -210,6 +210,7 @@ private RunningDevService startContainer(String clientName, DockerStatusBuildIte launchMode, useSharedNetwork); timeout.ifPresent(infinispanContainer::withStartupTimeout); + infinispanContainer.withEnv(devServicesConfig.containerEnv); infinispanContainer.start(); return getRunningDevService(clientName, infinispanContainer.getContainerId(), infinispanContainer::close, diff --git a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanDevServicesConfig.java b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanDevServicesConfig.java index 7f6de3acd579f..1d1178e30c416 100644 --- a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanDevServicesConfig.java +++ b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanDevServicesConfig.java @@ -1,6 +1,7 @@ package io.quarkus.infinispan.client.runtime; import java.util.List; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.OptionalInt; @@ -110,6 +111,12 @@ public class InfinispanDevServicesConfig { @ConfigItem(name = "tracing.exporter.otlp.endpoint", defaultValue = "http://localhost:4317") public Optional exporterOtlpEndpoint; + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; + @Override public boolean equals(Object o) { if (this == o) @@ -122,12 +129,13 @@ public boolean equals(Object o) { Objects.equals(shared, that.shared) && Objects.equals(serviceName, that.serviceName) && Objects.equals(imageName, that.imageName) && - Objects.equals(artifacts, this.artifacts); + Objects.equals(artifacts, this.artifacts) && + Objects.equals(containerEnv, that.containerEnv); } @Override public int hashCode() { - return Objects.hash(enabled, port, shared, serviceName, imageName, artifacts); + return Objects.hash(enabled, port, shared, serviceName, imageName, artifacts, containerEnv); } @Override diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java index 88e167dc08b5d..e6d20a2e7e7df 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/DevServicesKafkaProcessor.java @@ -233,6 +233,7 @@ private RunningDevService startKafka(DockerStatusBuildItem dockerStatusBuildItem launchMode.getLaunchMode() == LaunchMode.DEVELOPMENT ? config.serviceName : null, useSharedNetwork, config.redpanda); timeout.ifPresent(redpanda::withStartupTimeout); + redpanda.withEnv(config.containerEnv); redpanda.start(); return new RunningDevService(Feature.KAFKA_CLIENT.getName(), @@ -252,6 +253,7 @@ private RunningDevService startKafka(DockerStatusBuildItem dockerStatusBuildItem strimzi.withPort(config.fixedExposedPort); } timeout.ifPresent(strimzi::withStartupTimeout); + strimzi.withEnv(config.containerEnv); strimzi.start(); return new RunningDevService(Feature.KAFKA_CLIENT.getName(), @@ -264,6 +266,7 @@ private RunningDevService startKafka(DockerStatusBuildItem dockerStatusBuildItem launchMode.getLaunchMode() == LaunchMode.DEVELOPMENT ? config.serviceName : null, useSharedNetwork); timeout.ifPresent(kafkaNative::withStartupTimeout); + kafkaNative.withEnv(config.containerEnv); kafkaNative.start(); return new RunningDevService(Feature.KAFKA_CLIENT.getName(), @@ -314,6 +317,7 @@ private static final class KafkaDevServiceCfg { private final String serviceName; private final Map topicPartitions; private final Duration topicPartitionsTimeout; + private final Map containerEnv; private final KafkaDevServicesBuildTimeConfig.Provider provider; @@ -328,6 +332,7 @@ public KafkaDevServiceCfg(KafkaDevServicesBuildTimeConfig config) { this.serviceName = config.serviceName; this.topicPartitions = config.topicPartitions; this.topicPartitionsTimeout = config.topicPartitionsTimeout; + this.containerEnv = config.containerEnv; this.redpanda = config.redpanda; } @@ -344,12 +349,13 @@ public boolean equals(Object o) { return devServicesEnabled == that.devServicesEnabled && Objects.equals(provider, that.provider) && Objects.equals(imageName, that.imageName) - && Objects.equals(fixedExposedPort, that.fixedExposedPort); + && Objects.equals(fixedExposedPort, that.fixedExposedPort) + && Objects.equals(containerEnv, that.containerEnv); } @Override public int hashCode() { - return Objects.hash(devServicesEnabled, provider, imageName, fixedExposedPort); + return Objects.hash(devServicesEnabled, provider, imageName, fixedExposedPort, containerEnv); } } diff --git a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java index 36fc407e05d26..5c909c99a674a 100644 --- a/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java +++ b/extensions/kafka-client/deployment/src/main/java/io/quarkus/kafka/client/deployment/KafkaDevServicesBuildTimeConfig.java @@ -116,6 +116,12 @@ public String getDefaultImageName() { @ConfigItem(defaultValue = "2S") public Duration topicPartitionsTimeout; + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; + /** * Allows configuring the Red Panda broker. */ diff --git a/extensions/kubernetes-client/deployment/src/main/java/io/quarkus/kubernetes/client/deployment/DevServicesKubernetesProcessor.java b/extensions/kubernetes-client/deployment/src/main/java/io/quarkus/kubernetes/client/deployment/DevServicesKubernetesProcessor.java index dfbebf109d2da..74b6b49b97f6c 100644 --- a/extensions/kubernetes-client/deployment/src/main/java/io/quarkus/kubernetes/client/deployment/DevServicesKubernetesProcessor.java +++ b/extensions/kubernetes-client/deployment/src/main/java/io/quarkus/kubernetes/client/deployment/DevServicesKubernetesProcessor.java @@ -159,6 +159,7 @@ private void shutdownCluster() { } } + @SuppressWarnings("unchecked") private RunningDevService startKubernetes(DockerStatusBuildItem dockerStatusBuildItem, KubernetesDevServiceCfg config, LaunchModeBuildItem launchMode, boolean useSharedNetwork, Optional timeout) { if (!config.devServicesEnabled) { @@ -226,6 +227,8 @@ private RunningDevService startKubernetes(DockerStatusBuildItem dockerStatusBuil } timeout.ifPresent(container::withStartupTimeout); + container.withEnv(config.containerEnv); + container.start(); KubeConfig kubeConfig = KubeConfigUtils.parseKubeConfig(container.getKubeconfig()); @@ -291,6 +294,7 @@ private static final class KubernetesDevServiceCfg { public boolean overrideKubeconfig; public boolean shared; public String serviceName; + public Map containerEnv; public KubernetesDevServiceCfg(KubernetesDevServicesBuildTimeConfig config) { this.devServicesEnabled = config.enabled; @@ -299,11 +303,12 @@ public KubernetesDevServiceCfg(KubernetesDevServicesBuildTimeConfig config) { this.overrideKubeconfig = config.overrideKubeconfig; this.flavor = config.flavor; this.shared = config.shared; + this.containerEnv = config.containerEnv; } @Override public int hashCode() { - return Objects.hash(devServicesEnabled, flavor, apiVersion, overrideKubeconfig, shared, serviceName); + return Objects.hash(devServicesEnabled, flavor, apiVersion, overrideKubeconfig, shared, serviceName, containerEnv); } @Override @@ -315,7 +320,8 @@ public boolean equals(Object obj) { KubernetesDevServiceCfg other = (KubernetesDevServiceCfg) obj; return devServicesEnabled == other.devServicesEnabled && flavor == other.flavor && Objects.equals(apiVersion, other.apiVersion) && overrideKubeconfig == other.overrideKubeconfig - && shared == other.shared && Objects.equals(serviceName, other.serviceName); + && shared == other.shared && Objects.equals(serviceName, other.serviceName) + && Objects.equals(containerEnv, other.containerEnv); } } diff --git a/extensions/kubernetes-client/runtime-internal/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesDevServicesBuildTimeConfig.java b/extensions/kubernetes-client/runtime-internal/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesDevServicesBuildTimeConfig.java index 3c194f1d269d9..815cfb7e40ace 100644 --- a/extensions/kubernetes-client/runtime-internal/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesDevServicesBuildTimeConfig.java +++ b/extensions/kubernetes-client/runtime-internal/src/main/java/io/quarkus/kubernetes/client/runtime/KubernetesDevServicesBuildTimeConfig.java @@ -1,5 +1,6 @@ package io.quarkus.kubernetes.client.runtime; +import java.util.Map; import java.util.Optional; import io.quarkus.runtime.annotations.ConfigGroup; @@ -66,6 +67,12 @@ public class KubernetesDevServicesBuildTimeConfig { @ConfigItem(defaultValue = "kubernetes") public String serviceName; + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; + public static enum Flavor { /** * kind (needs priviledge docker) diff --git a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesBuildTimeConfig.java b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesBuildTimeConfig.java index 58ad0874e11c4..e89851d26c981 100644 --- a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesBuildTimeConfig.java +++ b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesBuildTimeConfig.java @@ -39,4 +39,10 @@ public class DevServicesBuildTimeConfig { @ConfigItem public Map properties; + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; + } diff --git a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesMongoProcessor.java b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesMongoProcessor.java index b751aa3a96c7f..20fae0ff4aef7 100644 --- a/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesMongoProcessor.java +++ b/extensions/mongodb-client/deployment/src/main/java/io/quarkus/mongodb/deployment/DevServicesMongoProcessor.java @@ -168,6 +168,7 @@ private RunningDevService startMongo(DockerStatusBuildItem dockerStatusBuildItem mongoDBContainer = new QuarkusMongoDBContainer(capturedProperties.fixedExposedPort, useSharedNetwork); } timeout.ifPresent(mongoDBContainer::withStartupTimeout); + mongoDBContainer.withEnv(capturedProperties.containerEnv); mongoDBContainer.start(); Optional databaseName = ConfigProvider.getConfig().getOptionalValue(configPrefix + "database", String.class); String effectiveURL = databaseName.map(mongoDBContainer::getReplicaSetUrl).orElse(mongoDBContainer.getReplicaSetUrl()); @@ -209,7 +210,7 @@ private CapturedProperties captureProperties(String connectionName, MongoClientB boolean devServicesEnabled = devServicesConfig.enabled.orElse(true); return new CapturedProperties(databaseName, connectionString, devServicesEnabled, devServicesConfig.imageName.orElseGet(() -> ConfigureUtil.getDefaultImageNameFor("mongo")), - devServicesConfig.port.orElse(null), devServicesConfig.properties); + devServicesConfig.port.orElse(null), devServicesConfig.properties, devServicesConfig.containerEnv); } private static final class CapturedProperties { @@ -219,15 +220,17 @@ private static final class CapturedProperties { private final String imageName; private final Integer fixedExposedPort; private final Map connectionProperties; + private final Map containerEnv; public CapturedProperties(String database, String connectionString, boolean devServicesEnabled, String imageName, - Integer fixedExposedPort, Map connectionProperties) { + Integer fixedExposedPort, Map connectionProperties, Map containerEnv) { this.database = database; this.connectionString = connectionString; this.devServicesEnabled = devServicesEnabled; this.imageName = imageName; this.fixedExposedPort = fixedExposedPort; this.connectionProperties = connectionProperties; + this.containerEnv = containerEnv; } @Override @@ -240,13 +243,14 @@ public boolean equals(Object o) { return devServicesEnabled == that.devServicesEnabled && Objects.equals(database, that.database) && Objects.equals(connectionString, that.connectionString) && Objects.equals(imageName, that.imageName) && Objects.equals(fixedExposedPort, that.fixedExposedPort) - && Objects.equals(connectionProperties, that.connectionProperties); + && Objects.equals(connectionProperties, that.connectionProperties) + && Objects.equals(containerEnv, that.containerEnv); } @Override public int hashCode() { return Objects.hash(database, connectionString, devServicesEnabled, imageName, fixedExposedPort, - connectionProperties); + connectionProperties, containerEnv); } } diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/DevServicesConfig.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/DevServicesConfig.java index aa7176fc3b4e2..02b6e63752e16 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/DevServicesConfig.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/DevServicesConfig.java @@ -200,6 +200,12 @@ public String getGrantType() { @ConfigItem public OptionalInt port; + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; + @Override public boolean equals(Object o) { if (this == o) @@ -216,11 +222,12 @@ public boolean equals(Object o) { && Objects.equals(realmName, that.realmName) && Objects.equals(users, that.users) && Objects.equals(javaOpts, that.javaOpts) - && Objects.equals(roles, that.roles); + && Objects.equals(roles, that.roles) + && Objects.equals(containerEnv, that.containerEnv); } @Override public int hashCode() { - return Objects.hash(enabled, imageName, port, realmPath, realmName, users, roles); + return Objects.hash(enabled, imageName, port, realmPath, realmName, users, roles, containerEnv); } } diff --git a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java index 907211c4a4162..fdcbd8d3ce577 100644 --- a/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java +++ b/extensions/oidc/deployment/src/main/java/io/quarkus/oidc/deployment/devservices/keycloak/KeycloakDevServicesProcessor.java @@ -369,6 +369,7 @@ private RunningDevService startContainer(DockerStatusBuildItem dockerStatusBuild errors); timeout.ifPresent(oidcContainer::withStartupTimeout); + oidcContainer.withEnv(capturedDevServicesConfiguration.containerEnv); oidcContainer.start(); String internalUrl = startURL(oidcContainer.getHost(), oidcContainer.getPort(), oidcContainer.keycloakX); diff --git a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/DevServicesConfig.java b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/DevServicesConfig.java index 53764787caf1f..f0e3c6035745f 100644 --- a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/DevServicesConfig.java +++ b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/DevServicesConfig.java @@ -1,5 +1,6 @@ package io.quarkus.redis.client.deployment; +import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.OptionalInt; @@ -63,6 +64,12 @@ public class DevServicesConfig { @ConfigItem(defaultValue = "redis") public String serviceName; + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; + @Override public boolean equals(Object o) { if (this == o) @@ -74,11 +81,12 @@ public boolean equals(Object o) { Objects.equals(imageName, that.imageName) && Objects.equals(port, that.port) && Objects.equals(shared, that.shared) && - Objects.equals(serviceName, that.serviceName); + Objects.equals(serviceName, that.serviceName) && + Objects.equals(containerEnv, that.containerEnv); } @Override public int hashCode() { - return Objects.hash(enabled, imageName, port, shared, serviceName); + return Objects.hash(enabled, imageName, port, shared, serviceName, containerEnv); } } diff --git a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/DevServicesRedisProcessor.java b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/DevServicesRedisProcessor.java index f189bacacbeac..4a0eccdb84e39 100644 --- a/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/DevServicesRedisProcessor.java +++ b/extensions/redis-client/deployment/src/main/java/io/quarkus/redis/client/deployment/DevServicesRedisProcessor.java @@ -178,6 +178,7 @@ private RunningDevService startContainer(DockerStatusBuildItem dockerStatusBuild QuarkusPortRedisContainer redisContainer = new QuarkusPortRedisContainer(dockerImageName, devServicesConfig.port, launchMode == DEVELOPMENT ? devServicesConfig.serviceName : null, useSharedNetwork); timeout.ifPresent(redisContainer::withStartupTimeout); + redisContainer.withEnv(devServicesConfig.containerEnv); redisContainer.start(); String redisHost = REDIS_SCHEME + redisContainer.getHost() + ":" + redisContainer.getPort(); return new RunningDevService(Feature.REDIS_CLIENT.getName(), redisContainer.getContainerId(), diff --git a/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/ApicurioRegistryDevServicesBuildTimeConfig.java b/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/ApicurioRegistryDevServicesBuildTimeConfig.java index 6c627cd77d610..c11a2aa85fbc6 100644 --- a/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/ApicurioRegistryDevServicesBuildTimeConfig.java +++ b/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/ApicurioRegistryDevServicesBuildTimeConfig.java @@ -1,5 +1,6 @@ package io.quarkus.apicurio.registry.devservice; +import java.util.Map; import java.util.Optional; import io.quarkus.runtime.annotations.ConfigItem; @@ -61,4 +62,10 @@ public class ApicurioRegistryDevServicesBuildTimeConfig { @ConfigItem(defaultValue = "apicurio-registry") public String serviceName; + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; + } diff --git a/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/DevServicesApicurioRegistryProcessor.java b/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/DevServicesApicurioRegistryProcessor.java index 7698a26f35537..0ca85d928ad65 100644 --- a/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/DevServicesApicurioRegistryProcessor.java +++ b/extensions/schema-registry/devservice/deployment/src/main/java/io/quarkus/apicurio/registry/devservice/DevServicesApicurioRegistryProcessor.java @@ -178,6 +178,7 @@ private RunningDevService startApicurioRegistry(DockerStatusBuildItem dockerStat launchMode.getLaunchMode() == LaunchMode.DEVELOPMENT ? config.serviceName : null, useSharedNetwork); timeout.ifPresent(container::withStartupTimeout); + container.withEnv(config.containerEnv); container.start(); return new RunningDevService(Feature.APICURIO_REGISTRY_AVRO.getName(), container.getContainerId(), @@ -215,6 +216,7 @@ private static final class ApicurioRegistryDevServiceCfg { private final Integer fixedExposedPort; private final boolean shared; private final String serviceName; + private final Map containerEnv; public ApicurioRegistryDevServiceCfg(ApicurioRegistryDevServicesBuildTimeConfig config) { this.devServicesEnabled = config.enabled.orElse(true); @@ -222,6 +224,7 @@ public ApicurioRegistryDevServiceCfg(ApicurioRegistryDevServicesBuildTimeConfig this.fixedExposedPort = config.port.orElse(0); this.shared = config.shared; this.serviceName = config.serviceName; + this.containerEnv = config.containerEnv; } @Override @@ -237,12 +240,13 @@ public boolean equals(Object o) { && Objects.equals(imageName, that.imageName) && Objects.equals(fixedExposedPort, that.fixedExposedPort) && shared == that.shared - && Objects.equals(serviceName, that.serviceName); + && Objects.equals(serviceName, that.serviceName) + && Objects.equals(containerEnv, that.containerEnv); } @Override public int hashCode() { - return Objects.hash(devServicesEnabled, imageName, fixedExposedPort, shared, serviceName); + return Objects.hash(devServicesEnabled, imageName, fixedExposedPort, shared, serviceName, containerEnv); } } diff --git a/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesBuildTimeConfig.java b/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesBuildTimeConfig.java index 2d92bb80cd1c0..6ee5be972032b 100644 --- a/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesBuildTimeConfig.java +++ b/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesBuildTimeConfig.java @@ -1,5 +1,6 @@ package io.quarkus.smallrye.reactivemessaging.amqp.deployment; +import java.util.Map; import java.util.Optional; import io.quarkus.runtime.annotations.ConfigGroup; @@ -70,4 +71,10 @@ public class AmqpDevServicesBuildTimeConfig { @ConfigItem(defaultValue = "amqp") public String serviceName; + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; + } diff --git a/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesProcessor.java b/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesProcessor.java index 60b6638382767..241f47ea62959 100644 --- a/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesProcessor.java +++ b/extensions/smallrye-reactive-messaging-amqp/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/amqp/deployment/AmqpDevServicesProcessor.java @@ -188,6 +188,7 @@ private RunningDevService startAmqpBroker(DockerStatusBuildItem dockerStatusBuil useSharedNetwork); timeout.ifPresent(container::withStartupTimeout); + container.withEnv(config.containerEnv); container.start(); return getRunningService(container.getContainerId(), container::close, container.getEffectiveHost(), @@ -245,6 +246,7 @@ private static final class AmqpDevServiceCfg { private final String extra; private final boolean shared; private final String serviceName; + private final Map containerEnv; public AmqpDevServiceCfg(AmqpDevServicesBuildTimeConfig devServicesConfig) { this.devServicesEnabled = devServicesConfig.enabled.orElse(true); @@ -253,7 +255,7 @@ public AmqpDevServiceCfg(AmqpDevServicesBuildTimeConfig devServicesConfig) { this.extra = devServicesConfig.extraArgs; this.shared = devServicesConfig.shared; this.serviceName = devServicesConfig.serviceName; - ; + this.containerEnv = devServicesConfig.containerEnv; } @Override @@ -266,12 +268,13 @@ public boolean equals(Object o) { } AmqpDevServiceCfg that = (AmqpDevServiceCfg) o; return devServicesEnabled == that.devServicesEnabled && Objects.equals(imageName, that.imageName) - && Objects.equals(fixedExposedPort, that.fixedExposedPort); + && Objects.equals(fixedExposedPort, that.fixedExposedPort) + && Objects.equals(containerEnv, that.containerEnv); } @Override public int hashCode() { - return Objects.hash(devServicesEnabled, imageName, fixedExposedPort); + return Objects.hash(devServicesEnabled, imageName, fixedExposedPort, containerEnv); } } diff --git a/extensions/smallrye-reactive-messaging-mqtt/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/mqtt/deployment/MqttDevServicesBuildTimeConfig.java b/extensions/smallrye-reactive-messaging-mqtt/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/mqtt/deployment/MqttDevServicesBuildTimeConfig.java index 0bdb3d3ca482a..c657e38421663 100644 --- a/extensions/smallrye-reactive-messaging-mqtt/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/mqtt/deployment/MqttDevServicesBuildTimeConfig.java +++ b/extensions/smallrye-reactive-messaging-mqtt/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/mqtt/deployment/MqttDevServicesBuildTimeConfig.java @@ -1,5 +1,6 @@ package io.quarkus.smallrye.reactivemessaging.mqtt.deployment; +import java.util.Map; import java.util.Optional; import java.util.OptionalInt; @@ -60,4 +61,10 @@ public class MqttDevServicesBuildTimeConfig { */ @ConfigItem(defaultValue = "mqtt") public String serviceName; + + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; } diff --git a/extensions/smallrye-reactive-messaging-mqtt/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/mqtt/deployment/MqttDevServicesProcessor.java b/extensions/smallrye-reactive-messaging-mqtt/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/mqtt/deployment/MqttDevServicesProcessor.java index 22772a680a70a..de0e0d9084fdf 100644 --- a/extensions/smallrye-reactive-messaging-mqtt/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/mqtt/deployment/MqttDevServicesProcessor.java +++ b/extensions/smallrye-reactive-messaging-mqtt/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/mqtt/deployment/MqttDevServicesProcessor.java @@ -163,6 +163,7 @@ private RunningDevService startMqttBroker(DockerStatusBuildItem dockerStatusBuil // Starting the broker timeout.ifPresent(container::withStartupTimeout); + container.withEnv(config.containerEnv); container.start(); return getRunningDevService( container.getContainerId(), @@ -230,6 +231,7 @@ private static final class MqttDevServiceCfg { private final Integer fixedExposedPort; private final boolean shared; private final String serviceName; + private final Map containerEnv; public MqttDevServiceCfg(MqttDevServicesBuildTimeConfig devServicesConfig) { this.devServicesEnabled = devServicesConfig.enabled.orElse(true); @@ -237,6 +239,7 @@ public MqttDevServiceCfg(MqttDevServicesBuildTimeConfig devServicesConfig) { this.fixedExposedPort = devServicesConfig.port.orElse(0); this.shared = devServicesConfig.shared; this.serviceName = devServicesConfig.serviceName; + this.containerEnv = devServicesConfig.containerEnv; } @Override @@ -249,12 +252,13 @@ public boolean equals(Object o) { } MqttDevServiceCfg that = (MqttDevServiceCfg) o; return devServicesEnabled == that.devServicesEnabled && Objects.equals(imageName, that.imageName) - && Objects.equals(fixedExposedPort, that.fixedExposedPort); + && Objects.equals(fixedExposedPort, that.fixedExposedPort) + && Objects.equals(containerEnv, that.containerEnv); } @Override public int hashCode() { - return Objects.hash(devServicesEnabled, imageName, fixedExposedPort); + return Objects.hash(devServicesEnabled, imageName, fixedExposedPort, containerEnv); } } diff --git a/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesBuildTimeConfig.java b/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesBuildTimeConfig.java index ff4617cdd6d8a..7533172d5d174 100644 --- a/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesBuildTimeConfig.java +++ b/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesBuildTimeConfig.java @@ -172,4 +172,10 @@ public static class Binding { */ @ConfigItem public Map bindings; + + /** + * Environment variables that are passed to the container. + */ + @ConfigItem + public Map containerEnv; } diff --git a/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesProcessor.java b/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesProcessor.java index 39d102ff57582..2ab5dc2afb125 100644 --- a/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesProcessor.java +++ b/extensions/smallrye-reactive-messaging-rabbitmq/deployment/src/main/java/io/quarkus/smallrye/reactivemessaging/rabbitmq/deployment/RabbitMQDevServicesProcessor.java @@ -190,6 +190,7 @@ private RunningDevService startRabbitMQBroker(DockerStatusBuildItem dockerStatus // Starting the broker timeout.ifPresent(container::withStartupTimeout); + container.withEnv(config.containerEnv); container.start(); return getRunningDevService(container.getContainerId(), container::close, container.getHost(), container.getPort(), container.getHttpPort(), container.getAdminUsername(), container.getAdminPassword()); @@ -320,6 +321,7 @@ static class Binding { private final List exchanges; private final List queues; private final List bindings; + private final Map containerEnv; public RabbitMQDevServiceCfg(RabbitMQDevServicesBuildTimeConfig devServicesConfig) { this.devServicesEnabled = devServicesConfig.enabled.orElse(true); @@ -337,6 +339,7 @@ public RabbitMQDevServiceCfg(RabbitMQDevServicesBuildTimeConfig devServicesConfi this.bindings = devServicesConfig.bindings != null ? devServicesConfig.bindings.entrySet().stream().map(Binding::new).collect(Collectors.toList()) : Collections.emptyList(); + this.containerEnv = devServicesConfig.containerEnv; } @Override @@ -349,12 +352,13 @@ public boolean equals(Object o) { } RabbitMQDevServiceCfg that = (RabbitMQDevServiceCfg) o; return devServicesEnabled == that.devServicesEnabled && Objects.equals(imageName, that.imageName) - && Objects.equals(fixedExposedPort, that.fixedExposedPort); + && Objects.equals(fixedExposedPort, that.fixedExposedPort) + && Objects.equals(containerEnv, that.containerEnv); } @Override public int hashCode() { - return Objects.hash(devServicesEnabled, imageName, fixedExposedPort); + return Objects.hash(devServicesEnabled, imageName, fixedExposedPort, containerEnv); } } From 58c3748f58fab173649df5a685c6b84ebfc06740 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 22 Jun 2023 10:53:52 +0200 Subject: [PATCH 2/2] Use lowercase sa for SQL Server username Otherwise the selected collation might cause issues. --- .../mssql/deployment/MSSQLDevServicesProcessor.java | 7 ++++++- .../deployment/DevServicesMsSQLDatasourceTestCase.java | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java b/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java index 7f32c0dd79b8d..9cc82062f702b 100644 --- a/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java +++ b/extensions/devservices/mssql/src/main/java/io/quarkus/devservices/mssql/deployment/MSSQLDevServicesProcessor.java @@ -27,6 +27,11 @@ public class MSSQLDevServicesProcessor { private static final Logger LOG = Logger.getLogger(MSSQLDevServicesProcessor.class); + /** + * Using SA doesn't work with all collations so let's use the lowercase version instead. + */ + private static final String DEFAULT_USERNAME = "sa"; + @BuildStep DevServicesDatasourceProviderBuildItem setupMSSQL( List devServicesSharedNetworkBuildItem) { @@ -63,7 +68,7 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt return new RunningDevServicesDatasource(container.getContainerId(), container.getEffectiveJdbcUrl(), container.getReactiveUrl(), - container.getUsername(), + DEFAULT_USERNAME, container.getPassword(), new ContainerShutdownCloseable(container, "Microsoft SQL Server")); } diff --git a/extensions/jdbc/jdbc-mssql/deployment/src/test/java/io/quarkus/jdbc/mssql/deployment/DevServicesMsSQLDatasourceTestCase.java b/extensions/jdbc/jdbc-mssql/deployment/src/test/java/io/quarkus/jdbc/mssql/deployment/DevServicesMsSQLDatasourceTestCase.java index 397da3a1e828a..d580858a70909 100644 --- a/extensions/jdbc/jdbc-mssql/deployment/src/test/java/io/quarkus/jdbc/mssql/deployment/DevServicesMsSQLDatasourceTestCase.java +++ b/extensions/jdbc/jdbc-mssql/deployment/src/test/java/io/quarkus/jdbc/mssql/deployment/DevServicesMsSQLDatasourceTestCase.java @@ -41,7 +41,7 @@ public class DevServicesMsSQLDatasourceTestCase { public void testDatasource() throws Exception { AgroalConnectionPoolConfiguration configuration = dataSource.getConfiguration().connectionPoolConfiguration(); assertTrue(configuration.connectionFactoryConfiguration().jdbcUrl().contains("jdbc:sqlserver:")); - assertEquals("SA", configuration.connectionFactoryConfiguration().principal().getName()); + assertEquals("sa", configuration.connectionFactoryConfiguration().principal().getName()); assertEquals(20, configuration.maxSize()); assertThat(configuration.exceptionSorter()).isInstanceOf(MSSQLExceptionSorter.class);