fixed code smells: string literal repetition + cyclomatic complexity

This commit is contained in:
A.Unger
2021-11-17 12:25:21 +01:00
parent c567eb6eea
commit aa4112e2e2
7 changed files with 95 additions and 98 deletions
+1 -24
View File
@@ -3,10 +3,6 @@ package command
import (
"context"
gofig "github.com/gookit/config/v2"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/shared"
"github.com/owncloud/ocis/store/pkg/tracing"
"github.com/owncloud/ocis/ocis-pkg/sync"
@@ -25,26 +21,7 @@ func Server(cfg *config.Config) *cli.Command {
Name: "server",
Usage: "Start integrated server",
Before: func(ctx *cli.Context) error {
// remember shared logging info to prevent empty overwrites
inLog := cfg.Log
if err := ParseConfig(ctx, cfg); err != nil {
return err
}
if (cfg.Log == shared.Log{}) && (inLog != shared.Log{}) {
// set the default to the parent config
cfg.Log = inLog
// and parse the environment
conf := &gofig.Config{}
conf.LoadOSEnv(config.GetEnv(), false)
bindings := config.StructMappings(cfg)
if err := ociscfg.BindEnv(conf, bindings); err != nil {
return err
}
}
return nil
return ParseConfig(ctx, cfg)
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)