Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence logs generated by aws-vault on the AWS shell plugin #297

Merged
merged 5 commits into from
Jun 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions plugins/aws/sts_provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package aws
import (
"context"
"fmt"
"io"
"log"
"os"
"time"

Expand Down Expand Up @@ -54,7 +56,7 @@ func (p STSProvisioner) Provision(ctx context.Context, in sdk.ProvisionInput, ou
return
}

awsConfig, err := getAWSAuthConfigurationForProfile(profile)
awsConfig, err := ExecuteSilently(getAWSAuthConfigurationForProfile)(profile)
if err != nil {
out.AddError(err)
return
Expand All @@ -67,7 +69,7 @@ func (p STSProvisioner) Provision(ctx context.Context, in sdk.ProvisionInput, ou
return
}

tempCredentials, err := tempCredentialsProvider.Retrieve(ctx)
tempCredentials, err := ExecuteSilently(tempCredentialsProvider.Retrieve)(ctx)
if err != nil {
out.AddError(err)
return
Expand Down Expand Up @@ -389,3 +391,11 @@ func DetectSourceProfileLoop(profile string, config *confighelpers.ConfigFile) e

return nil
}

func ExecuteSilently[input interface{}, output interface{}, e error](f func(input) (output, e)) func(input) (output, e) {
return func(i input) (output, e) {
log.SetOutput(io.Discard)
defer log.SetOutput(os.Stderr)
return f(i)
}
}