From cdc64737831880f2ccf7bcb4786d9944cc898c25 Mon Sep 17 00:00:00 2001 From: Ion Koutsouris <15728914+ion-elgreco@users.noreply.github.com> Date: Fri, 20 Dec 2024 15:12:03 +0100 Subject: [PATCH] fix: use correct aws_endpoint key is_aws() should be executing after with_env_s3 which downcases the parameters, but this is a bit more defensive in checking the presence of both aws_endpoint and the uppercase constant Signed-off-by: R. Tyler Croy --- crates/aws/src/storage.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/aws/src/storage.rs b/crates/aws/src/storage.rs index 019071a60f..84d5533f82 100644 --- a/crates/aws/src/storage.rs +++ b/crates/aws/src/storage.rs @@ -142,7 +142,9 @@ fn is_aws(options: &StorageOptions) -> bool { if options.0.contains_key(constants::AWS_S3_LOCKING_PROVIDER) { return true; } - !options.0.contains_key(constants::AWS_ENDPOINT_URL) + // Options at this stage should only contain 'aws_endpoint' in lowercase + // due to with_env_s3 + !(options.0.contains_key("aws_endpoint") || options.0.contains_key(constants::AWS_ENDPOINT_URL)) } /// Options used to configure the [S3StorageBackend]. @@ -819,9 +821,15 @@ mod tests { let options = StorageOptions::from(minio); assert!(!is_aws(&options)); + let minio: HashMap = hashmap! { + "aws_endpoint".to_string() => "http://minio:8080".to_string(), + }; + let options = StorageOptions::from(minio); + assert!(!is_aws(&options)); + let localstack: HashMap = hashmap! { constants::AWS_FORCE_CREDENTIAL_LOAD.to_string() => "true".to_string(), - constants::AWS_ENDPOINT_URL.to_string() => "http://minio:8080".to_string(), + "aws_endpoint".to_string() => "http://minio:8080".to_string(), }; let options = StorageOptions::from(localstack); assert!(is_aws(&options));