Commit
+13 -6 +/-1 browse
1 | diff --git a/src/storage/s3.rs b/src/storage/s3.rs |
2 | index f659d82..cda5908 100644 |
3 | --- a/src/storage/s3.rs |
4 | +++ b/src/storage/s3.rs |
5 | @@ -23,14 +23,14 @@ use bytes::Bytes; |
6 | use derive_more::{Display, From}; |
7 | use futures::{stream, stream::TryStreamExt}; |
8 | use http::StatusCode; |
9 | - use rusoto_core::{Region, HttpClient, RusotoError}; |
10 | - use rusoto_credential::{CredentialsError, AutoRefreshingProvider, ProvideAwsCredentials}; |
11 | - use rusoto_sts::WebIdentityProvider; |
12 | + use rusoto_core::{HttpClient, Region, RusotoError}; |
13 | + use rusoto_credential::{AutoRefreshingProvider, ProvideAwsCredentials}; |
14 | use rusoto_s3::{ |
15 | GetObjectError, GetObjectRequest, HeadBucketError, HeadBucketRequest, |
16 | HeadObjectError, HeadObjectRequest, PutObjectError, PutObjectRequest, |
17 | S3Client, StreamingBody, S3, |
18 | }; |
19 | + use rusoto_sts::WebIdentityProvider; |
20 | |
21 | use super::{LFSObject, Storage, StorageKey, StorageStream}; |
22 | |
23 | @@ -46,7 +46,9 @@ pub enum Error { |
24 | /// The uploaded object is too large. |
25 | TooLarge(u64), |
26 | |
27 | - From(CredentialsError), |
28 | + Tls(rusoto_core::request::TlsError), |
29 | + |
30 | + Credentials(rusoto_credential::CredentialsError), |
31 | } |
32 | |
33 | impl ::std::error::Error for Error {} |
34 | @@ -149,10 +151,15 @@ impl Backend { |
35 | region.name() |
36 | ); |
37 | |
38 | + // Check if there is any k8s credential provider. If there is, use it. |
39 | let k8s_provider = WebIdentityProvider::from_k8s_env(); |
40 | - let client: S3Client = if let Ok(_) = k8s_provider.credentials().await { |
41 | + let client = if k8s_provider.credentials().await.is_ok() { |
42 | log::info!("Using credentials from Kubernetes"); |
43 | - S3Client::new_with(HttpClient::new().unwrap(), AutoRefreshingProvider::new(k8s_provider)?, region) |
44 | + S3Client::new_with( |
45 | + HttpClient::new()?, |
46 | + AutoRefreshingProvider::new(k8s_provider)?, |
47 | + region, |
48 | + ) |
49 | } else { |
50 | S3Client::new(region) |
51 | }; |