Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,26 @@ public static SmallRyeConfigBuilder emptyConfigBuilder() {
.addDefaultSources();
}

/**
* Returns a {@code List} of the active profiles in Quarkus.
* <p>
* 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<String> 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);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/config-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading