mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
chore: updated error/warn messages to be more informative
This commit is contained in:
parent
522ddb985d
commit
b9213c5fae
2 changed files with 8 additions and 3 deletions
|
|
@ -95,15 +95,17 @@ var CollectCmd = &cobra.Command{
|
||||||
// if we have CLI flags set, then we want to override default stored creds
|
// if we have CLI flags set, then we want to override default stored creds
|
||||||
if username != "" && password != "" {
|
if username != "" && password != "" {
|
||||||
// finally, use the CLI arguments passed instead
|
// finally, use the CLI arguments passed instead
|
||||||
|
log.Info().Msg("...using provided arguments for credentials")
|
||||||
store = secrets.NewStaticStore(username, password)
|
store = secrets.NewStaticStore(username, password)
|
||||||
} else {
|
} else {
|
||||||
// try and get a default *stored* username/password
|
// try and get a default *stored* username/password
|
||||||
secret, err := store.GetSecretByID("default")
|
secret, err := store.GetSecretByID(secrets.DEFAULT_KEY)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// no default found, so use CLI arguments
|
// no default found, so use CLI arguments
|
||||||
log.Warn().Err(err).Msg("no default credentials found")
|
log.Warn().Err(err).Msg("failed to get default credentials...")
|
||||||
} else {
|
} else {
|
||||||
// found default values in local store so use them
|
// found default values in local store so use them
|
||||||
|
log.Info().Msg("...using default store for credentials")
|
||||||
var creds crawler.BMCUsernamePassword
|
var creds crawler.BMCUsernamePassword
|
||||||
err = json.Unmarshal([]byte(secret), &creds)
|
err = json.Unmarshal([]byte(secret), &creds)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ var CrawlCmd = &cobra.Command{
|
||||||
// try and load credentials from local store first
|
// try and load credentials from local store first
|
||||||
store, err = secrets.OpenStore(secretsFile)
|
store, err = secrets.OpenStore(secretsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn().Err(err).Msg("failed to open local store...falling back to default provided arguments")
|
log.Warn().Err(err).Msg("failed to open local store...falling back to provided arguments")
|
||||||
// try and use the `username` and `password` arguments instead
|
// try and use the `username` and `password` arguments instead
|
||||||
store = secrets.NewStaticStore(username, password)
|
store = secrets.NewStaticStore(username, password)
|
||||||
}
|
}
|
||||||
|
|
@ -51,12 +51,15 @@ var CrawlCmd = &cobra.Command{
|
||||||
// found the store so try to load the creds
|
// found the store so try to load the creds
|
||||||
_, err = store.GetSecretByID(uri)
|
_, err = store.GetSecretByID(uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Warn().Err(err).Msgf("failed to get secrets for '%s'...", uri)
|
||||||
// if we have CLI flags set, then we want to override default stored creds
|
// if we have CLI flags set, then we want to override default stored creds
|
||||||
if username != "" && password != "" {
|
if username != "" && password != "" {
|
||||||
// finally, use the CLI arguments passed instead
|
// finally, use the CLI arguments passed instead
|
||||||
|
log.Info().Msg("...using provided arguments for credentials")
|
||||||
store = secrets.NewStaticStore(username, password)
|
store = secrets.NewStaticStore(username, password)
|
||||||
} else {
|
} else {
|
||||||
// try and get a default *stored* username/password
|
// try and get a default *stored* username/password
|
||||||
|
log.Info().Msg("...using default stored secrets for credentials")
|
||||||
secret, err := store.GetSecretByID(secrets.DEFAULT_KEY)
|
secret, err := store.GetSecretByID(secrets.DEFAULT_KEY)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// no default found, so use CLI arguments
|
// no default found, so use CLI arguments
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue