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

AwsAdapter > Enable LogDebugWithRequestErrors when debug mode is enabled #323

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
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
11 changes: 6 additions & 5 deletions aws/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,11 @@ var (
}
)

var configProvider = defaultConfigProvider

func defaultConfigProvider() client.ConfigProvider {
func newConfigProvider(debug bool) client.ConfigProvider {
cfg := aws.NewConfig().WithMaxRetries(3)
if debug {
cfg = cfg.WithLogLevel(aws.LogDebugWithRequestErrors)
}
cfg = cfg.WithHTTPClient(instrumented_http.NewClient(cfg.HTTPClient, nil))
opts := session.Options{
SharedConfigState: session.SharedConfigEnable,
Expand All @@ -165,8 +166,8 @@ func defaultConfigProvider() client.ConfigProvider {
// Before returning there is a discovery process for VPC and EC2 details. It tries to find the Auto Scaling Group and
// Security Group that should be used for newly created Load Balancers. If any of those critical steps fail
// an appropriate error is returned.
func NewAdapter(newControllerID string) (adapter *Adapter, err error) {
p := configProvider()
func NewAdapter(newControllerID string, debug bool) (adapter *Adapter, err error) {
p := newConfigProvider(debug)
adapter = &Adapter{
ec2: ec2.New(p),
elbv2: elbv2.New(p),
Expand Down
2 changes: 1 addition & 1 deletion controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func main() {
os.Exit(0)
}

awsAdapter, err = aws.NewAdapter(controllerID)
awsAdapter, err = aws.NewAdapter(controllerID, debugFlag)
if err != nil {
log.Fatal(err)
}
Expand Down