Fix env vars for camelCase settings - #797
Open
mmeier86 wants to merge 1 commit into
Open
Conversation
This commits fixes environment variable handling for YaCy settings which have camelCase names. Before this commit, environment variables were only working for settings with all lower case names. Trying to set values like browserPopUpTrigger through YACY_BROWSERPOPUPTRIGGER would not work, because the code would transform the env variable to "browserpopuptrigger", which would then not be found in the config values, and hence the variable setting would be skipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi YaCy team,
This PR relates to #794
While setting up YaCy with the Docker image in my k8s cluster, I found that environment variables only work for settings like
server.https, which consist of all lower letters (and dots) only. But for settings likebrowserPopUpTrigger, the environment variableYACY_BROWSERPOPUPTRIGGERwould be ignored.It turns out that that that's because during setup, the environment variable is changed to all lower case to find the related config key, and that doesn't work for camelCase keys, as they aren't found.
This PR fixes the issue. As we can't derive camelCase names from the all-caps names of the environment variables, I decided to rewrite the loops a bit. I'm now looping over all entries in the
configPropsmap, and check for each entry whether there is a corresponding env variable or system property. To not iterate over all configs twice, once for env variables and once for system properties, I combined them into the same loop. The order of precedence, with env variables overwriting system properties, is preserved.One question I've got: I will admit that I haven't worked with Java applications in a very long time, but is checking the System properties actually useful here? Are those generally used for settings when deploying an app?
I've done some local testing with this commit, checking whether
camelCasesettings now work, and whetherall.lower.casedsettings still work, and both succeeded.