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 8347d2fe6 feat(services/gcs): add configuration aliases for better
Arrow object_store compatibility (#6526)
8347d2fe6 is described below
commit 8347d2fe617a75680cb90e47730d62d856dc5f69
Author: Jack Ye <[email protected]>
AuthorDate: Mon Aug 25 10:26:12 2025 -0700
feat(services/gcs): add configuration aliases for better Arrow object_store
compatibility (#6526)
* feat(services/gcs): add configuration aliases for better Arrow
object_store compatibility
This PR adds serde aliases to GcsConfig fields to support multiple
configuration key naming conventions, enabling seamless migration from Arrow
object_store and other file system libraries. Users can now use either
OpenDAL's native field names or Google-prefixed alternatives.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* fix: apply code formatting for GCS config aliases
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
* refactor: split GCS config alias tests into individual test functions
- Split large test_config_aliases into 5 focused test functions
- Each test function covers aliases for a specific config field
- Added missing google_service_account_path alias test
- Improved test organization and readability
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
---------
Co-authored-by: Claude <[email protected]>
---
core/src/services/gcs/config.rs | 97 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
diff --git a/core/src/services/gcs/config.rs b/core/src/services/gcs/config.rs
index 43ff15175..3e440e493 100644
--- a/core/src/services/gcs/config.rs
+++ b/core/src/services/gcs/config.rs
@@ -29,6 +29,11 @@ pub struct GcsConfig {
/// root URI, all operations happens under `root`
pub root: Option<String>,
/// bucket name
+ #[serde(
+ alias = "google_bucket",
+ alias = "google_bucket_name",
+ alias = "bucket_name"
+ )]
pub bucket: String,
/// endpoint URI of GCS service,
/// default is `https://storage.googleapis.com`
@@ -36,10 +41,17 @@ pub struct GcsConfig {
/// Scope for gcs.
pub scope: Option<String>,
/// Service Account for gcs.
+ #[serde(
+ alias = "google_service_account",
+ alias = "google_service_account_path",
+ alias = "service_account_path"
+ )]
pub service_account: Option<String>,
/// Credentials string for GCS service OAuth2 authentication.
+ #[serde(alias = "google_service_account_key", alias =
"service_account_key")]
pub credential: Option<String>,
/// Local path to credentials file for GCS service OAuth2 authentication.
+ #[serde(alias = "google_application_credentials")]
pub credential_path: Option<String>,
/// The predefined acl for GCS.
pub predefined_acl: Option<String>,
@@ -47,6 +59,7 @@ pub struct GcsConfig {
pub default_storage_class: Option<String>,
/// Allow opendal to send requests without signing when credentials are not
/// loaded.
+ #[serde(alias = "google_skip_signature", alias = "skip_signature")]
pub allow_anonymous: bool,
/// Disable attempting to load credentials from the GCE metadata server
when
/// running within Google Cloud.
@@ -69,3 +82,87 @@ impl Debug for GcsConfig {
.finish_non_exhaustive()
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_bucket_aliases() {
+ // Test google_bucket alias
+ let config_json = r#"{"google_bucket": "test-bucket"}"#;
+ let config: GcsConfig = serde_json::from_str(config_json).unwrap();
+ assert_eq!("test-bucket", config.bucket);
+
+ // Test google_bucket_name alias
+ let config_json = r#"{"google_bucket_name": "test-bucket-name"}"#;
+ let config: GcsConfig = serde_json::from_str(config_json).unwrap();
+ assert_eq!("test-bucket-name", config.bucket);
+
+ // Test bucket_name alias
+ let config_json = r#"{"bucket_name": "test-bucket-alias"}"#;
+ let config: GcsConfig = serde_json::from_str(config_json).unwrap();
+ assert_eq!("test-bucket-alias", config.bucket);
+ }
+
+ #[test]
+ fn test_service_account_aliases() {
+ // Test google_service_account alias
+ let config_json = r#"{"google_service_account": "/path/to/sa.json"}"#;
+ let config: GcsConfig = serde_json::from_str(config_json).unwrap();
+ assert_eq!(Some("/path/to/sa.json".to_string()),
config.service_account);
+
+ // Test google_service_account_path alias
+ let config_json = r#"{"google_service_account_path":
"/path/to/sa2.json"}"#;
+ let config: GcsConfig = serde_json::from_str(config_json).unwrap();
+ assert_eq!(
+ Some("/path/to/sa2.json".to_string()),
+ config.service_account
+ );
+
+ // Test service_account_path alias
+ let config_json = r#"{"service_account_path": "/path/to/sa3.json"}"#;
+ let config: GcsConfig = serde_json::from_str(config_json).unwrap();
+ assert_eq!(
+ Some("/path/to/sa3.json".to_string()),
+ config.service_account
+ );
+ }
+
+ #[test]
+ fn test_credential_aliases() {
+ // Test google_service_account_key alias
+ let config_json = r#"{"google_service_account_key": "key-content"}"#;
+ let config: GcsConfig = serde_json::from_str(config_json).unwrap();
+ assert_eq!(Some("key-content".to_string()), config.credential);
+
+ // Test service_account_key alias
+ let config_json = r#"{"service_account_key": "key-content-2"}"#;
+ let config: GcsConfig = serde_json::from_str(config_json).unwrap();
+ assert_eq!(Some("key-content-2".to_string()), config.credential);
+ }
+
+ #[test]
+ fn test_credential_path_aliases() {
+ // Test google_application_credentials alias
+ let config_json = r#"{"google_application_credentials":
"/path/to/app.json"}"#;
+ let config: GcsConfig = serde_json::from_str(config_json).unwrap();
+ assert_eq!(
+ Some("/path/to/app.json".to_string()),
+ config.credential_path
+ );
+ }
+
+ #[test]
+ fn test_allow_anonymous_aliases() {
+ // Test google_skip_signature alias
+ let config_json = r#"{"google_skip_signature": true}"#;
+ let config: GcsConfig = serde_json::from_str(config_json).unwrap();
+ assert!(config.allow_anonymous);
+
+ // Test skip_signature alias
+ let config_json = r#"{"skip_signature": true}"#;
+ let config: GcsConfig = serde_json::from_str(config_json).unwrap();
+ assert!(config.allow_anonymous);
+ }
+}