William Petit
e66938f1d3
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
37 lines
806 B
Go
37 lines
806 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
|
|
"forge.cadoles.com/cadoles/bouncer/internal/command/common"
|
|
"forge.cadoles.com/cadoles/bouncer/internal/config"
|
|
"github.com/pkg/errors"
|
|
"github.com/urfave/cli/v2"
|
|
"gitlab.com/wpetit/goweb/logger"
|
|
)
|
|
|
|
func Dump() *cli.Command {
|
|
flags := common.Flags()
|
|
|
|
return &cli.Command{
|
|
Name: "dump",
|
|
Usage: "Dump the current configuration",
|
|
Flags: flags,
|
|
Action: func(ctx *cli.Context) error {
|
|
conf, err := common.LoadConfig(ctx)
|
|
if err != nil {
|
|
return errors.Wrap(err, "Could not load configuration")
|
|
}
|
|
|
|
logger.SetFormat(logger.Format(conf.Logger.Format))
|
|
logger.SetLevel(logger.Level(conf.Logger.Level))
|
|
|
|
if err := config.Dump(conf, os.Stdout); err != nil {
|
|
return errors.Wrap(err, "Could not dump configuration")
|
|
}
|
|
|
|
return nil
|
|
},
|
|
}
|
|
}
|