chore: updated error/warn messages to be more informative

This commit is contained in:
David Allen 2025-04-14 14:11:00 -06:00 committed by David Allen
parent 3074e7323a
commit ee99d6e06d
Signed by: towk
GPG key ID: 0430CDBE22619155
2 changed files with 8 additions and 3 deletions

View file

@ -43,7 +43,7 @@ var CrawlCmd = &cobra.Command{
// try and load credentials from local store first
store, err = secrets.OpenStore(secretsFile)
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
store = secrets.NewStaticStore(username, password)
}
@ -51,12 +51,15 @@ var CrawlCmd = &cobra.Command{
// found the store so try to load the creds
_, err = store.GetSecretByID(uri)
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 username != "" && password != "" {
// finally, use the CLI arguments passed instead
log.Info().Msg("...using provided arguments for credentials")
store = secrets.NewStaticStore(username, password)
} else {
// try and get a default *stored* username/password
log.Info().Msg("...using default stored secrets for credentials")
secret, err := store.GetSecretByID(secrets.DEFAULT_KEY)
if err != nil {
// no default found, so use CLI arguments