@@ -22,6 +22,7 @@ use opendal::services::GcsConfig;
22
22
use opendal:: Operator ;
23
23
use url:: Url ;
24
24
25
+ use crate :: io:: is_truthy;
25
26
use crate :: { Error , ErrorKind , Result } ;
26
27
27
28
// 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";
41
42
/// Google Cloud Storage token
42
43
pub const GCS_TOKEN : & str = "gcs.oauth2.token" ;
43
44
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
+
44
52
/// Parse iceberg properties to [`GcsConfig`].
45
53
pub ( crate ) fn gcs_config_parse ( mut m : HashMap < String , String > ) -> Result < GcsConfig > {
46
54
let mut cfg = GcsConfig :: default ( ) ;
@@ -63,6 +71,22 @@ pub(crate) fn gcs_config_parse(mut m: HashMap<String, String>) -> Result<GcsConf
63
71
cfg. disable_config_load = true ;
64
72
}
65
73
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
+
66
90
Ok ( cfg)
67
91
}
68
92
0 commit comments