Skip to content
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

Add env variable support for configuration #339

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

ewassef
Copy link

@ewassef ewassef commented Apr 25, 2022

#225 updated to current HEAD

This commit also makes possible to use json files as configuration
files via viper configuration library.

This PR contains breaking changes on configuration to make
configuration overridable by the environment variables. To make it
support nested struct overrides struct tags are renamed to not
contain any underscore in their names. This is going to break old
configuration files.

Because of viper's limitations of detecting new map keys from env
variables, a little procedure goes trough prefixed env variables and
override viper settings by the parsed value of them. If the
configuration file is in yaml format env variables can contain correct
yaml strings and they will be parsed correctly. This behaviour is same
for json files too.

PS: viper doesn't use file format parsers for unmarshalling the structures.
It parses files as interface{} and the using mapstructure library to
unmarshall structs from maps. This is why yaml struct tags converted to
mapstructure ones.

The original author is @Um

Tagging @techknowlogick frm the other PR https://github.com/techknowlogick

umurgdk and others added 6 commits February 19, 2018 18:01
This commit also makes possible to use json files as configuration
files via `viper` configuration library. And contains breaking changes
to configuration.

Because of viper's limitations of detecting new map keys from env
variables, a little procedure goes trough prefixed env variables and
override viper settings by the parsed value of them. If the
configuration file is in yaml format env variables can contain correct
yaml strings and they will be parsed correctly. This behaviour is same
for json files too.
…nto upstream

# Conflicts:
#	auth_server/authn/github_auth.go
#	auth_server/authn/ldap_auth.go
#	auth_server/authn/static_auth.go
#	auth_server/authz/acl_mongo.go
#	auth_server/main.go
#	auth_server/mgo_session/mgo_session.go
#	auth_server/server/config.go
@techknowlogick
Copy link
Collaborator

Thanks for picking up this PR @ewassef

As you can imaging this will take some time to review, especially due to the breaking nature, however I can commit to you (haha, no pun intended 😉) to review this.

@ewassef
Copy link
Author

ewassef commented Apr 26, 2022

Thanks for the follow-up.. I went ahead and fixed the tests and committed the change.

@ewassef
Copy link
Author

ewassef commented Apr 29, 2022

@techknowlogick would you mind letting the checks kick off so I can fix anything that might come up/

@ewassef
Copy link
Author

ewassef commented May 12, 2022

@techknowlogick any guidance?

@ewassef
Copy link
Author

ewassef commented May 13, 2022

@flaper87 @techknowlogick @karmi anyone?

@ewassef
Copy link
Author

ewassef commented May 25, 2022

Hi there @techknowlogick @umurgdk @karmi @flaper87 any help is appreciated

@techknowlogick
Copy link
Collaborator

I've just tried pushing an update to see if that fixed the build

@ewassef
Copy link
Author

ewassef commented Jul 22, 2022

@techknowlogick any help?

@mstup
Copy link

mstup commented May 26, 2024

Is there any chance that it could be completed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants