switch ocs to struct tag based env config
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user