-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Runtime Default values in the static Config
- Loading branch information
Showing
7 changed files
with
88 additions
and
51 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
11 changes: 0 additions & 11 deletions
11
core/test-extension/deployment/src/test/java/io/quarkus/config/RuntimeInitConfigSource.java
This file was deleted.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
...-extension/deployment/src/test/java/io/quarkus/config/RuntimeInitConfigSourceFactory.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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.quarkus.config; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.eclipse.microprofile.config.spi.ConfigSource; | ||
|
||
import io.smallrye.config.ConfigSourceContext; | ||
import io.smallrye.config.ConfigSourceFactory; | ||
import io.smallrye.config.ConfigValue; | ||
import io.smallrye.config.common.MapBackedConfigSource; | ||
|
||
public class RuntimeInitConfigSourceFactory implements ConfigSourceFactory { | ||
@Override | ||
public Iterable<ConfigSource> getConfigSources(final ConfigSourceContext context) { | ||
ConfigValue value = context.getValue("skip.build.sources"); | ||
if (value.getValue() != null && value.getValue().equals("true")) { | ||
return List.of(new MapBackedConfigSource("RuntimeInitConfigSource", Map.of("config.static.init.my-prop", "1234")) { | ||
}); | ||
} else { | ||
return Collections.emptyList(); | ||
} | ||
} | ||
} |
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
13 changes: 0 additions & 13 deletions
13
core/test-extension/deployment/src/test/java/io/quarkus/config/StaticInitConfigSource.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
...t-extension/deployment/src/test/java/io/quarkus/config/StaticInitConfigSourceFactory.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.quarkus.config; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.eclipse.microprofile.config.spi.ConfigSource; | ||
|
||
import io.quarkus.runtime.annotations.StaticInitSafe; | ||
import io.smallrye.config.ConfigSourceContext; | ||
import io.smallrye.config.ConfigSourceFactory; | ||
import io.smallrye.config.ConfigValue; | ||
import io.smallrye.config.common.MapBackedConfigSource; | ||
|
||
@StaticInitSafe | ||
public class StaticInitConfigSourceFactory implements ConfigSourceFactory { | ||
@Override | ||
public Iterable<ConfigSource> getConfigSources(final ConfigSourceContext context) { | ||
ConfigValue value = context.getValue("skip.build.sources"); | ||
if (value.getValue() != null && value.getValue().equals("true")) { | ||
return List.of(new MapBackedConfigSource("StaticInitConfigSource", Map.of("config.static.init.my-prop", "1234")) { | ||
}); | ||
} else { | ||
return Collections.emptyList(); | ||
} | ||
} | ||
} |