Skip to content

Commit

Permalink
feat(object storage): add is_https_endpoint for minio (#12517)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcy-fdu authored Oct 7, 2023
1 parent 04f33a1 commit 01c7c2b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/object_store/src/object/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,16 @@ impl S3ObjectStore {
pub async fn with_minio(server: &str, metrics: Arc<ObjectStoreMetrics>) -> Self {
let server = server.strip_prefix("minio://").unwrap();
let (access_key_id, rest) = server.split_once(':').unwrap();
let (secret_access_key, rest) = rest.split_once('@').unwrap();
let (secret_access_key, mut rest) = rest.split_once('@').unwrap();
let endpoint_prefix = if let Some(rest_stripped) = rest.strip_prefix("https://") {
rest = rest_stripped;
"https://"
} else if let Some(rest_stripped) = rest.strip_prefix("http://") {
rest = rest_stripped;
"http://"
} else {
"http://"
};
let (address, bucket) = rest.split_once('/').unwrap();

#[cfg(madsim)]
Expand All @@ -626,10 +635,9 @@ impl S3ObjectStore {
aws_sdk_s3::config::Builder::from(&aws_config::ConfigLoader::default().load().await)
.force_path_style(true)
.http_connector(Self::new_http_connector(&S3ObjectStoreConfig::default()));

let config = builder
.region(Region::new("custom"))
.endpoint_url(format!("http://{}", address))
.endpoint_url(format!("{}{}", endpoint_prefix, address))
.credentials_provider(Credentials::from_keys(
access_key_id,
secret_access_key,
Expand Down

0 comments on commit 01c7c2b

Please sign in to comment.