This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
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.
Motivation
Currently there is no conversion done (except nesting
.
->_
), and the rest of the format for Flat or Map is the same as for environment variables.Which seems awkward to me.
Now if I define a Config, and want to read from Env, I am kind of forced to use ugly upper-case key names in my Config, making the Config specialised for Environment variables.
Or I must break with convention and live with
camelCase
key names to fit with Flat or Map providers.Proposal
Auto convert from/to Environment variable convention.
The convention for environment variables classically is
UPPERCASE
,word separation is clasically with
_
so:HOST_PORT
.Nesting is currently also done with
_
, so I would instead propose__
to avoid reasonable colissions.key - current - suggestion
host
-host
->HOST
hostPort
-hostPort
->HOST_PORT
hostPort.port
-hostPort_port
->HOST_PORT__PORT
TODO
Auto replace any unsupported symbol with
__
?hubla@abc%
->HUBLA__ABC__
sample of invalid:
This might however prove challenging because apparently there's also a return conversion :)
Alternative
Provide the ability to provide a transformer to a ConfigProvider, so that one may override it with their own convention.
Extending