-
Notifications
You must be signed in to change notification settings - Fork 19
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
Env-vars expect lower case letters #583
Comments
@mostafa, what about the parameters? I guess it’s not only related to the recent change; we have a problem with those that do not have a configuration block, like |
But parameters are struct, not keys, so it’s not a good idea to lowercase them. For parameters, we need to find another solution or leave them as they are. The PR #587 will only lowercase configuration groups and configuration blocks. |
@sinadarbouy how about changing struct tags? Possibly in a separate PR. |
If we change the struct tag, we need to change the YAML configuration as well. but, do we want to lowercase the parameters or change them to another format like Kebab Case? Neither of these options is a good idea. @mostafa What do you think about implementing some parameter mapping? Parameters not defined by the user so could have a mapping, such as:
or generate it from
|
Env tag seems like a nice idea. |
Definitely, maybe the env might be optional for the obvious ones (the ones that have no problems) I'm a bit afraid a forgotten env tag on a new fields won't be available via the env variables Or, the code,or the tests, could expect each struct fields/groups to have an env tag |
Using the env tag can complicate things and introduce additional edge cases, such as needing to parse the ENV variable to determine if it represents parameters, a configuration group, or a configuration block. the PR #588, handle this with the |
I found a tiny bug (more of an assumption on how things work) in processing environment variables. The strings.ToLower in the
loadEnvVars()
function assumes that all keys are in lower case, yet the config blocks are camel case, likeactiveWrites
.As a result, the
GATEWAYD_POOLS_DEFAULT_ACTIVEWRITES_SIZE=1
gets converted tomap[pools:map[default:map[activewrites:map[size:1]]]]
, which is incorrect because it creates a new config block:activewrites
(notice the lower case).I removed the
strings.ToLower
function and tested it with normal cased env-vars. Now, usingGATEWAYD_pools_default_activeWrites_size=1
gets converted tomap[pools:map[default:map[activeWrites:map[size:1]]]]
and it works as expected.However, environment variables are usually written in upper case letters, so we need to find a fix for this that accommodates the convention of upper case env-vars without breaking the camel case config blocks.
This is related to recent changes in #577.
A viable solution is to disregard the casing and only accept lower case config blocks (and maybe config groups). And then ensure that we are converting all the keys to lower case before loading the configuration from the file.
The text was updated successfully, but these errors were encountered: