chore: add log message for workdir and configuration loading
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good

This commit is contained in:
wpetit 2023-06-29 20:16:25 -06:00
parent ff1d01828d
commit 74928fe413
2 changed files with 8 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"forge.cadoles.com/cadoles/bouncer/internal/config"
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
"gitlab.com/wpetit/goweb/logger"
)
func LoadConfig(ctx *cli.Context) (*config.Config, error) {
@ -15,11 +16,15 @@ func LoadConfig(ctx *cli.Context) (*config.Config, error) {
)
if configFile != "" {
logger.Info(ctx.Context, "loading config", logger.F("config", configFile))
conf, err = config.NewFromFile(configFile)
if err != nil {
return nil, errors.Wrapf(err, "Could not load config file '%s'", configFile)
}
} else {
logger.Info(ctx.Context, "using default config")
conf = config.NewDefault()
}

View File

@ -9,6 +9,7 @@ import (
"github.com/pkg/errors"
"github.com/urfave/cli/v2"
"gitlab.com/wpetit/goweb/logger"
)
func Main(buildDate, projectVersion, gitRef, defaultConfigPath string, commands ...*cli.Command) {
@ -29,6 +30,8 @@ func Main(buildDate, projectVersion, gitRef, defaultConfigPath string, commands
workdir := ctx.String("workdir")
// Switch to new working directory if defined
if workdir != "" {
logger.Info(ctx.Context, "changing working directory", logger.F("workdir", workdir))
if err := os.Chdir(workdir); err != nil {
return errors.Wrap(err, "could not change working directory")
}