Use log module to determine current log level

As part of config refactoring process, it makes sense to
remove Debug field of AirshipCTLSettings and use log module
method as source of truth about current log level.

Change-Id: I42e3a9fd3b4e2778c71278f98a0d168421dfd2fb
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #327
This commit is contained in:
Ruslan Aliev 2020-08-25 16:29:19 -05:00
parent 60dae58d68
commit 160117af3a
5 changed files with 10 additions and 4 deletions

View File

@ -71,7 +71,7 @@ func GenerateBootstrapIso(settings *environment.AirshipCTLSettings) error {
return err
}
err = generateBootstrapIso(docBundle, builder, cfg, settings.Debug)
err = generateBootstrapIso(docBundle, builder, cfg, log.DebugEnabled())
if err != nil {
return err
}

View File

@ -61,7 +61,7 @@ func NewExecutor(cfg ifc.ExecutorConfig) (ifc.Executor, error) {
if err != nil {
return nil, err
}
client, err := NewClient(tgtPath, cfg.AirshipSettings.Debug, options)
client, err := NewClient(tgtPath, log.DebugEnabled(), options)
if err != nil {
return nil, err
}

View File

@ -20,6 +20,7 @@ import (
"opendev.org/airship/airshipctl/pkg/config"
"opendev.org/airship/airshipctl/pkg/document"
"opendev.org/airship/airshipctl/pkg/environment"
"opendev.org/airship/airshipctl/pkg/log"
)
// Command adds a layer to clusterctl interface with airshipctl context
@ -48,7 +49,7 @@ func NewCommand(rs *environment.AirshipCTLSettings) (*Command, error) {
if err != nil {
return nil, err
}
client, err := client.NewClient(root, rs.Debug, options)
client, err := client.NewClient(root, log.DebugEnabled(), options)
if err != nil {
return nil, err
}

View File

@ -31,6 +31,11 @@ func Init(debugFlag bool, out io.Writer) {
airshipLog.SetOutput(out)
}
// DebugEnabled returns whether the debug level is set
func DebugEnabled() bool {
return debug
}
// Debug is a wrapper for log.Debug
func Debug(v ...interface{}) {
if debug {

View File

@ -175,7 +175,7 @@ func (p *Cmd) Exec(name string) error {
return
}
executor.Run(runCh, ifc.RunOptions{
Debug: p.Debug,
Debug: log.DebugEnabled(),
DryRun: p.DryRun,
})
}()