Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,10 @@ public abstract class BaseUploadMojo extends AbstractMojo {
)
private String fileUploaderType;

@Parameter(
property = "slimfast.s3.accessKey",
defaultValue = "${s3.access.key}",
required = true
)
@Parameter(property = "slimfast.s3.accessKey", defaultValue = "${s3.access.key}")
private String s3AccessKey;

@Parameter(
property = "slimfast.s3.secretKey",
defaultValue = "${s3.secret.key}",
required = true
)
@Parameter(property = "slimfast.s3.secretKey", defaultValue = "${s3.secret.key}")
private String s3SecretKey;

@Parameter(property = "slimfast.s3.region", defaultValue = "${s3.region}")
Expand Down Expand Up @@ -101,8 +93,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {

protected UploadConfiguration buildConfiguration(Path prefix) {
S3Configuration s3Configuration = new S3Configuration(
s3AccessKey,
s3SecretKey,
Optional.ofNullable(s3AccessKey),
Optional.ofNullable(s3SecretKey),
Optional.ofNullable(s3Region).map(Region::of),
Optional.of(20.0), // aws-sdk default is 10.0
Optional.empty() // aws-sdk default is 8mb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,10 @@ public class DownloadJarsMojo extends AbstractMojo {
)
private String fileDownloaderType;

@Parameter(
property = "slimfast.s3.accessKey",
defaultValue = "${s3.access.key}",
required = true
)
@Parameter(property = "slimfast.s3.accessKey", defaultValue = "${s3.access.key}")
private String s3AccessKey;

@Parameter(
property = "slimfast.s3.secretKey",
defaultValue = "${s3.secret.key}",
required = true
)
@Parameter(property = "slimfast.s3.secretKey", defaultValue = "${s3.secret.key}")
private String s3SecretKey;

@Parameter(property = "slimfast.s3.region", defaultValue = "${s3.region}")
Expand Down Expand Up @@ -79,8 +71,8 @@ private S3ArtifactWrapper readArtifactInfo() throws MojoFailureException {

private DownloadConfiguration buildConfiguration(String prefix) {
S3Configuration s3Configuration = new S3Configuration(
s3AccessKey,
s3SecretKey,
Optional.ofNullable(s3AccessKey),
Optional.ofNullable(s3SecretKey),
Optional.ofNullable(s3Region).map(Region::of),
Optional.of(20.0), // aws-sdk default is 10.0
Optional.empty() // aws-sdk default is 8mb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

public class S3Configuration {

private final String accessKey;
private final String secretKey;
private final Optional<String> accessKey;
private final Optional<String> secretKey;

private final Optional<Region> region;
private final Optional<Double> targetThroughputGbps;
private final Optional<Long> minPartSizeBytes;

public S3Configuration(
String accessKey,
String secretKey,
Optional<String> accessKey,
Optional<String> secretKey,
Optional<Region> region,
Optional<Double> targetThroughputGbps,
Optional<Long> minPartSizeBytes
Expand All @@ -26,11 +26,11 @@ public S3Configuration(
this.minPartSizeBytes = minPartSizeBytes;
}

public String getAccessKey() {
public Optional<String> getAccessKey() {
return accessKey;
}

public String getSecretKey() {
public Optional<String> getSecretKey() {
return secretKey;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.services.s3.S3AsyncClient;
import software.amazon.awssdk.services.s3.S3CrtAsyncClientBuilder;
Expand All @@ -15,13 +16,20 @@ private S3Factory() {
}

public static S3AsyncClient createS3AsyncClient(S3Configuration config) {
AwsCredentialsProvider credentialsProvider = null;
if (config.getAccessKey().isPresent() && config.getSecretKey().isPresent()) {
credentialsProvider =
StaticCredentialsProvider.create(
AwsBasicCredentials.create(
config.getAccessKey().get(),
config.getSecretKey().get()
)
);
}

S3CrtAsyncClientBuilder clientBuilder = S3AsyncClient
.crtBuilder()
.credentialsProvider(
StaticCredentialsProvider.create(
AwsBasicCredentials.create(config.getAccessKey(), config.getSecretKey())
)
);
.credentialsProvider(credentialsProvider);

config.getRegion().ifPresent(clientBuilder::region);
config.getTargetThroughputGbps().ifPresent(clientBuilder::targetThroughputInGbps);
Expand Down