Skip to content

Commit

Permalink
Added log_level option to aws cli login
Browse files Browse the repository at this point in the history
Used to setup the logger for use in GenerateCredentialChain()
  • Loading branch information
tvoran committed Sep 16, 2020
1 parent 98adda6 commit 2271d6c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
17 changes: 16 additions & 1 deletion builtin/credential/aws/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,18 @@ func (h *CLIHandler) Auth(c *api.Client, m map[string]string) (*api.Secret, erro
headerValue = ""
}

creds, err := RetrieveCreds(m["aws_access_key_id"], m["aws_secret_access_key"], m["aws_security_token"], hclog.Default())
logVal, ok := m["log_level"]
if !ok {
logVal = "info"
}
level := hclog.LevelFromString(logVal)
if level == hclog.NoLevel {
return nil, fmt.Errorf("failed to parse 'log_level' value: %q", logVal)
}
hlogger := hclog.Default()
hlogger.SetLevel(level)

creds, err := RetrieveCreds(m["aws_access_key_id"], m["aws_secret_access_key"], m["aws_security_token"], hlogger)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -196,6 +207,10 @@ Configuration:
role=<string>
Name of the role to request a token against
log_level=<string>
Set logging level during AWS credential acquisition. Valid levels are
trace, debug, info, warn, error. Defaults to info.
`

return strings.TrimSpace(help)
Expand Down
2 changes: 1 addition & 1 deletion sdk/helper/awsutil/generate_credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type CredentialsConfig struct {
// Make sure the logger isn't nil before logging
func (c *CredentialsConfig) log(level hclog.Level, msg string, args ...interface{}) {
if c.Logger != nil {
c.Logger.Log(level, msg, args)
c.Logger.Log(level, msg, args...)
}
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2271d6c

Please sign in to comment.