Skip to content

Commit

Permalink
Merge pull request #297 from 1Password/arun/aws-silence-logs
Browse files Browse the repository at this point in the history
Silence logs generated by aws-vault on the AWS shell plugin
  • Loading branch information
AndyTitu committed Jun 26, 2023
2 parents cd89b26 + 9a43fdc commit 509b723
Showing 1 changed file with 12 additions and 2 deletions.
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)
}
}

0 comments on commit 509b723

Please sign in to comment.