use reflection to set config values from environment

This commit is contained in:
A.Unger
2021-11-03 11:34:56 +01:00
parent d54fc2f5b9
commit 09195ffc8c
4 changed files with 104 additions and 5 deletions
+13 -1
View File
@@ -67,7 +67,19 @@ func NewLogger(cfg *config.Config) log.Logger {
// ParseConfig loads proxy configuration from known paths.
func ParseConfig(c *cli.Context, cfg *config.Config) error {
return ociscfg.BindSourcesToStructs("proxy", cfg)
conf, err := ociscfg.BindSourcesToStructs("proxy", cfg)
if err != nil {
return err
}
// load all env variables relevant to the config in the current context.
conf.LoadOSEnv(config.GetEnv(), false)
if err = config.UnmapEnv(conf, cfg); err != nil {
return err
}
return nil
}
// SutureService allows for the proxy command to be embedded and supervised by a suture supervisor tree.