Skip to content

Commit

Permalink
Merge pull request #3775 from Xuanwo/dal-s3
Browse files Browse the repository at this point in the history
dal2: Add s3 support layout
  • Loading branch information
databend-bot authored Jan 5, 2022
2 parents 25c0b77 + 0f902bc commit 7e3ddf3
Show file tree
Hide file tree
Showing 5 changed files with 512 additions and 31 deletions.
296 changes: 293 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions common/dal2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ async-compat = "0.2.1"
async-trait = "0.1.52"
bytes = "1"
futures = "0.3.19"
rusoto_core = "0.47.0"
rusoto_s3 = "0.47.0"
rusoto_credential = "0.47.0"
tokio = { version = "1.15.0", features = ["fs"] }
thiserror = "1"
aws-config = "0.3.0"
aws-types = {version = "0.3.0", features = ["hardcoded-credentials"]}
aws-sdk-s3 = "0.3.0"
aws-endpoint = "0.3.0"
http = "0.2.6"
aws-smithy-http = "0.33.1"
49 changes: 49 additions & 0 deletions common/dal2/src/credential.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2022 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[derive(Debug, Clone)]
pub enum Credential {
/// Basic refers to HTTP Basic Authentication.
Basic { username: String, password: String },
/// HMAC, also known as Access Key/Secret Key authentication.
///
/// ## NOTE
///
/// HMAC is just a common step of ak/sk authentication. And it's not the correct name for
/// this type of authentication. But it's widely used and no ambiguities with other types.
/// So we use it here to avoid using AkSk as a credential type.
HMAC {
access_key_id: String,
secret_access_key: String,
},
/// Token refers to static API token.
Token(String),
}

impl Credential {
pub fn basic(username: String, password: String) -> Credential {
Credential::Basic { username, password }
}

pub fn hmac(access_key_id: String, secret_access_key: String) -> Credential {
Credential::HMAC {
access_key_id,
secret_access_key,
}
}

pub fn token(token: String) -> Credential {
Credential::Token(token)
}
}
Loading

0 comments on commit 7e3ddf3

Please sign in to comment.