Skip to content

Commit

Permalink
AwsAdapter > Enable LogDebugWithRequestErrors when debug mode is en…
Browse files Browse the repository at this point in the history
…abled

Signed-off-by: Ruud Kamphuis <[email protected]>
  • Loading branch information
ruudk committed Mar 28, 2020
1 parent df00edd commit bda8ae1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
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

0 comments on commit bda8ae1

Please sign in to comment.