sane common configurations

This commit is contained in:
A.Unger
2021-11-11 12:51:57 +01:00
parent 04d8ec86ab
commit aa67106e04
11 changed files with 72 additions and 97 deletions
+14 -4
View File
@@ -63,8 +63,20 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
return err
}
// provide with defaults for shared logging, since we need a valid destination address for BindEnv.
if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil {
cfg.Log = &shared.Log{
Level: cfg.Commons.Log.Level,
Pretty: cfg.Commons.Log.Pretty,
Color: cfg.Commons.Log.Color,
File: cfg.Commons.Log.File,
}
} else if cfg.Log == nil && cfg.Commons == nil {
cfg.Log = &shared.Log{}
}
// load all env variables relevant to the config in the current context.
conf.LoadOSEnv(config.GetEnv(), false)
conf.LoadOSEnv(config.GetEnv(cfg), false)
bindings := config.StructMappings(cfg)
return ociscfg.BindEnv(conf, bindings)
@@ -77,9 +89,7 @@ type SutureService struct {
// NewSutureService creates a new accounts.SutureService
func NewSutureService(cfg *ociscfg.Config) suture.Service {
if (cfg.Accounts.Log == shared.Log{}) {
cfg.Accounts.Log = cfg.Log
}
cfg.Accounts.Commons = cfg.Commons
return SutureService{
cfg: cfg.Accounts,
}