forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
206 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 17 additions & 12 deletions
29
extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayBuildTimeConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
package io.quarkus.flyway.runtime; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import io.quarkus.datasource.common.runtime.DataSourceUtil; | ||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
import io.smallrye.config.ConfigMapping; | ||
import io.smallrye.config.WithParentName; | ||
|
||
@ConfigRoot(name = "flyway", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) | ||
public final class FlywayBuildTimeConfig { | ||
@ConfigMapping(prefix = "quarkus.flyway") | ||
@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED) | ||
public interface FlywayBuildTimeConfig { | ||
|
||
/** | ||
* Gets the {@link FlywayDataSourceBuildTimeConfig} for the given datasource name. | ||
*/ | ||
public FlywayDataSourceBuildTimeConfig getConfigForDataSourceName(String dataSourceName) { | ||
default FlywayDataSourceBuildTimeConfig getConfigForDataSourceName(String dataSourceName) { | ||
if (DataSourceUtil.isDefault(dataSourceName)) { | ||
return defaultDataSource; | ||
return defaultDataSource(); | ||
} | ||
return namedDataSources.getOrDefault(dataSourceName, FlywayDataSourceBuildTimeConfig.defaultConfig()); | ||
FlywayDataSourceBuildTimeConfig config = namedDataSources().get(dataSourceName); | ||
if (config == null) { | ||
config = defaultDataSource(); | ||
} | ||
return config; | ||
} | ||
|
||
/** | ||
* Flyway configuration for the default datasource. | ||
*/ | ||
@ConfigItem(name = ConfigItem.PARENT) | ||
public FlywayDataSourceBuildTimeConfig defaultDataSource; | ||
@WithParentName | ||
FlywayDataSourceBuildTimeConfig defaultDataSource(); | ||
|
||
/** | ||
* Flyway configurations for named datasources. | ||
*/ | ||
@ConfigItem(name = ConfigItem.PARENT) | ||
public Map<String, FlywayDataSourceBuildTimeConfig> namedDataSources = Collections.emptyMap(); | ||
} | ||
@WithParentName | ||
Map<String, FlywayDataSourceBuildTimeConfig> namedDataSources(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.