Skip to content

Commit

Permalink
Address code review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
  • Loading branch information
reta committed Jun 2, 2022
1 parent b88d2a5 commit 3a841e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ private AmazonS3WithCredentials(final AmazonS3 client, @Nullable final AWSCreden
this.credentials = credentials;
}

AmazonS3 getClient() {
return client;
}

AWSCredentialsProvider getCredentials() {
return credentials;
}

AmazonS3 client() {
return client;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public Socket createSocket(final HttpContext ctx) throws IOException {

// pkg private for tests
static AWSCredentialsProvider buildCredentials(Logger logger, S3ClientSettings clientSettings) {
final S3BasicCredentials credentials = clientSettings.credentials;
final S3BasicCredentials basicCredentials = clientSettings.credentials;
final IrsaCredentials irsaCredentials = buildFromEnviroment(clientSettings.irsaCredentials);

// If IAM Roles for Service Accounts (IRSA) credentials are configured, start with them first
Expand All @@ -280,10 +280,10 @@ static AWSCredentialsProvider buildCredentials(Logger logger, S3ClientSettings c

AWSSecurityTokenService securityTokenService = null;
final String region = Strings.hasLength(clientSettings.region) ? clientSettings.region : null;
if (region != null || credentials != null) {
if (region != null || basicCredentials != null) {
securityTokenService = SocketAccess.doPrivileged(
() -> AWSSecurityTokenServiceClientBuilder.standard()
.withCredentials((credentials != null) ? new AWSStaticCredentialsProvider(credentials) : null)
.withCredentials((basicCredentials != null) ? new AWSStaticCredentialsProvider(basicCredentials) : null)
.withRegion(region)
.build()
);
Expand All @@ -306,9 +306,9 @@ static AWSCredentialsProvider buildCredentials(Logger logger, S3ClientSettings c
).withStsClient(securityTokenService).build()
);
}
} else if (credentials != null) {
} else if (basicCredentials != null) {
logger.debug("Using basic key/secret credentials");
return new AWSStaticCredentialsProvider(credentials);
return new AWSStaticCredentialsProvider(basicCredentials);
} else {
logger.debug("Using instance profile credentials");
return new PrivilegedInstanceProfileCredentialsProvider();
Expand Down

0 comments on commit 3a841e0

Please sign in to comment.