Skip to content

Commit

Permalink
fix: use correct aws_endpoint key
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ion-elgreco authored and rtyler committed Dec 21, 2024
1 parent 2272ff7 commit cdc6473
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions crates/aws/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down Expand Up @@ -819,9 +821,15 @@ mod tests {
let options = StorageOptions::from(minio);
assert!(!is_aws(&options));

let minio: HashMap<String, String> = hashmap! {
"aws_endpoint".to_string() => "http://minio:8080".to_string(),
};
let options = StorageOptions::from(minio);
assert!(!is_aws(&options));

let localstack: HashMap<String, String> = 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));
Expand Down

0 comments on commit cdc6473

Please sign in to comment.