Skip to content

Commit b63538b

Browse files
committed
Allow EnvConfig to use the values of other env variables
It turns out that kubernetes will expose useful environment variables in config scripts, but they need to be accessed. This allows one to use `$VAR` as a config value to make the `EnvConfig` look up that value and return it.
1 parent ec01f52 commit b63538b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

java/server/src/org/openqa/selenium/grid/config/EnvConfig.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public Optional<List<String>> getAll(String section, String option) {
4242
.replace("-", "_")
4343
.replace(".", "_");
4444

45-
return Optional.ofNullable(System.getenv().get(key)).map(ImmutableList::of);
45+
String value = System.getenv().get(key);
46+
if (value == null) {
47+
return Optional.empty();
48+
}
49+
50+
if (value.startsWith("$")) {
51+
value = System.getenv(value.substring(1));
52+
}
53+
54+
return Optional.ofNullable(value).map(ImmutableList::of);
4655
}
4756
}

0 commit comments

Comments
 (0)