Fixed root persistent flags not binding correctly

This commit is contained in:
David Allen 2024-08-13 14:44:11 -06:00
parent 809aa91ec6
commit 7285492815
No known key found for this signature in database
GPG key ID: 717C593FF60A2ACC
3 changed files with 12 additions and 9 deletions

View file

@ -9,6 +9,7 @@ import (
"github.com/OpenCHAMI/magellan/pkg/crawler"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// 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().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)
}