diff --git a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigUtils.java b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigUtils.java index c0bfbb453a695..8b005f6ca8256 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigUtils.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/configuration/ConfigUtils.java @@ -34,10 +34,26 @@ public static SmallRyeConfigBuilder emptyConfigBuilder() { .addDefaultSources(); } + /** + * Returns a {@code List} of the active profiles in Quarkus. + *

+ * Profiles are sorted in reverse order according to how they were set in + * {@code quarkus.profile}, as the last profile overrides the previous one until there are + * no profiles left in the list. + * + * @return a {@code List} of the active profiles + * @see io.smallrye.config.SmallRyeConfig#getProfiles() + */ public static List getProfiles() { return ConfigProvider.getConfig().unwrap(SmallRyeConfig.class).getProfiles(); } + /** + * Check if a configuration profile is active in Quarkus. + * + * @param profile the configuration profile to check + * @return true if the profile is active or false otherwise. + */ public static boolean isProfileActive(final String profile) { return getProfiles().contains(profile); } diff --git a/docs/src/main/asciidoc/config-reference.adoc b/docs/src/main/asciidoc/config-reference.adoc index 83c57341357d7..ac7a357735a4b 100644 --- a/docs/src/main/asciidoc/config-reference.adoc +++ b/docs/src/main/asciidoc/config-reference.adoc @@ -367,7 +367,7 @@ Setting `quarkus.profile` to `staging` will activate the `staging` profile. [NOTE] ==== -The `io.smallrye.config.SmallRyeConfig#getProfiles` API provides a way to retrieve the active profiles programmatically. +The `io.quarkus.runtime.configuration.ConfigUtils.getProfiles` API provides a way to retrieve the active profiles programmatically. ==== === Profile-aware files