From 60770dadc0ea99dac8da2b868e7e6c9ae09c926e Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Wed, 8 May 2024 12:48:02 -0600 Subject: [PATCH] Removed GET request in collect and minor changes --- cmd/collect.go | 10 +++++----- cmd/root.go | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/collect.go b/cmd/collect.go index a9c831d..5cb4edf 100644 --- a/cmd/collect.go +++ b/cmd/collect.go @@ -63,10 +63,10 @@ var collectCmd = &cobra.Command{ } magellan.CollectAll(&probeStates, l, q) - // confirm the inventories were added - err = smd.GetRedfishEndpoints() - if err != nil { - l.Log.Errorf("could not get redfish endpoints: %v", err) + // add necessary headers for final request (like token) + headers := make(map[string]string) + if q.AccessToken != "" { + headers["Authorization"] = "Bearer " + q.AccessToken } }, } @@ -77,7 +77,7 @@ func init() { collectCmd.PersistentFlags().IntVarP(&smd.Port, "port", "p", smd.Port, "set the port to the smd API") collectCmd.PersistentFlags().StringVar(&user, "user", "", "set the BMC user") collectCmd.PersistentFlags().StringVar(&pass, "pass", "", "set the BMC password") - collectCmd.PersistentFlags().StringVar(&protocol, "protocol", "https", "set the Redfish protocol") + collectCmd.PersistentFlags().StringVar(&protocol, "protocol", "https", "set the protocol used to query") collectCmd.PersistentFlags().StringVarP(&outputPath, "output", "o", "/tmp/magellan/data/", "set the path to store collection data") collectCmd.PersistentFlags().BoolVar(&forceUpdate, "force-update", false, "set flag to force update data sent to SMD ") collectCmd.PersistentFlags().StringVar(&preferredDriver, "preferred-driver", "ipmi", "set the preferred driver to use") diff --git a/cmd/root.go b/cmd/root.go index 2223ea1..5d14761 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -56,7 +56,7 @@ func Execute() { func LoadAccessToken() (string, error) { // try to load token from env var - testToken := os.Getenv("OCHAMI_ACCESS_TOKEN") + testToken := os.Getenv("MAGELLAN_ACCESS_TOKEN") if testToken != "" { return testToken, nil } @@ -80,7 +80,7 @@ func init() { rootCmd.PersistentFlags().IntVar(&threads, "threads", -1, "set the number of threads") rootCmd.PersistentFlags().IntVar(&timeout, "timeout", 30, "set the timeout") rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", "", "set the config file path") - rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", true, "set verbose flag") + rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "set verbose flag") rootCmd.PersistentFlags().StringVar(&accessToken, "access-token", "", "set the access token") rootCmd.PersistentFlags().StringVar(&dbpath, "db.path", "/tmp/magellan/magellan.db", "set the probe storage path") @@ -103,7 +103,7 @@ func SetDefaults() { viper.SetDefault("threads", 1) viper.SetDefault("timeout", 30) viper.SetDefault("config", "") - viper.SetDefault("verbose", true) + viper.SetDefault("verbose", false) viper.SetDefault("db.path", "/tmp/magellan/magellan.db") viper.SetDefault("scan.hosts", []string{}) viper.SetDefault("scan.ports", []int{})