Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Aug 22, 2024
1 parent 5b55921 commit f1685eb
Show file tree
Hide file tree
Showing 128 changed files with 2,008 additions and 2,231 deletions.
2 changes: 0 additions & 2 deletions core/src/services/aliyun_drive/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ use http::Request;
use http::Response;
use http::StatusCode;
use log::debug;
use serde::Deserialize;
use serde::Serialize;
use tokio::sync::Mutex;

use super::core::*;
Expand Down
2 changes: 0 additions & 2 deletions core/src/services/alluxio/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ use std::sync::Arc;

use http::Response;
use log::debug;
use serde::Deserialize;
use serde::Serialize;

use super::core::AlluxioCore;
use super::error::parse_error;
Expand Down
70 changes: 3 additions & 67 deletions core/src/services/azblob/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ use log::debug;
use reqsign::AzureStorageConfig;
use reqsign::AzureStorageLoader;
use reqsign::AzureStorageSigner;
use serde::Deserialize;
use serde::Serialize;
use sha2::Digest;
use sha2::Sha256;

Expand All @@ -41,6 +39,7 @@ use super::writer::AzblobWriter;
use crate::raw::*;
use crate::services::azblob::core::AzblobCore;
use crate::services::azblob::writer::AzblobWriters;
use crate::services::AzblobConfig;
use crate::*;

/// Known endpoint suffix Azure Storage Blob services resource URI syntax.
Expand All @@ -55,69 +54,6 @@ const KNOWN_AZBLOB_ENDPOINT_SUFFIX: &[&str] = &[

const AZBLOB_BATCH_LIMIT: usize = 256;

/// Azure Storage Blob services support.
#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct AzblobConfig {
/// The root of Azblob service backend.
///
/// All operations will happen under this root.
pub root: Option<String>,

/// The container name of Azblob service backend.
pub container: String,

/// The endpoint of Azblob service backend.
///
/// Endpoint must be full uri, e.g.
///
/// - Azblob: `https://accountname.blob.core.windows.net`
/// - Azurite: `http://127.0.0.1:10000/devstoreaccount1`
pub endpoint: Option<String>,

/// The account name of Azblob service backend.
pub account_name: Option<String>,

/// The account key of Azblob service backend.
pub account_key: Option<String>,

/// The encryption key of Azblob service backend.
pub encryption_key: Option<String>,

/// The encryption key sha256 of Azblob service backend.
pub encryption_key_sha256: Option<String>,

/// The encryption algorithm of Azblob service backend.
pub encryption_algorithm: Option<String>,

/// The sas token of Azblob service backend.
pub sas_token: Option<String>,

/// The maximum batch operations of Azblob service backend.
pub batch_max_operations: Option<usize>,
}

impl Debug for AzblobConfig {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut ds = f.debug_struct("AzblobConfig");

ds.field("root", &self.root);
ds.field("container", &self.container);
ds.field("endpoint", &self.endpoint);

if self.account_name.is_some() {
ds.field("account_name", &"<redacted>");
}
if self.account_key.is_some() {
ds.field("account_key", &"<redacted>");
}
if self.sas_token.is_some() {
ds.field("sas_token", &"<redacted>");
}

ds.finish()
}
}

impl Configurator for AzblobConfig {
type Builder = AzblobBuilder;
fn into_builder(self) -> Self::Builder {
Expand Down Expand Up @@ -838,7 +774,7 @@ TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;
SharedAccessSignature=sv=2021-01-01&ss=b&srt=c&sp=rwdlaciytfx&se=2022-01-01T11:00:14Z&st=2022-01-02T03:00:14Z&spr=https&sig=KEllk4N8f7rJfLjQCmikL2fRVt%2B%2Bl73UBkbgH%2FK3VGE%3D
"#,
)
.expect("from connection string must succeed");
.expect("from connection string must succeed");

assert_eq!(
builder.config.endpoint.unwrap(),
Expand All @@ -859,7 +795,7 @@ AccountKey=account-key;
SharedAccessSignature=sv=2021-01-01&ss=b&srt=c&sp=rwdlaciytfx&se=2022-01-01T11:00:14Z&st=2022-01-02T03:00:14Z&spr=https&sig=KEllk4N8f7rJfLjQCmikL2fRVt%2B%2Bl73UBkbgH%2FK3VGE%3D
"#,
)
.expect("from connection string must succeed");
.expect("from connection string must succeed");

// SAS should be preferred over shared key
assert_eq!(builder.config.sas_token.unwrap(), "sv=2021-01-01&ss=b&srt=c&sp=rwdlaciytfx&se=2022-01-01T11:00:14Z&st=2022-01-02T03:00:14Z&spr=https&sig=KEllk4N8f7rJfLjQCmikL2fRVt%2B%2Bl73UBkbgH%2FK3VGE%3D");
Expand Down
1 change: 0 additions & 1 deletion core/src/services/azblob/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

mod backend;
pub use backend::AzblobBuilder as Azblob;
pub use backend::AzblobConfig;

mod core;
mod error;
Expand Down
37 changes: 1 addition & 36 deletions core/src/services/azdls/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ use log::debug;
use reqsign::AzureStorageConfig;
use reqsign::AzureStorageLoader;
use reqsign::AzureStorageSigner;
use serde::Deserialize;
use serde::Serialize;

use super::core::AzdlsCore;
use super::error::parse_error;
use super::lister::AzdlsLister;
use super::writer::AzdlsWriter;
use super::writer::AzdlsWriters;
use crate::raw::*;
use crate::services::AzdlsConfig;
use crate::*;

/// Known endpoint suffix Azure Data Lake Storage Gen2 URI syntax.
Expand All @@ -46,40 +45,6 @@ const KNOWN_AZDLS_ENDPOINT_SUFFIX: &[&str] = &[
"dfs.core.chinacloudapi.cn",
];

/// Azure Data Lake Storage Gen2 Support.
#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct AzdlsConfig {
/// Root of this backend.
pub root: Option<String>,
/// Filesystem name of this backend.
pub filesystem: String,
/// Endpoint of this backend.
pub endpoint: Option<String>,
/// Account name of this backend.
pub account_name: Option<String>,
/// Account key of this backend.
pub account_key: Option<String>,
}

impl Debug for AzdlsConfig {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut ds = f.debug_struct("AzdlsConfig");

ds.field("root", &self.root);
ds.field("filesystem", &self.filesystem);
ds.field("endpoint", &self.endpoint);

if self.account_name.is_some() {
ds.field("account_name", &"<redacted>");
}
if self.account_key.is_some() {
ds.field("account_key", &"<redacted>");
}

ds.finish()
}
}

impl Configurator for AzdlsConfig {
type Builder = AzdlsBuilder;
fn into_builder(self) -> Self::Builder {
Expand Down
1 change: 0 additions & 1 deletion core/src/services/azdls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

mod backend;
pub use backend::AzdlsBuilder as Azdls;
pub use backend::AzdlsConfig;

mod core;
mod error;
Expand Down
42 changes: 1 addition & 41 deletions core/src/services/azfile/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,59 +25,19 @@ use log::debug;
use reqsign::AzureStorageConfig;
use reqsign::AzureStorageLoader;
use reqsign::AzureStorageSigner;
use serde::Deserialize;
use serde::Serialize;

use super::core::AzfileCore;
use super::error::parse_error;
use super::writer::AzfileWriter;
use super::writer::AzfileWriters;
use crate::raw::*;
use crate::services::azfile::lister::AzfileLister;
use crate::services::AzfileConfig;
use crate::*;

/// Default endpoint of Azure File services.
const DEFAULT_AZFILE_ENDPOINT_SUFFIX: &str = "file.core.windows.net";

/// Azure File services support.
#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct AzfileConfig {
/// The root path for azfile.
pub root: Option<String>,
/// The endpoint for azfile.
pub endpoint: Option<String>,
/// The share name for azfile.
pub share_name: String,
/// The account name for azfile.
pub account_name: Option<String>,
/// The account key for azfile.
pub account_key: Option<String>,
/// The sas token for azfile.
pub sas_token: Option<String>,
}

impl Debug for AzfileConfig {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut ds = f.debug_struct("AzfileConfig");

ds.field("root", &self.root);
ds.field("share_name", &self.share_name);
ds.field("endpoint", &self.endpoint);

if self.account_name.is_some() {
ds.field("account_name", &"<redacted>");
}
if self.account_key.is_some() {
ds.field("account_key", &"<redacted>");
}
if self.sas_token.is_some() {
ds.field("sas_token", &"<redacted>");
}

ds.finish()
}
}

impl Configurator for AzfileConfig {
type Builder = AzfileBuilder;
fn into_builder(self) -> Self::Builder {
Expand Down
1 change: 0 additions & 1 deletion core/src/services/azfile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// under the License.

pub use backend::AzfileBuilder as Azfile;
pub use backend::AzfileConfig;

mod backend;
mod core;
Expand Down
45 changes: 1 addition & 44 deletions core/src/services/b2/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use http::Request;
use http::Response;
use http::StatusCode;
use log::debug;
use serde::Deserialize;
use serde::Serialize;
use tokio::sync::RwLock;

use super::core::constants;
Expand All @@ -38,50 +36,9 @@ use super::writer::B2Writers;
use crate::raw::*;
use crate::services::b2::core::B2Signer;
use crate::services::b2::core::ListFileNamesResponse;
use crate::services::B2Config;
use crate::*;

/// Config for backblaze b2 services support.
#[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
#[serde(default)]
#[non_exhaustive]
pub struct B2Config {
/// root of this backend.
///
/// All operations will happen under this root.
pub root: Option<String>,
/// keyID of this backend.
///
/// - If application_key_id is set, we will take user's input first.
/// - If not, we will try to load it from environment.
pub application_key_id: Option<String>,
/// applicationKey of this backend.
///
/// - If application_key is set, we will take user's input first.
/// - If not, we will try to load it from environment.
pub application_key: Option<String>,
/// bucket of this backend.
///
/// required.
pub bucket: String,
/// bucket id of this backend.
///
/// required.
pub bucket_id: String,
}

impl Debug for B2Config {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut d = f.debug_struct("B2Config");

d.field("root", &self.root)
.field("application_key_id", &self.application_key_id)
.field("bucket_id", &self.bucket_id)
.field("bucket", &self.bucket);

d.finish_non_exhaustive()
}
}

impl Configurator for B2Config {
type Builder = B2Builder;
fn into_builder(self) -> Self::Builder {
Expand Down
1 change: 0 additions & 1 deletion core/src/services/b2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

mod backend;
pub use backend::B2Builder as B2;
pub use backend::B2Config;

mod core;
mod error;
Expand Down
10 changes: 1 addition & 9 deletions core/src/services/cacache/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,16 @@ use std::fmt::Formatter;
use std::str;

use cacache;
use serde::Deserialize;
use serde::Serialize;

use crate::raw::adapters::kv;
use crate::raw::Access;
use crate::services::CacacheConfig;
use crate::Builder;
use crate::Error;
use crate::ErrorKind;
use crate::Scheme;
use crate::*;

/// cacache service support.
#[derive(Default, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub struct CacacheConfig {
/// That path to the cacache data directory.
pub datadir: Option<String>,
}

impl Configurator for CacacheConfig {
type Builder = CacacheBuilder;
fn into_builder(self) -> Self::Builder {
Expand Down
1 change: 0 additions & 1 deletion core/src/services/cacache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@
mod backend;

pub use backend::CacacheBuilder as Cacache;
pub use backend::CacacheConfig;
Loading

0 comments on commit f1685eb

Please sign in to comment.