switch ocs to struct tag based env config

This commit is contained in:
Willy Kloucek
2022-01-03 07:49:23 +01:00
parent a35c472be3
commit d0030ab555
18 changed files with 101 additions and 193 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
}
// merge environment variable config on top of the current config
if err := mergo.Merge(cfg, envCfg, mergo.WithOverride); err != nil {
if err := mergo.Merge(cfg, envCfg, mergo.WithOverride); err != nil && err.Error() != "none of the target fields were set from environment variables" {
return err
}
+2 -15
View File
@@ -4,10 +4,9 @@ import (
"context"
"strings"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/oklog/run"
"github.com/owncloud/ocis/accounts/pkg/config"
"github.com/owncloud/ocis/accounts/pkg/logging"
"github.com/owncloud/ocis/accounts/pkg/metrics"
"github.com/owncloud/ocis/accounts/pkg/server/grpc"
"github.com/owncloud/ocis/accounts/pkg/server/http"
@@ -16,18 +15,6 @@ import (
"github.com/urfave/cli/v2"
)
// TODO: don't redeclare from ocis-pkg/log/log.go
// LoggerFromConfig initializes a service-specific logger instance.
func LoggerFromConfig(name string, cfg config.Log) log.Logger {
return log.NewLogger(
log.Name(name),
log.Level(cfg.Level),
log.Pretty(cfg.Pretty),
log.Color(cfg.Color),
log.File(cfg.File),
)
}
// Server is the entry point for the server command.
func Server(cfg *config.Config) *cli.Command {
return &cli.Command{
@@ -48,7 +35,7 @@ func Server(cfg *config.Config) *cli.Command {
return nil
},
Action: func(c *cli.Context) error {
logger := LoggerFromConfig("accounts", cfg.Log)
logger := logging.Configure(cfg.Service.Name, cfg.Log)
err := tracing.Configure(cfg)
if err != nil {
return err