Skip to content

Commit

Permalink
fix(tools): endpoint compatibility includes HTTP protocol (#891)
Browse files Browse the repository at this point in the history
Co-authored-by: KamiWan <[email protected]>
  • Loading branch information
funky-eyes and KaimingWan authored Mar 7, 2024
1 parent d17278e commit c5b6274
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ static class Parameter {
this.s3SecretKey = res.getString("s3-secret-key");
this.s3Region = res.getString("s3-region");
String endpointProtocolStr = res.get("s3-endpoint-protocol");
String currentEndpoint = res.getString("s3-endpoint");
if (currentEndpoint.startsWith("http://") || currentEndpoint.startsWith("https://")) {
this.s3Endpoint = currentEndpoint.replace("http://", "").replace("https://", "");
endpointProtocolStr = currentEndpoint.substring(0, currentEndpoint.indexOf("://"));
} else {
this.s3Endpoint = currentEndpoint;
}
this.endpointProtocol = EndpointProtocol.getByName(endpointProtocolStr);
this.s3Endpoint = res.getString("s3-endpoint");
this.s3DataBucket = res.getString("s3-data-bucket");
String s3OpsBucketFromArg = res.getString("s3-ops-bucket");
if (s3OpsBucketFromArg == null) {
Expand Down Expand Up @@ -144,10 +150,8 @@ public String run() {
System.out.println();

//precheck
String s3Endpoint = parameter.s3Endpoint;
var context = S3Utils.S3Context.builder().setEndpoint(
s3Endpoint.startsWith("https://") || s3Endpoint.startsWith("http://") ? s3Endpoint :
parameter.endpointProtocol.getName() + "://" + s3Endpoint)
var context = S3Utils.S3Context.builder()
.setEndpoint(parameter.endpointProtocol.getName() + "://" + parameter.s3Endpoint)
.setCredentialsProviders(List.of(() -> AwsBasicCredentials.create(parameter.s3AccessKey, parameter.s3SecretKey)))
.setBucketName(parameter.s3DataBucket)
.setRegion(parameter.s3Region)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static class Parameter {
final boolean controllerOnlyMode;

Parameter(Namespace res) {
this.s3Url = res.getString("s3-url");
this.s3Url = res.getString("s3-url").replace("http://", "").replace("https://", "");
this.brokerList = res.getString("broker-list");
this.controllerList = res.getString("controller-list");
this.networkBaselineBandwidthMB = res.getString("network-baseline-bandwidth-mb");
Expand Down

0 comments on commit c5b6274

Please sign in to comment.