Skip to content

Commit 1506644

Browse files
committed
fix(auth): Return failure message when an explicit config and/or profile are passed rather than attempt env and default config auth.
Signed-off-by: spbsoluble <1661003+spbsoluble@users.noreply.github.com>
1 parent 0059b2d commit 1506644

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

cmd/root.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,10 @@ func initClient(saveConfig bool) (*api.Client, error) {
553553
Str("providerProfile", providerProfile).
554554
Msg("enter: initClient()")
555555
var (
556-
c *api.Client
557-
envCfgErr error
558-
cfgErr error
556+
c *api.Client
557+
envCfgErr error
558+
cfgErr error
559+
explicitCfgErr error
559560
)
560561

561562
if providerType != "" {
@@ -572,14 +573,20 @@ func initClient(saveConfig bool) (*api.Client, error) {
572573
Str("configFile", configFile).
573574
Str("profile", profile).
574575
Msg("authenticating via config file")
575-
c, cfgErr = authViaConfigFile(configFile, profile)
576-
if cfgErr == nil {
576+
c, explicitCfgErr = authViaConfigFile(configFile, profile)
577+
if explicitCfgErr == nil {
577578
log.Info().
578579
Str("configFile", configFile).
579580
Str("profile", profile).
580581
Msgf("Authenticated via config file %s using profile %s", configFile, profile)
581582
return c, nil
582583
}
584+
log.Error().
585+
Err(explicitCfgErr).
586+
Str("configFile", configFile).
587+
Str("profile", profile).
588+
Msg("unable to authenticate using explicit config file and/or profile")
589+
return nil, explicitCfgErr // return explicit error
583590
}
584591

585592
log.Info().Msg("authenticating via environment variables")

0 commit comments

Comments
 (0)