refactor: use vars for cred flags

This commit is contained in:
David Allen 2025-03-24 14:29:47 -06:00
parent d1042d77aa
commit 5c4ca34976
Signed by: towk
GPG key ID: 0430CDBE22619155
2 changed files with 6 additions and 5 deletions

View file

@ -40,8 +40,8 @@ var CrawlCmd = &cobra.Command{
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
store = &secrets.StaticStore{ store = &secrets.StaticStore{
Username: viper.GetString("crawl.username"), Username: username,
Password: viper.GetString("crawl.password"), Password: password,
} }
} }
systems, err := crawler.CrawlBMCForSystems(crawler.CrawlerConfig{ systems, err := crawler.CrawlBMCForSystems(crawler.CrawlerConfig{
@ -65,9 +65,9 @@ var CrawlCmd = &cobra.Command{
} }
func init() { func init() {
CrawlCmd.Flags().StringP("username", "u", "", "Set the username for the BMC") CrawlCmd.Flags().StringVarP(&username, "username", "u", "", "Set the username for the BMC")
CrawlCmd.Flags().StringP("password", "p", "", "Set the password for the BMC") CrawlCmd.Flags().StringVarP(&password, "password", "p", "", "Set the password for the BMC")
CrawlCmd.Flags().BoolP("insecure", "i", false, "Ignore SSL errors") CrawlCmd.Flags().BoolVarP(&insecure, "insecure", "i", false, "Ignore SSL errors")
CrawlCmd.Flags().StringVarP(&secretsFile, "file", "f", "nodes.json", "set the secrets file with BMC credentials") CrawlCmd.Flags().StringVarP(&secretsFile, "file", "f", "nodes.json", "set the secrets file with BMC credentials")
checkBindFlagError(viper.BindPFlag("crawl.username", CrawlCmd.Flags().Lookup("username"))) checkBindFlagError(viper.BindPFlag("crawl.username", CrawlCmd.Flags().Lookup("username")))

View file

@ -44,6 +44,7 @@ var (
verbose bool verbose bool
debug bool debug bool
forceUpdate bool forceUpdate bool
insecure bool
) )
// The `root` command doesn't do anything on it's own except display // The `root` command doesn't do anything on it's own except display