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.
.replace("-", "_")
.replace(".", "_");
- return Optional.ofNullable(System.getenv().get(key)).map(ImmutableList::of);
+ String value = System.getenv().get(key);
+ if (value == null) {
+ return Optional.empty();
+ }
+
+ if (value.startsWith("$")) {
+ value = System.getenv(value.substring(1));
+ }
+
+ return Optional.ofNullable(value).map(ImmutableList::of);
}
}
