|
8 | 8 | package org.seedstack.seed.core.internal.configuration; |
9 | 9 |
|
10 | 10 | import com.google.common.base.Strings; |
| 11 | +import org.seedstack.coffig.TreeNode; |
| 12 | +import org.seedstack.coffig.node.MapNode; |
| 13 | +import org.seedstack.coffig.spi.ConfigurationProcessor; |
| 14 | + |
11 | 15 | import java.util.ArrayList; |
12 | 16 | import java.util.Arrays; |
13 | 17 | import java.util.HashMap; |
| 18 | +import java.util.HashSet; |
14 | 19 | import java.util.List; |
15 | 20 | import java.util.Map; |
| 21 | +import java.util.Optional; |
16 | 22 | import java.util.Set; |
17 | 23 | import java.util.function.Predicate; |
18 | 24 | import java.util.regex.Matcher; |
19 | 25 | import java.util.regex.Pattern; |
20 | 26 | import java.util.stream.Collectors; |
21 | | -import org.seedstack.coffig.TreeNode; |
22 | | -import org.seedstack.coffig.node.MapNode; |
23 | | -import org.seedstack.coffig.spi.ConfigurationProcessor; |
24 | 27 |
|
25 | 28 | public class ProfileProcessor implements ConfigurationProcessor { |
26 | 29 | private static final String SEEDSTACK_PROFILES_PROPERTY = "seedstack.profiles"; |
| 30 | + private static final String SEEDSTACK_PROFILES_ENV = "SEEDSTACK_PROFILES"; |
27 | 31 | private static Pattern keyWithProfilePattern = Pattern.compile("(.*)<([,\\s\\w]+)>"); |
28 | 32 | private static Predicate<String> notNullOrEmpty = ((Predicate<String>) Strings::isNullOrEmpty).negate(); |
29 | 33 |
|
@@ -67,6 +71,9 @@ private static Set<String> parseProfiles(String value) { |
67 | 71 | } |
68 | 72 |
|
69 | 73 | static Set<String> activeProfiles() { |
70 | | - return parseProfiles(System.getProperty(SEEDSTACK_PROFILES_PROPERTY, "")); |
| 74 | + Set<String> activeProfiles = new HashSet<>(); |
| 75 | + activeProfiles.addAll(parseProfiles(System.getProperty(SEEDSTACK_PROFILES_PROPERTY, ""))); |
| 76 | + activeProfiles.addAll(parseProfiles(Optional.ofNullable(System.getenv(SEEDSTACK_PROFILES_ENV)).orElse(""))); |
| 77 | + return activeProfiles; |
71 | 78 | } |
72 | 79 | } |
0 commit comments