-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Properties from file system should be search with the same rules used for environment variables #276
Conversation
accoding to specification
Hi @kifj Thank yo for the PR! Just a clarification: from my understanding, the spec only mandates the name mapping to happen for Environment Variables: https://github.com/eclipse/microprofile-config/blob/cafee0a79fd36dfaa4f7b30bc77efa75eefa589b/spec/src/main/asciidoc/configsources.asciidoc#L53 Now, that doesn't mean we shouldn't support this in the Do you mind adding a few tests? |
@@ -96,4 +98,30 @@ private static String readContent(Path file) { | |||
throw new UncheckedIOException(e); | |||
} | |||
} | |||
|
|||
@Override | |||
public String getValue(String name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tests.
You're right regarding the specification so I have updated the comment and added a unit test |
Thanks! Can you also document the new feature for |
… for environment variables (smallrye#276) Properties from file system should be search with the same rules used for environment variables.
Statement of problem
given a interface for the MicroProfile REST client
which will retrieve its URL from MP Config with the key
com.example.QuickQuoteService/mp-rest/url
and a ConfigMap in Kubernetes with entries
A ConfigMap defines rules on the key, which forbids '/', because it cannot be mapped to an environment variable or a file name.
According to specification the replacement rules are defined for environment variables, all non-alphanumeric characters are replaced with '_'; and if that doesn't resolve, all alphabetical characters can be upper-case.
This ConfigMap will be mounted in a volume, resulting in a file named com_example_QuickQuoteService_mp_rest_url with the value as content.
The FileSystemConfigSource should pick up that file (which it does) and the Config should return its content as value for the key
com.example.QuickQuoteService/mp-rest/url
(which is doesn't)Solution
The mapping rules for environment variables (see EnvConfigSource) should apply to file names as well, even if the specification does not define this behavior.