chore: add log message for workdir and configuration loading
Cadoles/bouncer/pipeline/head This commit looks good
Details
Cadoles/bouncer/pipeline/head This commit looks good
Details
This commit is contained in:
parent
ff1d01828d
commit
74928fe413
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue