Set debug flag in the main app (#64)

This commit is contained in:
Itxaka 2023-06-21 09:42:11 +02:00 committed by GitHub
parent b126f7ab00
commit 629a0b2eee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 11 deletions

View File

@ -26,7 +26,6 @@ import (
qr "github.com/mudler/go-nodepair/qrcode"
"github.com/mudler/go-pluggable"
"github.com/pterm/pterm"
"github.com/spf13/viper"
"gopkg.in/yaml.v2"
)
@ -63,7 +62,7 @@ func mergeOption(cloudConfig string, r map[string]string) {
}
}
func ManualInstall(c string, options map[string]string, strictValidations, debug bool) error {
func ManualInstall(c string, options map[string]string, strictValidations bool) error {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
@ -98,8 +97,6 @@ func ManualInstall(c string, options map[string]string, strictValidations, debug
}
}
// Set debug from here already, so it's loaded by the ReadConfigRun
viper.Set("debug", debug)
// Load the installation Config from the system
installConfig, err := elementalConfig.ReadConfigRun("/etc/elemental")
if err != nil {
@ -109,7 +106,7 @@ func ManualInstall(c string, options map[string]string, strictValidations, debug
return RunInstall(installConfig, options)
}
func Install(debug bool, dir ...string) error {
func Install(dir ...string) error {
utils.OnSignal(func() {
svc, err := machine.Getty(1)
if err == nil {
@ -133,8 +130,6 @@ func Install(debug bool, dir ...string) error {
ensureDataSourceReady()
// Set debug from here already, so it's loaded by the ReadConfigRun
viper.Set("debug", debug)
// Load the installation Config from the system
installConfig, err := elementalConfig.ReadConfigRun("/etc/elemental")
if err != nil {

12
main.go
View File

@ -26,6 +26,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/Masterminds/semver/v3"
"github.com/spf13/viper"
"github.com/urfave/cli/v2"
"gopkg.in/yaml.v3"
)
@ -417,8 +418,7 @@ This command is meant to be used from the boot GRUB menu, but can be also starte
if c.Bool("reboot") {
options["reboot"] = "true"
}
return agent.ManualInstall(config, options, c.Bool("strict-validation"), c.Bool("debug"))
return agent.ManualInstall(config, options, c.Bool("strict-validation"))
},
},
{
@ -434,7 +434,7 @@ See also https://kairos.io/docs/installation/qrcode/ for documentation.
This command is meant to be used from the boot GRUB menu, but can be started manually`,
Aliases: []string{"i"},
Action: func(c *cli.Context) error {
return agent.Install(c.Bool("debug"), configScanDir...)
return agent.Install(configScanDir...)
},
},
{
@ -650,7 +650,11 @@ The kairos agent is a component to abstract away node ops, providing a common fe
`,
UsageText: ``,
Copyright: "kairos authors",
Before: func(c *cli.Context) error {
// Set debug from here already, so it's loaded by the ReadConfigRun
viper.Set("debug", c.Bool("debug"))
return nil
},
Commands: cmds,
}