mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Fixed root persistent flags not binding correctly
This commit is contained in:
parent
809aa91ec6
commit
7285492815
3 changed files with 12 additions and 9 deletions
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/OpenCHAMI/magellan/pkg/crawler"
|
"github.com/OpenCHAMI/magellan/pkg/crawler"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The `crawl` command walks a collection of Redfish endpoints to collect
|
// The `crawl` command walks a collection of Redfish endpoints to collect
|
||||||
|
|
@ -66,5 +67,9 @@ func init() {
|
||||||
crawlCmd.Flags().StringP("password", "p", "", "Set the password for the BMC")
|
crawlCmd.Flags().StringP("password", "p", "", "Set the password for the BMC")
|
||||||
crawlCmd.Flags().BoolP("insecure", "i", false, "Ignore SSL errors")
|
crawlCmd.Flags().BoolP("insecure", "i", false, "Ignore SSL errors")
|
||||||
|
|
||||||
|
viper.BindPFlag("crawl.username", crawlCmd.Flags().Lookup("username"))
|
||||||
|
viper.BindPFlag("crawl.password", crawlCmd.Flags().Lookup("password"))
|
||||||
|
viper.BindPFlag("crawl.insecure", crawlCmd.Flags().Lookup("insecure"))
|
||||||
|
|
||||||
rootCmd.AddCommand(crawlCmd)
|
rootCmd.AddCommand(crawlCmd)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
13
cmd/root.go
13
cmd/root.go
|
|
@ -83,13 +83,12 @@ func init() {
|
||||||
rootCmd.PersistentFlags().StringVar(&cachePath, "cache", fmt.Sprintf("/tmp/%s/magellan/assets.db", currentUser.Username), "set the scanning result cache path")
|
rootCmd.PersistentFlags().StringVar(&cachePath, "cache", fmt.Sprintf("/tmp/%s/magellan/assets.db", currentUser.Username), "set the scanning result cache path")
|
||||||
|
|
||||||
// bind viper config flags with cobra
|
// bind viper config flags with cobra
|
||||||
checkBindFlagError(viper.BindPFlag("concurrency", rootCmd.Flags().Lookup("concurrency")))
|
checkBindFlagError(viper.BindPFlag("concurrency", rootCmd.PersistentFlags().Lookup("concurrency")))
|
||||||
checkBindFlagError(viper.BindPFlag("timeout", rootCmd.Flags().Lookup("timeout")))
|
checkBindFlagError(viper.BindPFlag("timeout", rootCmd.PersistentFlags().Lookup("timeout")))
|
||||||
checkBindFlagError(viper.BindPFlag("verbose", rootCmd.Flags().Lookup("verbose")))
|
checkBindFlagError(viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose")))
|
||||||
checkBindFlagError(viper.BindPFlag("debug", rootCmd.Flags().Lookup("debug")))
|
checkBindFlagError(viper.BindPFlag("debug", rootCmd.PersistentFlags().Lookup("debug")))
|
||||||
checkBindFlagError(viper.BindPFlag("access-token", rootCmd.Flags().Lookup("verbose")))
|
checkBindFlagError(viper.BindPFlag("access-token", rootCmd.PersistentFlags().Lookup("verbose")))
|
||||||
checkBindFlagError(viper.BindPFlag("cache", rootCmd.Flags().Lookup("cache")))
|
checkBindFlagError(viper.BindPFlag("cache", rootCmd.PersistentFlags().Lookup("cache")))
|
||||||
checkBindFlagError(viper.BindPFlags(rootCmd.Flags()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkBindFlagError(err error) {
|
func checkBindFlagError(err error) {
|
||||||
|
|
|
||||||
|
|
@ -88,8 +88,7 @@ func init() {
|
||||||
|
|
||||||
checkBindFlagError(viper.BindPFlag("update.username", updateCmd.Flags().Lookup("username")))
|
checkBindFlagError(viper.BindPFlag("update.username", updateCmd.Flags().Lookup("username")))
|
||||||
checkBindFlagError(viper.BindPFlag("update.password", updateCmd.Flags().Lookup("password")))
|
checkBindFlagError(viper.BindPFlag("update.password", updateCmd.Flags().Lookup("password")))
|
||||||
checkBindFlagError(viper.BindPFlag("update.transfer-protocol", updateCmd.Flags().Lookup("transfer-protocol")))
|
checkBindFlagError(viper.BindPFlag("update.scheme", updateCmd.Flags().Lookup("scheme")))
|
||||||
checkBindFlagError(viper.BindPFlag("update.protocol", updateCmd.Flags().Lookup("protocol")))
|
|
||||||
checkBindFlagError(viper.BindPFlag("update.firmware.url", updateCmd.Flags().Lookup("firmware.url")))
|
checkBindFlagError(viper.BindPFlag("update.firmware.url", updateCmd.Flags().Lookup("firmware.url")))
|
||||||
checkBindFlagError(viper.BindPFlag("update.firmware.version", updateCmd.Flags().Lookup("firmware.version")))
|
checkBindFlagError(viper.BindPFlag("update.firmware.version", updateCmd.Flags().Lookup("firmware.version")))
|
||||||
checkBindFlagError(viper.BindPFlag("update.component", updateCmd.Flags().Lookup("component")))
|
checkBindFlagError(viper.BindPFlag("update.component", updateCmd.Flags().Lookup("component")))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue