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

Remove DebugLogging parameter from awsbase.Config and always enable logging #97

Merged
merged 1 commit into from
Feb 2, 2022
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
9 changes: 2 additions & 7 deletions aws_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ func commonLoadOptions(c *Config) ([]func(*config.LoadOptions) error, error) {
config.WithRegion(c.Region),
config.WithHTTPClient(httpClient),
config.WithAPIOptions(apiOptions),
config.WithClientLogMode(aws.LogRequestWithBody | aws.LogResponseWithBody | aws.LogRetries),
config.WithLogger(debugLogger{}),
}

if len(c.SharedConfigFiles) > 0 {
Expand All @@ -168,13 +170,6 @@ func commonLoadOptions(c *Config) ([]func(*config.LoadOptions) error, error) {
)
}

if c.DebugLogging {
loadOptions = append(loadOptions,
config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponseWithBody|aws.LogRetries),
config.WithLogger(debugLogger{}),
)
}

if c.EC2MetadataServiceEndpoint != "" {
loadOptions = append(loadOptions,
config.WithEC2IMDSEndpoint(c.EC2MetadataServiceEndpoint),
Expand Down
6 changes: 2 additions & 4 deletions aws_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,9 +757,8 @@ region = us-east-1
RoleARN: servicemocks.MockStsAssumeRoleArn,
SessionName: servicemocks.MockStsAssumeRoleSessionName,
},
DebugLogging: true,
Region: "us-east-1",
SecretKey: servicemocks.MockStaticSecretKey,
Region: "us-east-1",
SecretKey: servicemocks.MockStaticSecretKey,
},
Description: "assume role error",
ExpectedError: func(err error) bool {
Expand Down Expand Up @@ -2004,7 +2003,6 @@ func TestRetryHandlers(t *testing.T) {
MaxRetries: maxRetries,
SecretKey: servicemocks.MockStaticSecretKey,
SkipCredsValidation: true,
DebugLogging: true,
}
awsConfig, err := GetAwsConfig(context.Background(), config)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ type Config struct {
AssumeRole *AssumeRole
CallerDocumentationURL string
CallerName string
DebugLogging bool
EC2MetadataServiceEndpoint string
EC2MetadataServiceEndpointMode string
HTTPProxy string
Expand Down
8 changes: 2 additions & 6 deletions v2/awsv1shim/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,15 @@ func getSessionOptions(awsC *awsv2.Config, c *awsbase.Config) (*session.Options,
creds.SessionToken,
),
HTTPClient: httpClient,
LogLevel: aws.LogLevel(aws.LogDebugWithHTTPBody | aws.LogDebugWithRequestRetries | aws.LogDebugWithRequestErrors),
Logger: debugLogger{},
MaxRetries: aws.Int(0),
Region: aws.String(awsC.Region),
UseFIPSEndpoint: convertFIPSEndpointState(useFIPSEndpoint),
UseDualStackEndpoint: convertDualStackEndpointState(useDualStackEndpoint),
},
}

// This needs its own debug logger. Don't reuse or wrap the AWS SDK for Go v2 logger, since it hardcodes the string "aws-sdk-go-v2"
if c.DebugLogging {
options.Config.LogLevel = aws.LogLevel(aws.LogDebugWithHTTPBody | aws.LogDebugWithRequestRetries | aws.LogDebugWithRequestErrors)
options.Config.Logger = debugLogger{}
}

return options, nil
}

Expand Down
7 changes: 3 additions & 4 deletions v2/awsv1shim/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestGetSessionOptions(t *testing.T) {
false,
},
{"ConfigWithCredsAndOptions",
&awsbase.Config{AccessKey: "MockAccessKey", SecretKey: "MockSecretKey", Insecure: true, DebugLogging: true},
&awsbase.Config{AccessKey: "MockAccessKey", SecretKey: "MockSecretKey", Insecure: true},
false,
},
}
Expand Down Expand Up @@ -799,9 +799,8 @@ region = us-east-1
RoleARN: servicemocks.MockStsAssumeRoleArn,
SessionName: servicemocks.MockStsAssumeRoleSessionName,
},
DebugLogging: true,
Region: "us-east-1",
SecretKey: servicemocks.MockStaticSecretKey,
Region: "us-east-1",
SecretKey: servicemocks.MockStaticSecretKey,
},
Description: "assume role error",
ExpectedError: func(err error) bool {
Expand Down