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 {
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")))