Skip to content

Commit 6259202

Browse files
authored
Unify from_env behaviours (#652)
* parse_url_opts should match {S3,Azure,GCP}Builder::from_env * fix AmazonS3Builder::from_env documentation * fix parse_url_opts documentation * update test_url_http to ingest case insensitive data * fix sentence cut off
1 parent 66e640d commit 6259202

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/aws/builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ impl AmazonS3Builder {
546546
///
547547
/// All environment variables starting with `AWS_` will be evaluated.
548548
/// Names must match acceptable input to [`AmazonS3ConfigKey::from_str`].
549-
/// Only upper-case environment variables are accepted.
550549
///
551550
/// Some examples of variables extracted from environment:
552551
/// * `AWS_ACCESS_KEY_ID` -> access_key_id

src/parse.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ macro_rules! builder_opts {
144144
($builder:ty, $url:expr, $options:expr) => {{
145145
let builder = $options.into_iter().fold(
146146
<$builder>::new().with_url($url.to_string()),
147-
|builder, (key, value)| match key.as_ref().parse() {
147+
|builder, (key, value)| match key.as_ref().to_ascii_lowercase().parse() {
148148
Ok(k) => builder.with_config(k, value),
149149
Err(_) => builder,
150150
},
@@ -177,9 +177,7 @@ pub fn parse_url(url: &Url) -> Result<(Box<dyn ObjectStore>, Path), super::Error
177177
/// * `options`: A list of key-value pairs to pass to the [`ObjectStore`] builder.
178178
/// Note different object stores accept different configuration options, so
179179
/// the options that are read depends on the `url` value. One common pattern
180-
/// is to pass configuration information via process variables using
181-
/// [`std::env::vars`]. Keys must be lower-case and match the list of supported
182-
/// keys to apply successfully.
180+
/// is to pass configuration information via process variables using [`std::env::vars`].
183181
///
184182
/// Returns
185183
/// - An [`ObjectStore`] of the corresponding type
@@ -435,15 +433,19 @@ mod tests {
435433
server.push_fn(|r| {
436434
assert_eq!(r.uri().path(), "/foo/bar");
437435
assert_eq!(r.headers().get(USER_AGENT).unwrap(), "test_url");
438-
Response::new(String::new())
436+
Response::new(String::from("result"))
439437
});
440438

441439
let test = format!("{}/foo/bar", server.url());
442-
let opts = [("user_agent", "test_url"), ("allow_http", "true")];
440+
let opts = [("USER_AGENT", "test_url"), ("allow_http", "true")];
443441
let url = test.parse().unwrap();
444442
let (store, path) = parse_url_opts(&url, opts).unwrap();
445443
assert_eq!(path.as_ref(), "foo/bar");
446-
store.get(&path).await.unwrap();
444+
445+
let res = store.get(&path).await.unwrap();
446+
let body = res.bytes().await.unwrap();
447+
let body = str::from_utf8(&body).unwrap();
448+
assert_eq!(body, "result");
447449

448450
server.shutdown().await;
449451
}

0 commit comments

Comments
 (0)