Skip to content

Commit

Permalink
feat(auth): Return failure message when an explicit config and/or `…
Browse files Browse the repository at this point in the history
…profile` are passed rather than attempt env and default config auth.

Signed-off-by: spbsoluble <[email protected]>
  • Loading branch information
spbsoluble committed Dec 12, 2024
1 parent 0059b2d commit cffa17d
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,10 @@ func initClient(saveConfig bool) (*api.Client, error) {
Str("providerProfile", providerProfile).
Msg("enter: initClient()")
var (
c *api.Client
envCfgErr error
cfgErr error
c *api.Client
envCfgErr error
cfgErr error
explicitCfgErr error
)

if providerType != "" {
Expand All @@ -572,14 +573,20 @@ func initClient(saveConfig bool) (*api.Client, error) {
Str("configFile", configFile).
Str("profile", profile).
Msg("authenticating via config file")
c, cfgErr = authViaConfigFile(configFile, profile)
if cfgErr == nil {
c, explicitCfgErr = authViaConfigFile(configFile, profile)
if explicitCfgErr == nil {
log.Info().
Str("configFile", configFile).
Str("profile", profile).
Msgf("Authenticated via config file %s using profile %s", configFile, profile)
return c, nil
}
log.Error().
Err(explicitCfgErr).
Str("configFile", configFile).
Str("profile", profile).
Msg("unable to authenticate using explicit config file and/or profile")
return nil, explicitCfgErr
}

log.Info().Msg("authenticating via environment variables")
Expand Down

0 comments on commit cffa17d

Please sign in to comment.