normalize webdav

This commit is contained in:
A.Unger
2021-11-08 12:32:52 +01:00
parent 185cee04e9
commit 8c2a681937
5 changed files with 23 additions and 126 deletions
+3 -20
View File
@@ -71,11 +71,8 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
// 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 webdav command to be embedded and supervised by a suture supervisor tree.
@@ -85,11 +82,7 @@ type SutureService struct {
// NewSutureService creates a new webdav.SutureService
func NewSutureService(cfg *ociscfg.Config) suture.Service {
inheritLogging(cfg)
if cfg.Mode == 0 {
cfg.WebDAV.Supervised = true
}
cfg.WebDAV.Log.File = cfg.Log.File
cfg.WebDAV.Log = cfg.Log
return SutureService{
cfg: cfg.WebDAV,
}
@@ -103,13 +96,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.WebDAV.Log.File = cfg.Log.File
cfg.WebDAV.Log.Color = cfg.Log.Color
cfg.WebDAV.Log.Pretty = cfg.Log.Pretty
cfg.WebDAV.Log.Level = cfg.Log.Level
}