wip correctly parse config

This commit is contained in:
A.Unger
2020-10-09 11:24:04 +02:00
parent f2d560ff0f
commit 8fe3ac9b33
4 changed files with 15 additions and 17 deletions

View File

@@ -33,7 +33,8 @@ func Execute() error {
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
return nil
//return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
@@ -87,16 +88,16 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
if err := viper.ReadInConfig(); err != nil {
switch err.(type) {
case viper.ConfigFileNotFoundError:
logger.Info().
Msg("Continue without config")
logger.Debug().
Msg("no config found on preconfigured location")
case viper.UnsupportedConfigError:
logger.Fatal().
Err(err).
Msg("Unsupported config type")
Msg("unsupported config type")
default:
logger.Fatal().
Err(err).
Msg("Failed to read config")
Msg("failed to read config")
}
}

View File

@@ -6,7 +6,6 @@ import (
"net/http"
"os"
"os/signal"
"strconv"
"strings"
"time"
@@ -45,8 +44,6 @@ func Server(cfg *config.Config) *cli.Command {
Usage: "Start integrated server",
Flags: flagset.ServerWithConfig(cfg),
Before: func(ctx *cli.Context) error {
l := NewLogger(cfg)
l.Debug().Str("tracing", strconv.FormatBool(cfg.Tracing.Enabled)).Msg("init: before")
if cfg.HTTP.Root != "/" {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
}