docker_auth icon indicating copy to clipboard operation
docker_auth copied to clipboard

Add env variable support for configuration

Open ewassef opened this issue 2 years ago • 9 comments

https://github.com/cesanta/docker_auth/pull/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

ewassef avatar Apr 25 '22 22:04 ewassef

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.

techknowlogick avatar Apr 26 '22 00:04 techknowlogick

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

ewassef avatar Apr 26 '22 21:04 ewassef

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

ewassef avatar Apr 29 '22 03:04 ewassef

@techknowlogick any guidance?

ewassef avatar May 12 '22 03:05 ewassef

@flaper87 @techknowlogick @karmi anyone?

ewassef avatar May 13 '22 22:05 ewassef

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

ewassef avatar May 25 '22 18:05 ewassef

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

techknowlogick avatar May 25 '22 20:05 techknowlogick

@techknowlogick any help?

ewassef avatar Jul 22 '22 19:07 ewassef