Skip to content

Commit

Permalink
Added support for multiple init scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianmarco Frangipane committed Jan 10, 2025
1 parent f040b40 commit 7df6602
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.datasource.deployment.spi;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;
Expand All @@ -15,7 +16,7 @@ public class DevServicesDatasourceContainerConfig {
private final Optional<String> dbName;
private final Optional<String> username;
private final Optional<String> password;
private final Optional<String> initScriptPath;
private final Optional<List<String>> initScriptsPaths;
private final Map<String, String> volumes;
private final boolean reuse;
private final boolean showLogs;
Expand All @@ -29,7 +30,7 @@ public DevServicesDatasourceContainerConfig(Optional<String> imageName,
Optional<String> dbName,
Optional<String> username,
Optional<String> password,
Optional<String> initScriptPath,
Optional<List<String>> initScriptsPaths,
Map<String, String> volumes,
boolean reuse,
boolean showLogs) {
Expand All @@ -42,7 +43,7 @@ public DevServicesDatasourceContainerConfig(Optional<String> imageName,
this.dbName = dbName;
this.username = username;
this.password = password;
this.initScriptPath = initScriptPath;
this.initScriptsPaths = initScriptsPaths;
this.volumes = volumes;
this.reuse = reuse;
this.showLogs = showLogs;
Expand Down Expand Up @@ -84,8 +85,8 @@ public Optional<String> getPassword() {
return password;
}

public Optional<String> getInitScriptPath() {
return initScriptPath;
public Optional<List<String>> getInitScriptsPaths() {
return initScriptsPaths;
}

public boolean isShowLogs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private static Map<String, Object> buildMapFromBuildConfig(DataSourcesBuildTimeC
res.put(name + ".devservices.container-properties.", config.devservices().containerProperties());
res.put(name + ".devservices.db-name", config.devservices().dbName());
res.put(name + ".devservices.image-name", config.devservices().imageName());
res.put(name + ".devservices.init-script-path", config.devservices().initScriptPath());
res.put(name + ".devservices.init-script-path", config.devservices().initScriptsPaths());
res.put(name + ".devservices.password", config.devservices().password());
res.put(name + ".devservices.port", config.devservices().port());
res.put(name + ".devservices.properties", config.devservices().properties());
Expand Down Expand Up @@ -286,7 +286,7 @@ private RunningDevService startDevDb(
dataSourceBuildTimeConfig.devservices().dbName(),
dataSourceBuildTimeConfig.devservices().username(),
dataSourceBuildTimeConfig.devservices().password(),
dataSourceBuildTimeConfig.devservices().initScriptPath(),
dataSourceBuildTimeConfig.devservices().initScriptsPaths(),
dataSourceBuildTimeConfig.devservices().volumes(),
dataSourceBuildTimeConfig.devservices().reuse(),
dataSourceBuildTimeConfig.devservices().showLogs());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.datasource.runtime;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;
Expand Down Expand Up @@ -83,11 +84,11 @@ public interface DevServicesBuildTimeConfig {
Optional<String> password();

/**
* The path to a SQL script to be loaded from the classpath and applied to the Dev Service database.
* The paths to SQL scripts to be loaded from the classpath and applied to the Dev Service database.
* <p>
* This has no effect if the provider is not a container-based database, such as H2 or Derby.
*/
Optional<String> initScriptPath();
Optional<List<@WithConverter(TrimmedStringConverter.class) String>> initScriptsPaths();

/**
* The volumes to be mapped to the container.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public RunningDevServicesDatasource startDatabase(Optional<String> username, Opt

containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam);
containerConfig.getCommand().ifPresent(container::setCommand);
containerConfig.getInitScriptPath().ifPresent(container::withInitScript);
containerConfig.getInitScriptsPaths().ifPresent(container::withInitScripts);
if (containerConfig.isShowLogs()) {
container.withLogConsumer(new JBossLoggingConsumer(LOG));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public RunningDevServicesDatasource startDatabase(Optional<String> username, Opt

containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam);
containerConfig.getCommand().ifPresent(container::setCommand);
containerConfig.getInitScriptPath().ifPresent(container::withInitScript);
containerConfig.getInitScriptsPaths().ifPresent(container::withInitScripts);
if (containerConfig.isShowLogs()) {
container.withLogConsumer(new JBossLoggingConsumer(LOG));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public RunningDevServicesDatasource startDatabase(Optional<String> username, Opt

containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam);
containerConfig.getCommand().ifPresent(container::setCommand);
containerConfig.getInitScriptPath().ifPresent(container::withInitScript);
containerConfig.getInitScriptsPaths().ifPresent(container::withInitScripts);
if (containerConfig.isShowLogs()) {
container.withLogConsumer(new JBossLoggingConsumer(LOG));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public RunningDevServicesDatasource startDatabase(Optional<String> username, Opt

containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam);
containerConfig.getCommand().ifPresent(container::setCommand);
containerConfig.getInitScriptPath().ifPresent(container::withInitScript);
containerConfig.getInitScriptsPaths().ifPresent(container::withInitScripts);
if (containerConfig.isShowLogs()) {
container.withLogConsumer(new JBossLoggingConsumer(LOG));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public RunningDevServicesDatasource startDatabase(Optional<String> username, Opt

containerConfig.getAdditionalJdbcUrlProperties().forEach(container::withUrlParam);
containerConfig.getCommand().ifPresent(container::setCommand);
containerConfig.getInitScriptPath().ifPresent(container::withInitScript);
containerConfig.getInitScriptsPaths().ifPresent(container::withInitScripts);
if (containerConfig.isShowLogs()) {
container.withLogConsumer(new JBossLoggingConsumer(LOG));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public RunningDevServicesDatasource startDatabase(Optional<String> username, Opt
}
container.setCommand(augmentedCommand);

containerConfig.getInitScriptPath().ifPresent(container::withInitScript);
containerConfig.getInitScriptsPaths().ifPresent(container::withInitScripts);
if (containerConfig.isShowLogs()) {
container.withLogConsumer(new JBossLoggingConsumer(LOG));
}
Expand Down

0 comments on commit 7df6602

Please sign in to comment.