Skip to content

Commit 6333096

Browse files
authored
Merge pull request #86 from SentryMan/profiles
Avaje Profiles
2 parents 41b7d83 + 449b754 commit 6333096

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Below is the how it looks for configuration properties.
7676

7777
- loads via system property `props.file` or environment variable `PROPS_FILE` (if defined)
7878

79-
- loads via system property `config.profiles` or environment variable `CONFIG_PROFILES` (if defined).
79+
- loads via system property `avaje.profiles` or environment variable `AVAJE_PROFILES` (if defined).
8080

8181
Setting the `config.profiles` or environment variable `CONFIG_PROFILES` will cause avaje config to load the property files in the form `application-${profile}.properties` (will also work for yml/yaml files).
8282

avaje-config/src/main/java/io/avaje/config/InitialLoadContext.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void loadEnvironmentVars() {
5959
initSystemProperty(System.getenv("POD_VERSION"), "app.version");
6060
initSystemProperty(System.getenv("POD_IP"), "app.ipAddress");
6161
initSystemProperty(System.getenv("CONFIG_PROFILES"), "config.profiles");
62+
initSystemProperty(System.getenv("AVAJE_PROFILES"), "avaje.profiles");
6263
}
6364

6465
private void initSystemProperty(String envValue, String key) {
@@ -133,18 +134,24 @@ CoreMap evalAll() {
133134
* Read the special properties that can point to an external properties source.
134135
*/
135136
String indirectLocation() {
136-
CoreEntry indirectLocation = map.get("load.properties");
137+
var indirectLocation = map.get("load.properties");
137138
if (indirectLocation == null) {
138139
indirectLocation = map.get("load.properties.override");
139140
}
140141
return indirectLocation == null ? null : indirectLocation.value();
141142
}
142143

143144
String profiles() {
144-
final CoreEntry indirectLocation = map.get("config.profiles");
145-
return indirectLocation == null
146-
? System.getProperty("config.profiles")
147-
: indirectLocation.value();
145+
final var configEntry = map.get("config.profiles");
146+
final var configProfile =
147+
configEntry == null ? System.getProperty("config.profiles") : configEntry.value();
148+
149+
if (configProfile != null) {
150+
return configProfile;
151+
}
152+
153+
final var avajeProfile = map.get("avaje.profiles");
154+
return avajeProfile == null ? System.getProperty("avaje.profiles") : avajeProfile.value();
148155
}
149156

150157
/**
@@ -155,7 +162,7 @@ int size() {
155162
}
156163

157164
String getAppName() {
158-
final CoreEntry appName = map.get("app.name");
165+
final var appName = map.get("app.name");
159166
return (appName != null) ? appName.value() : System.getProperty("app.name");
160167
}
161168
}

0 commit comments

Comments
 (0)