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 new file mode 100644 index 0000000000000..7061c743b3bca --- /dev/null +++ b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceContainerConfig.java @@ -0,0 +1,39 @@ +package io.quarkus.datasource.deployment.spi; + +import java.util.Map; +import java.util.Optional; +import java.util.OptionalInt; + +public class DevServicesDatasourceContainerConfig { + + private final Optional imageName; + private final Map containerProperties; + private final Map additionalJdbcUrlProperties; + private final OptionalInt fixedExposedPort; + + public DevServicesDatasourceContainerConfig(Optional imageName, + Map containerProperties, + Map additionalJdbcUrlProperties, + OptionalInt port) { + this.imageName = imageName; + this.containerProperties = containerProperties; + this.additionalJdbcUrlProperties = additionalJdbcUrlProperties; + this.fixedExposedPort = port; + } + + public Optional getImageName() { + return imageName; + } + + public Map getContainerProperties() { + return containerProperties; + } + + public Map getAdditionalJdbcUrlProperties() { + return additionalJdbcUrlProperties; + } + + public OptionalInt getFixedExposedPort() { + return fixedExposedPort; + } +} diff --git a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java index 25bd51c5571ed..05e3dffee7b60 100644 --- a/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java +++ b/extensions/datasource/deployment-spi/src/main/java/io/quarkus/datasource/deployment/spi/DevServicesDatasourceProvider.java @@ -2,9 +2,7 @@ import java.io.Closeable; import java.time.Duration; -import java.util.Map; import java.util.Optional; -import java.util.OptionalInt; import io.quarkus.runtime.LaunchMode; @@ -12,10 +10,9 @@ public interface DevServicesDatasourceProvider { RunningDevServicesDatasource startDatabase(Optional username, Optional password, Optional datasourceName, - Optional imageName, - Map containerProperties, - Map additionalJdbcUrlProperties, - OptionalInt port, LaunchMode launchMode, Optional startupTimeout); + DevServicesDatasourceContainerConfig devServicesDatasourceContainerConfig, + LaunchMode launchMode, + Optional startupTimeout); default boolean isDockerRequired() { return true; 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 db479d3c02995..73d68e608977a 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 @@ -15,6 +15,7 @@ import io.quarkus.datasource.deployment.spi.DefaultDataSourceDbKindBuildItem; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceConfigurationHandlerBuildItem; +import io.quarkus.datasource.deployment.spi.DevServicesDatasourceContainerConfig; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceResultBuildItem; @@ -261,13 +262,17 @@ private RunningDevService startDevDb(String dbName, prefix = prefix + dbName + "."; } + DevServicesDatasourceContainerConfig containerConfig = new DevServicesDatasourceContainerConfig( + dataSourceBuildTimeConfig.devservices.imageName, + dataSourceBuildTimeConfig.devservices.containerProperties, + dataSourceBuildTimeConfig.devservices.properties, + dataSourceBuildTimeConfig.devservices.port); + DevServicesDatasourceProvider.RunningDevServicesDatasource datasource = devDbProvider .startDatabase(ConfigProvider.getConfig().getOptionalValue(prefix + "username", String.class), ConfigProvider.getConfig().getOptionalValue(prefix + "password", String.class), - Optional.ofNullable(dbName), dataSourceBuildTimeConfig.devservices.imageName, - dataSourceBuildTimeConfig.devservices.containerProperties, - dataSourceBuildTimeConfig.devservices.properties, - dataSourceBuildTimeConfig.devservices.port, launchMode, globalDevServicesConfig.timeout); + Optional.ofNullable(dbName), containerConfig, + launchMode, globalDevServicesConfig.timeout); propertiesMap.put(prefix + "db-kind", dataSourceBuildTimeConfig.dbKind.orElse(null)); String devServicesPrefix = prefix + "devservices."; 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 6cb6b90aa0704..8db17dc91d14c 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 @@ -2,7 +2,6 @@ import java.time.Duration; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.OptionalInt; @@ -11,6 +10,7 @@ import org.testcontainers.utility.DockerImageName; import io.quarkus.datasource.common.runtime.DatabaseKind; +import io.quarkus.datasource.deployment.spi.DevServicesDatasourceContainerConfig; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; import io.quarkus.deployment.annotations.BuildStep; @@ -29,17 +29,17 @@ DevServicesDatasourceProviderBuildItem setupDB2( return new DevServicesDatasourceProviderBuildItem(DatabaseKind.DB2, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, - Optional datasourceName, Optional imageName, - Map containerProperties, Map additionalJdbcUrlProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { - QuarkusDb2Container container = new QuarkusDb2Container(imageName, fixedExposedPort, + Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, + LaunchMode launchMode, Optional startupTimeout) { + QuarkusDb2Container container = new QuarkusDb2Container(containerConfig.getImageName(), + containerConfig.getFixedExposedPort(), !devServicesSharedNetworkBuildItem.isEmpty()); startupTimeout.ifPresent(container::withStartupTimeout); container.withPassword(password.orElse("quarkus")) .withUsername(username.orElse("quarkus")) .withDatabaseName(datasourceName.orElse("default")) .withReuse(true); - additionalJdbcUrlProperties.forEach(container::withUrlParam); + containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam); container.start(); LOG.info("Dev Services for IBM Db2 started."); diff --git a/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java b/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java index 4a2389fe066cf..0b75127ef0792 100644 --- a/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java +++ b/extensions/devservices/derby/src/main/java/io/quarkus/devservices/derby/deployment/DerbyDevServicesProcessor.java @@ -7,12 +7,12 @@ import java.time.Duration; import java.util.Map; import java.util.Optional; -import java.util.OptionalInt; import org.apache.derby.drda.NetworkServerControl; import org.jboss.logging.Logger; import io.quarkus.datasource.common.runtime.DatabaseKind; +import io.quarkus.datasource.deployment.spi.DevServicesDatasourceContainerConfig; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; import io.quarkus.deployment.annotations.BuildStep; @@ -30,11 +30,11 @@ DevServicesDatasourceProviderBuildItem setupDerby() { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.DERBY, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, - Optional datasourceName, Optional imageName, - Map containerProperties, Map additionalJdbcUrlProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { + Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, + LaunchMode launchMode, Optional startupTimeout) { try { - int port = fixedExposedPort.isPresent() ? fixedExposedPort.getAsInt() + int port = containerConfig.getFixedExposedPort().isPresent() + ? containerConfig.getFixedExposedPort().getAsInt() : 1527 + (launchMode == LaunchMode.TEST ? 0 : 1); NetworkServerControl server = new NetworkServerControl(InetAddress.getByName("localhost"), port); server.start(new PrintWriter(System.out)); @@ -58,7 +58,7 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt LOG.info("Dev Services for Derby started."); StringBuilder additionalArgs = new StringBuilder(); - for (Map.Entry i : additionalJdbcUrlProperties.entrySet()) { + for (Map.Entry i : containerConfig.getAdditionalJdbcUrlProperties().entrySet()) { additionalArgs.append(";"); additionalArgs.append(i.getKey()); additionalArgs.append("="); diff --git a/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java b/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java index 9b4fb7a7200aa..9c046786e658b 100644 --- a/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java +++ b/extensions/devservices/h2/src/main/java/io/quarkus/devservices/h2/deployment/H2DevServicesProcessor.java @@ -9,12 +9,12 @@ import java.time.Duration; import java.util.Map; import java.util.Optional; -import java.util.OptionalInt; import org.h2.tools.Server; import org.jboss.logging.Logger; import io.quarkus.datasource.common.runtime.DatabaseKind; +import io.quarkus.datasource.deployment.spi.DevServicesDatasourceContainerConfig; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; import io.quarkus.deployment.annotations.BuildStep; @@ -29,17 +29,18 @@ DevServicesDatasourceProviderBuildItem setupH2() { return new DevServicesDatasourceProviderBuildItem(DatabaseKind.H2, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, - Optional datasourceName, Optional imageName, - Map containerProperties, Map additionalJdbcUrlProperties, - OptionalInt port, LaunchMode launchMode, Optional startupTimeout) { + Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, + LaunchMode launchMode, Optional startupTimeout) { try { final Server tcpServer = Server.createTcpServer("-tcpPort", - port.isPresent() ? String.valueOf(port.getAsInt()) : "0", + containerConfig.getFixedExposedPort().isPresent() + ? String.valueOf(containerConfig.getFixedExposedPort().getAsInt()) + : "0", "-ifNotExists"); tcpServer.start(); StringBuilder additionalArgs = new StringBuilder(); - for (Map.Entry i : additionalJdbcUrlProperties.entrySet()) { + for (Map.Entry i : containerConfig.getAdditionalJdbcUrlProperties().entrySet()) { additionalArgs.append(";"); additionalArgs.append(i.getKey()); additionalArgs.append("="); 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 4a6d44eed1987..4395801bbd20a 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 @@ -2,7 +2,6 @@ import java.time.Duration; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.OptionalInt; @@ -11,6 +10,7 @@ import org.testcontainers.utility.DockerImageName; import io.quarkus.datasource.common.runtime.DatabaseKind; +import io.quarkus.datasource.deployment.spi.DevServicesDatasourceContainerConfig; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; import io.quarkus.deployment.annotations.BuildStep; @@ -32,10 +32,10 @@ DevServicesDatasourceProviderBuildItem setupMariaDB( return new DevServicesDatasourceProviderBuildItem(DatabaseKind.MARIADB, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, - Optional datasourceName, Optional imageName, - Map containerProperties, Map additionalJdbcUrlProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { - QuarkusMariaDBContainer container = new QuarkusMariaDBContainer(imageName, fixedExposedPort, + Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, + LaunchMode launchMode, Optional startupTimeout) { + QuarkusMariaDBContainer container = new QuarkusMariaDBContainer(containerConfig.getImageName(), + containerConfig.getFixedExposedPort(), !devServicesSharedNetworkBuildItem.isEmpty()); startupTimeout.ifPresent(container::withStartupTimeout); container.withPassword(password.orElse("quarkus")) @@ -43,11 +43,12 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt .withDatabaseName(datasourceName.orElse("default")) .withReuse(true); - if (containerProperties.containsKey(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)) { - container.withConfigurationOverride(containerProperties.get(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)); + if (containerConfig.getContainerProperties().containsKey(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)) { + container.withConfigurationOverride( + containerConfig.getContainerProperties().get(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)); } - additionalJdbcUrlProperties.forEach(container::withUrlParam); + containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam); container.start(); LOG.info("Dev Services for MariaDB started."); 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 b55693b5f618d..c8cb95a58bac8 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 @@ -2,7 +2,6 @@ import java.time.Duration; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.OptionalInt; @@ -11,6 +10,7 @@ import org.testcontainers.utility.DockerImageName; import io.quarkus.datasource.common.runtime.DatabaseKind; +import io.quarkus.datasource.deployment.spi.DevServicesDatasourceContainerConfig; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; import io.quarkus.deployment.annotations.BuildStep; @@ -29,15 +29,15 @@ DevServicesDatasourceProviderBuildItem setupMSSQL( return new DevServicesDatasourceProviderBuildItem(DatabaseKind.MSSQL, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, - Optional datasourceName, Optional imageName, - Map containerProperties, Map additionalJdbcUrlProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { - QuarkusMSSQLServerContainer container = new QuarkusMSSQLServerContainer(imageName, fixedExposedPort, + Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, + LaunchMode launchMode, Optional startupTimeout) { + QuarkusMSSQLServerContainer container = new QuarkusMSSQLServerContainer(containerConfig.getImageName(), + containerConfig.getFixedExposedPort(), !devServicesSharedNetworkBuildItem.isEmpty()); startupTimeout.ifPresent(container::withStartupTimeout); container.withPassword(password.orElse("Quarkuspassword1")) .withReuse(true); - additionalJdbcUrlProperties.forEach(container::withUrlParam); + containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam); container.start(); LOG.info("Dev Services for Microsoft SQL Server started."); 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 23f29ccef7cc7..ffc0277dee99e 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 @@ -2,7 +2,6 @@ import java.time.Duration; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.OptionalInt; @@ -11,6 +10,7 @@ import org.testcontainers.utility.DockerImageName; import io.quarkus.datasource.common.runtime.DatabaseKind; +import io.quarkus.datasource.deployment.spi.DevServicesDatasourceContainerConfig; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; import io.quarkus.deployment.annotations.BuildStep; @@ -31,10 +31,10 @@ DevServicesDatasourceProviderBuildItem setupMysql( return new DevServicesDatasourceProviderBuildItem(DatabaseKind.MYSQL, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, - Optional datasourceName, Optional imageName, - Map containerProperties, Map additionalJdbcUrlProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { - QuarkusMySQLContainer container = new QuarkusMySQLContainer(imageName, fixedExposedPort, + Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, + LaunchMode launchMode, Optional startupTimeout) { + QuarkusMySQLContainer container = new QuarkusMySQLContainer(containerConfig.getImageName(), + containerConfig.getFixedExposedPort(), !devServicesSharedNetworkBuildItem.isEmpty()); startupTimeout.ifPresent(container::withStartupTimeout); container.withPassword(password.orElse("quarkus")) @@ -42,11 +42,12 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt .withDatabaseName(datasourceName.orElse("default")) .withReuse(true); - if (containerProperties.containsKey(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)) { - container.withConfigurationOverride(containerProperties.get(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)); + if (containerConfig.getContainerProperties().containsKey(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)) { + container.withConfigurationOverride( + containerConfig.getContainerProperties().get(MY_CNF_CONFIG_OVERRIDE_PARAM_NAME)); } - additionalJdbcUrlProperties.forEach(container::withUrlParam); + containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam); container.start(); 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 bb9ca8ae8571d..e900eaf3a2b78 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 @@ -2,7 +2,6 @@ import java.time.Duration; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.OptionalInt; @@ -11,6 +10,7 @@ import org.testcontainers.utility.DockerImageName; import io.quarkus.datasource.common.runtime.DatabaseKind; +import io.quarkus.datasource.deployment.spi.DevServicesDatasourceContainerConfig; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; import io.quarkus.deployment.annotations.BuildStep; @@ -35,10 +35,10 @@ DevServicesDatasourceProviderBuildItem setupOracle( return new DevServicesDatasourceProviderBuildItem(DatabaseKind.ORACLE, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, - Optional datasourceName, Optional imageName, - Map containerProperties, Map additionalJdbcUrlProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { - QuarkusOracleServerContainer container = new QuarkusOracleServerContainer(imageName, fixedExposedPort, + Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, + LaunchMode launchMode, Optional startupTimeout) { + QuarkusOracleServerContainer container = new QuarkusOracleServerContainer(containerConfig.getImageName(), + containerConfig.getFixedExposedPort(), !devServicesSharedNetworkBuildItem.isEmpty()); startupTimeout.ifPresent(container::withStartupTimeout); container.withUsername(username.orElse(DEFAULT_DATABASE_USER)) @@ -53,7 +53,7 @@ public RunningDevServicesDatasource startDatabase(Optional username, Opt // and keeps things simple. container.withCreateContainerCmdModifier(cmd -> cmd.getHostConfig().withNanoCPUs(2_000_000_000l)); - additionalJdbcUrlProperties.forEach(container::withUrlParam); + containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam); container.start(); LOG.info("Dev Services for Oracle started."); 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 7eee0c6b74ef0..f57156575e4a7 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 @@ -2,7 +2,6 @@ import java.time.Duration; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.OptionalInt; @@ -11,6 +10,7 @@ import org.testcontainers.utility.DockerImageName; import io.quarkus.datasource.common.runtime.DatabaseKind; +import io.quarkus.datasource.deployment.spi.DevServicesDatasourceContainerConfig; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProvider; import io.quarkus.datasource.deployment.spi.DevServicesDatasourceProviderBuildItem; import io.quarkus.deployment.annotations.BuildStep; @@ -36,17 +36,17 @@ DevServicesDatasourceProviderBuildItem setupPostgres( return new DevServicesDatasourceProviderBuildItem(DatabaseKind.POSTGRESQL, new DevServicesDatasourceProvider() { @Override public RunningDevServicesDatasource startDatabase(Optional username, Optional password, - Optional datasourceName, Optional imageName, - Map containerProperties, Map additionalJdbcUrlProperties, - OptionalInt fixedExposedPort, LaunchMode launchMode, Optional startupTimeout) { - QuarkusPostgreSQLContainer container = new QuarkusPostgreSQLContainer(imageName, fixedExposedPort, + Optional datasourceName, DevServicesDatasourceContainerConfig containerConfig, + LaunchMode launchMode, Optional startupTimeout) { + QuarkusPostgreSQLContainer container = new QuarkusPostgreSQLContainer(containerConfig.getImageName(), + containerConfig.getFixedExposedPort(), !devServicesSharedNetworkBuildItem.isEmpty()); startupTimeout.ifPresent(container::withStartupTimeout); container.withPassword(password.orElse("quarkus")) .withUsername(username.orElse("quarkus")) .withDatabaseName(datasourceName.orElse("default")) .withReuse(true); - additionalJdbcUrlProperties.forEach(container::withUrlParam); + containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam); container.start();