@@ -58,11 +58,17 @@ pub const S3_ASSUME_ROLE_ARN: &str = "client.assume-role.arn";
5858pub const S3_ASSUME_ROLE_EXTERNAL_ID : & str = "client.assume-role.external-id" ;
5959/// Optional session name used to assume an IAM role.
6060pub const S3_ASSUME_ROLE_SESSION_NAME : & str = "client.assume-role.session-name" ;
61- /// Option to skip signing request (e.g. for public buckets/folders)
61+ /// Option to skip signing requests (e.g. for public buckets/folders).
6262pub const S3_ALLOW_ANONYMOUS : & str = "s3.allow-anonymous" ;
6363/// Option to skip loading the credential from EC2 metadata (typically used in conjunction with
64- /// `S3_ALLOW_ANONYMOUS`)
64+ /// `S3_ALLOW_ANONYMOUS`).
6565pub const S3_DISABLE_EC2_METADATA : & str = "s3.disable-ec2-metadata" ;
66+ /// Option to skip loading configuration from config file and the env.
67+ pub const S3_DISABLE_CONFIG_LOAD : & str = "s3.disable-config-load" ;
68+
69+ fn is_truthy ( value : & str ) -> bool {
70+ [ "true" , "t" , "1" , "on" ] . contains ( & value)
71+ }
6672
6773/// Parse iceberg props to s3 config.
6874pub ( crate ) fn s3_config_parse ( mut m : HashMap < String , String > ) -> Result < S3Config > {
@@ -86,7 +92,7 @@ pub(crate) fn s3_config_parse(mut m: HashMap<String, String>) -> Result<S3Config
8692 cfg. region = Some ( region) ;
8793 } ;
8894 if let Some ( path_style_access) = m. remove ( S3_PATH_STYLE_ACCESS ) {
89- if [ "true" , "t" , "1" ] . contains ( & path_style_access. to_lowercase ( ) . as_str ( ) ) {
95+ if is_truthy ( & path_style_access. to_lowercase ( ) . as_str ( ) ) {
9096 cfg. enable_virtual_host_style = true ;
9197 }
9298 } ;
@@ -132,15 +138,20 @@ pub(crate) fn s3_config_parse(mut m: HashMap<String, String>) -> Result<S3Config
132138 } ;
133139
134140 if let Some ( allow_anonymous) = m. remove ( S3_ALLOW_ANONYMOUS ) {
135- if [ "true" , "t" , "1" , "on" ] . contains ( & allow_anonymous. to_lowercase ( ) . as_str ( ) ) {
141+ if is_truthy ( & allow_anonymous. to_lowercase ( ) . as_str ( ) ) {
136142 cfg. allow_anonymous = true ;
137143 }
138144 }
139145 if let Some ( disable_ec2_metadata) = m. remove ( S3_DISABLE_EC2_METADATA ) {
140- if [ "true" , "t" , "1" , "on" ] . contains ( & disable_ec2_metadata. to_lowercase ( ) . as_str ( ) ) {
146+ if is_truthy ( & disable_ec2_metadata. to_lowercase ( ) . as_str ( ) ) {
141147 cfg. disable_ec2_metadata = true ;
142148 }
143149 } ;
150+ if let Some ( disable_config_load) = m. remove ( S3_DISABLE_CONFIG_LOAD ) {
151+ if is_truthy ( & disable_config_load. to_lowercase ( ) . as_str ( ) ) {
152+ cfg. disable_config_load = true ;
153+ }
154+ } ;
144155
145156 Ok ( cfg)
146157}
0 commit comments