Conversation
By default, values from configuration files loaded via Configuration or ConfigFlag take precedence over environment variables from `env` tags: flag > configuration > env > default. EnvOverridesConfiguration swaps configuration files and environment variables, so the precedence becomes flag > env > configuration > default. Other resolvers are not affected. The option is opt-in so the default behaviour is unchanged. Also document the precedence of values in the README.
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.
Some people are confused by the choice Kong did which prefers Configuration (files) over Environment Variables.
This happened to me yesterday and colleagues of mine as well friends intuition would be the opposite.
FWIW: This is a topic with a bit of history12.
Instead of implementing a custom loader in every project i use Kong i thought why not bring this topic up again and maybe even resolve #566 with it.
I found two groups of related issues, 1 which are mostly about how it works, while 2 was about moving loading environments via resolver. The latter introduced breaking changes.
So this MR is purely about allowing users to swap this behavior (
... > Config > Env > ...to... > Env > Config > ...) to align the behavior of Kong more with the expectations which are common in the DevOps world.To not introduce any breaking changes i've made this a callable Option from
kong.Parse(...).Maybe also in the hopes we could have a separate discussion3 if we could make this the default behavior with a new major release.
(The less knobs the better IMO)
Anyway. Since 1.x already made a breaking change, maybe we can find a way to stagger the change over multiple releases?
Footnotes
Related Issues over time Flag / Env / Config / Default argument ordering #566, Precedence order when config file is specified on the command line #249, Precedence order when config file is specified on the command line #254, Questions about setting the path to the config file path on the command line in Kong #351, Questions about setting the path to the config file path on the command line in Kong #353 ↩ ↩2
Load Env via Resolver Load environment variables as a resolver #480 (reverted), 1.8.0 broke environment resolving #497 and
1.8.0seems to introduce breaking change to custom decoders #498 ↩ ↩2Where i can provide arguments and examples etc. why i think such a change might be a welcome one for users ↩