This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git
The following commit(s) were added to refs/heads/main by this push:
new bc7aca7d1 chore: random code and comments tidy (#6808)
bc7aca7d1 is described below
commit bc7aca7d15b87d40609cf159736e620e2ac51f95
Author: tison <[email protected]>
AuthorDate: Thu Nov 20 23:55:11 2025 +0800
chore: random code and comments tidy (#6808)
Signed-off-by: tison <[email protected]>
---
core/src/services/s3/config.rs | 25 ++++++++++++++++++++-----
core/src/types/operator/registry.rs | 3 ++-
2 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/core/src/services/s3/config.rs b/core/src/services/s3/config.rs
index 43342e677..4ece9ab21 100644
--- a/core/src/services/s3/config.rs
+++ b/core/src/services/s3/config.rs
@@ -22,7 +22,8 @@ use serde::Serialize;
use super::backend::S3Builder;
-/// Config for Aws S3 and compatible services (including minio, digitalocean
space, Tencent Cloud Object Storage(COS) and so on) support.
+/// Config for Aws S3 and compatible services (including minio, digitalocean
space,
+/// Tencent Cloud Object Storage(COS) and so on) support.
#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
#[serde(default)]
#[non_exhaustive]
@@ -109,7 +110,7 @@ pub struct S3Config {
/// Disable load credential from ec2 metadata.
///
/// This option is used to disable the default behavior of opendal
- /// to load credential from ec2 metadata, a.k.a, IMDSv2
+ /// to load credential from ec2 metadata, a.k.a., IMDSv2
pub disable_ec2_metadata: bool,
/// Allow anonymous will allow opendal to send request without signing
/// when credential is not loaded.
@@ -202,7 +203,7 @@ pub struct S3Config {
pub checksum_algorithm: Option<String>,
/// Disable write with if match so that opendal will not send write
request with if match headers.
///
- /// For example, Ceph RADOS S3 doesn't support write with if match.
+ /// For example, Ceph RADOS S3 doesn't support write with if matched.
pub disable_write_with_if_match: bool,
/// Enable write with append so that opendal will send write request with
append headers.
@@ -258,6 +259,8 @@ impl crate::Configurator for S3Config {
#[cfg(test)]
mod tests {
+ use std::iter;
+
use super::*;
use crate::Configurator;
use crate::types::OperatorUri;
@@ -355,13 +358,25 @@ mod tests {
#[test]
fn from_uri_extracts_bucket_and_root() {
+ let uri = OperatorUri::new("s3://example-bucket/path/to/root",
iter::empty()).unwrap();
+ let cfg = S3Config::from_uri(&uri).unwrap();
+ assert_eq!(cfg.bucket, "example-bucket");
+ assert_eq!(cfg.root.as_deref(), Some("path/to/root"));
+ }
+
+ #[test]
+ fn from_uri_extracts_endpoint() {
let uri = OperatorUri::new(
- "s3://example-bucket/path/to/root",
- Vec::<(String, String)>::new(),
+
"s3://example-bucket/path/to/root?endpoint=https%3A%2F%2Fcustom-s3-endpoint.com",
+ iter::empty(),
)
.unwrap();
let cfg = S3Config::from_uri(&uri).unwrap();
assert_eq!(cfg.bucket, "example-bucket");
assert_eq!(cfg.root.as_deref(), Some("path/to/root"));
+ assert_eq!(
+ cfg.endpoint.as_deref(),
+ Some("https://custom-s3-endpoint.com")
+ );
}
}
diff --git a/core/src/types/operator/registry.rs
b/core/src/types/operator/registry.rs
index 1a4efb801..4aedc77d7 100644
--- a/core/src/types/operator/registry.rs
+++ b/core/src/types/operator/registry.rs
@@ -104,5 +104,6 @@ fn register_builtin_services(registry: &OperatorRegistry) {
/// Factory adapter that builds an operator from a configurator type.
fn factory<C: Configurator>(uri: &OperatorUri) -> Result<Operator> {
let cfg = C::from_uri(uri)?;
- Ok(Operator::from_config(cfg)?.finish())
+ let builder = Operator::from_config(cfg)?;
+ Ok(builder.finish())
}