From 5c4ca3497640368e2b2e68d97b062a5a4207b092 Mon Sep 17 00:00:00 2001 From: David Allen Date: Mon, 24 Mar 2025 14:29:47 -0600 Subject: [PATCH] refactor: use vars for cred flags --- cmd/crawl.go | 10 +++++----- cmd/root.go | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/crawl.go b/cmd/crawl.go index 12203eb..db9821c 100644 --- a/cmd/crawl.go +++ b/cmd/crawl.go @@ -40,8 +40,8 @@ var CrawlCmd = &cobra.Command{ if err != nil { fmt.Println(err) store = &secrets.StaticStore{ - Username: viper.GetString("crawl.username"), - Password: viper.GetString("crawl.password"), + Username: username, + Password: password, } } systems, err := crawler.CrawlBMCForSystems(crawler.CrawlerConfig{ @@ -65,9 +65,9 @@ var CrawlCmd = &cobra.Command{ } func init() { - CrawlCmd.Flags().StringP("username", "u", "", "Set the username 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().StringVarP(&username, "username", "u", "", "Set the username for the BMC") + CrawlCmd.Flags().StringVarP(&password, "password", "p", "", "Set the password for the BMC") + 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") checkBindFlagError(viper.BindPFlag("crawl.username", CrawlCmd.Flags().Lookup("username"))) diff --git a/cmd/root.go b/cmd/root.go index 778e37f..4e713fe 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -44,6 +44,7 @@ var ( verbose bool debug bool forceUpdate bool + insecure bool ) // The `root` command doesn't do anything on it's own except display