@@ -22,6 +22,7 @@ use opendal::services::GcsConfig;
2222use opendal:: Operator ;
2323use url:: Url ;
2424
25+ use crate :: io:: is_truthy;
2526use crate :: { Error , ErrorKind , Result } ;
2627
2728// Reference: https://github.com/apache/iceberg/blob/main/gcp/src/main/java/org/apache/iceberg/gcp/GCPProperties.java
@@ -41,6 +42,13 @@ pub const GCS_CREDENTIALS_JSON: &str = "gcs.credentials-json";
4142/// Google Cloud Storage token
4243pub const GCS_TOKEN : & str = "gcs.oauth2.token" ;
4344
45+ /// Option to skip signing requests (e.g. for public buckets/folders).
46+ pub const GCS_ALLOW_ANONYMOUS : & str = "gcs.allow-anonymous" ;
47+ /// Option to skip loading the credential from GCE metadata server (typically used in conjunction with `GCS_ALLOW_ANONYMOUS`).
48+ pub const GCS_DISABLE_VM_METADATA : & str = "gcs.disable-vm-metadata" ;
49+ /// Option to skip loading configuration from config file and the env.
50+ pub const GCS_DISABLE_CONFIG_LOAD : & str = "gcs.disable-config-load" ;
51+
4452/// Parse iceberg properties to [`GcsConfig`].
4553pub ( crate ) fn gcs_config_parse ( mut m : HashMap < String , String > ) -> Result < GcsConfig > {
4654 let mut cfg = GcsConfig :: default ( ) ;
@@ -63,6 +71,22 @@ pub(crate) fn gcs_config_parse(mut m: HashMap<String, String>) -> Result<GcsConf
6371 cfg. disable_config_load = true ;
6472 }
6573
74+ if let Some ( allow_anonymous) = m. remove ( GCS_ALLOW_ANONYMOUS ) {
75+ if is_truthy ( allow_anonymous. to_lowercase ( ) . as_str ( ) ) {
76+ cfg. allow_anonymous = true ;
77+ }
78+ }
79+ if let Some ( disable_ec2_metadata) = m. remove ( GCS_DISABLE_VM_METADATA ) {
80+ if is_truthy ( disable_ec2_metadata. to_lowercase ( ) . as_str ( ) ) {
81+ cfg. disable_vm_metadata = true ;
82+ }
83+ } ;
84+ if let Some ( disable_config_load) = m. remove ( GCS_DISABLE_CONFIG_LOAD ) {
85+ if is_truthy ( disable_config_load. to_lowercase ( ) . as_str ( ) ) {
86+ cfg. disable_config_load = true ;
87+ }
88+ } ;
89+
6690 Ok ( cfg)
6791}
6892
0 commit comments