mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
chore: miscellaneous updates
This commit is contained in:
parent
a9492c70f6
commit
86fcf54b6e
4 changed files with 18 additions and 12 deletions
|
|
@ -50,12 +50,21 @@ var CollectCmd = &cobra.Command{
|
||||||
// try to load access token either from env var, file, or config if var not set
|
// try to load access token either from env var, file, or config if var not set
|
||||||
if accessToken == "" {
|
if accessToken == "" {
|
||||||
var err error
|
var err error
|
||||||
accessToken, err = auth.LoadAccessToken(tokenPath)
|
accessToken, err = auth.LoadAccessToken(accessTokenPath)
|
||||||
if err != nil && verbose {
|
if err != nil && verbose {
|
||||||
log.Warn().Err(err).Msgf("could not load access token")
|
log.Warn().Err(err).Msgf("could not load access token")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// try to load session token either from env var, file, or config if var is not set
|
||||||
|
if sessionToken == "" {
|
||||||
|
var err error
|
||||||
|
sessionToken, err = auth.LoadSessionToken(accessTokenPath)
|
||||||
|
if err != nil && verbose {
|
||||||
|
log.Warn().Err(err).Msgf("could not load session token")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set the minimum/maximum number of concurrent processes
|
// set the minimum/maximum number of concurrent processes
|
||||||
if concurrency <= 0 {
|
if concurrency <= 0 {
|
||||||
concurrency = mathutil.Clamp(len(scannedResults), 1, 10000)
|
concurrency = mathutil.Clamp(len(scannedResults), 1, 10000)
|
||||||
|
|
@ -145,6 +154,7 @@ func init() {
|
||||||
CollectCmd.Flags().StringVarP(&username, "username", "u", "", "Set the master BMC username")
|
CollectCmd.Flags().StringVarP(&username, "username", "u", "", "Set the master BMC username")
|
||||||
CollectCmd.Flags().StringVarP(&password, "password", "p", "", "Set the master BMC password")
|
CollectCmd.Flags().StringVarP(&password, "password", "p", "", "Set the master BMC password")
|
||||||
CollectCmd.Flags().StringVar(&secretsFile, "secrets-file", "", "Set path to the node secrets file")
|
CollectCmd.Flags().StringVar(&secretsFile, "secrets-file", "", "Set path to the node secrets file")
|
||||||
|
CollectCmd.Flags().StringVar(&sessionToken, "session-token", "", "Set the session token to use for auth")
|
||||||
CollectCmd.Flags().StringVar(&scheme, "scheme", "https", "Set the default scheme used to query when not included in URI")
|
CollectCmd.Flags().StringVar(&scheme, "scheme", "https", "Set the default scheme used to query when not included in URI")
|
||||||
CollectCmd.Flags().StringVar(&protocol, "protocol", "tcp", "Set the protocol used to query")
|
CollectCmd.Flags().StringVar(&protocol, "protocol", "tcp", "Set the protocol used to query")
|
||||||
CollectCmd.Flags().StringVarP(&outputPath, "output-file", "o", "", "Set the path to store collection data using HIVE partitioning")
|
CollectCmd.Flags().StringVarP(&outputPath, "output-file", "o", "", "Set the path to store collection data using HIVE partitioning")
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
|
"os/user"
|
||||||
|
|
||||||
magellan "github.com/davidallendj/magellan/internal"
|
magellan "github.com/davidallendj/magellan/internal"
|
||||||
"github.com/davidallendj/magellan/internal/util"
|
"github.com/davidallendj/magellan/internal/util"
|
||||||
|
|
@ -36,6 +37,7 @@ const (
|
||||||
|
|
||||||
// CLI arguments as variables to not fiddle with error-prone strings
|
// CLI arguments as variables to not fiddle with error-prone strings
|
||||||
var (
|
var (
|
||||||
|
currentUser *user.User
|
||||||
accessToken string
|
accessToken string
|
||||||
timeout int
|
timeout int
|
||||||
concurrency int
|
concurrency int
|
||||||
|
|
@ -193,3 +195,7 @@ func initSecretsStore(uri string) secrets.SecretStore {
|
||||||
}
|
}
|
||||||
return store
|
return store
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func validSecretArgs(masterKey string, secretsFile string) bool {
|
||||||
|
return masterKey != "" && secretsFile != ""
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,5 @@ func PrintYAML(data any) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Msgf("failed to marshal scanned results to JSON")
|
log.Error().Err(err).Msgf("failed to marshal scanned results to JSON")
|
||||||
}
|
}
|
||||||
fmt.Printf("%s\n", string(b))
|
fmt.Print(string(b))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
package util
|
|
||||||
|
|
||||||
import "strings"
|
|
||||||
|
|
||||||
func TidyJSON(s string) string {
|
|
||||||
s = strings.ReplaceAll(s, "\n", "")
|
|
||||||
s = strings.ReplaceAll(s, "\t", "")
|
|
||||||
s = strings.ReplaceAll(s, " ", "")
|
|
||||||
return strings.ReplaceAll(s, "\"", "'")
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue