normalize web

This commit is contained in:
A.Unger
2021-11-08 12:29:59 +01:00
parent b1de937c05
commit 185cee04e9
4 changed files with 21 additions and 84 deletions
+3 -22
View File
@@ -62,14 +62,9 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
return err
}
// load all env variables relevant to the config in the current context.
conf.LoadOSEnv(config.GetEnv(), false)
if err = cfg.UnmapEnv(conf); err != nil {
return err
}
return nil
bindings := config.StructMappings(cfg)
return ociscfg.BindEnv(conf, bindings)
}
// SutureService allows for the web command to be embedded and supervised by a suture supervisor tree.
@@ -79,11 +74,7 @@ type SutureService struct {
// NewSutureService creates a new web.SutureService
func NewSutureService(cfg *ociscfg.Config) suture.Service {
inheritLogging(cfg)
if cfg.Mode == 0 {
cfg.Web.Supervised = true
}
cfg.Web.Log.File = cfg.Log.File
cfg.Web.Log = cfg.Log
return SutureService{
cfg: cfg.Web,
}
@@ -97,13 +88,3 @@ func (s SutureService) Serve(ctx context.Context) error {
return nil
}
// inheritLogging is a poor man's global logging state tip-toeing around circular dependencies. It sets the logging
// of the service to whatever is in the higher config (in this case coming from ocis.yaml) and sets them as defaults,
// being overwritten when the extension parses its config file / env variables.
func inheritLogging(cfg *ociscfg.Config) {
cfg.Web.Log.File = cfg.Log.File
cfg.Web.Log.Color = cfg.Log.Color
cfg.Web.Log.Pretty = cfg.Log.Pretty
cfg.Web.Log.Level = cfg.Log.Level
}
-3
View File
@@ -30,9 +30,6 @@ func Server(cfg *config.Config) *cli.Command {
return err
}
logger := NewLogger(cfg)
logger.Debug().Str("service", "web").Msg("ignoring config file parsing when running supervised")
// build well known openid-configuration endpoint if it is not set
if cfg.Web.Config.OpenIDConnect.MetadataURL == "" {
cfg.Web.Config.OpenIDConnect.MetadataURL = strings.TrimRight(cfg.Web.Config.OpenIDConnect.Authority, "/") + "/.well-known/openid-configuration"