diff --git a/main.go b/main.go index 8fa37a55..2f14ce36 100644 --- a/main.go +++ b/main.go @@ -13,7 +13,6 @@ import ( "github.com/roboll/helmfile/pkg/state" "github.com/urfave/cli" "go.uber.org/zap" - "go.uber.org/zap/zapcore" ) var logger *zap.SugaredLogger @@ -22,14 +21,11 @@ func configureLogging(c *cli.Context) error { // Valid levels: // https://github.com/uber-go/zap/blob/7e7e266a8dbce911a49554b945538c5b950196b8/zapcore/level.go#L126 logLevel := c.GlobalString("log-level") - if c.GlobalBool("quiet") { + if c.GlobalBool("debug") { + logLevel = "debug" + } else if c.GlobalBool("quiet") { logLevel = "warn" } - var level zapcore.Level - err := level.Set(logLevel) - if err != nil { - return err - } logger = helmexec.NewLogger(os.Stderr, logLevel) if c.App.Metadata == nil { // Auto-initialised in 1.19.0 @@ -76,6 +72,10 @@ func main() { Name: "kube-context", Usage: "Set kubectl context. Uses current context by default", }, + cli.BoolFlag{ + Name: "debug", + Usage: "Enable verbose output for Helm and set log-level to debug, this disables --quiet/-q effect", + }, cli.BoolFlag{ Name: "no-color", Usage: "Output without color", @@ -539,7 +539,13 @@ func (c configImpl) Values() []string { } func (c configImpl) Args() string { - return c.c.String("args") + args := c.c.String("args") + enableHelmDebug := c.c.GlobalBool("debug") + + if enableHelmDebug { + args = fmt.Sprintf("%s %s", args, "--debug") + } + return args } func (c configImpl) OutputDir() string {