Replace rusoto

This commit is contained in:
Adrian Woźniak 2023-04-02 22:41:40 +02:00
parent 5f1d9c1f4d
commit 2aea60ecf2
4 changed files with 25 additions and 208 deletions

204
Cargo.lock generated
View File

@ -589,11 +589,10 @@ dependencies = [
name = "bitque-config"
version = "0.1.0"
dependencies = [
"rusoto_core",
"rusoto_s3",
"rusoto_signature",
"rust-s3",
"serde",
"toml",
"tracing",
]
[[package]]
@ -622,15 +621,6 @@ dependencies = [
"tui",
]
[[package]]
name = "block-buffer"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
dependencies = [
"generic-array",
]
[[package]]
name = "block-buffer"
version = "0.10.4"
@ -776,14 +766,10 @@ dependencies = [
"aws-creds",
"bitque-config",
"bytes",
"futures",
"libc",
"rust-s3",
"serde",
"thiserror",
"tokio",
"tracing",
"uuid 1.3.0",
]
[[package]]
@ -944,16 +930,6 @@ dependencies = [
"typenum",
]
[[package]]
name = "crypto-mac"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714"
dependencies = [
"generic-array",
"subtle",
]
[[package]]
name = "cxx"
version = "1.0.94"
@ -1200,22 +1176,13 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "digest"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
dependencies = [
"generic-array",
]
[[package]]
name = "digest"
version = "0.10.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f"
dependencies = [
"block-buffer 0.10.4",
"block-buffer",
"crypto-common",
"subtle",
]
@ -1229,16 +1196,6 @@ dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
dependencies = [
"cfg-if",
"dirs-sys-next",
]
[[package]]
name = "dirs-sys"
version = "0.3.7"
@ -1250,17 +1207,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]]
name = "dlv-list"
version = "0.3.0"
@ -1682,23 +1628,13 @@ dependencies = [
"toml",
]
[[package]]
name = "hmac"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b"
dependencies = [
"crypto-mac",
"digest 0.9.0",
]
[[package]]
name = "hmac"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
dependencies = [
"digest 0.10.6",
"digest",
]
[[package]]
@ -2092,17 +2028,6 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "md-5"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15"
dependencies = [
"block-buffer 0.9.0",
"digest 0.9.0",
"opaque-debug",
]
[[package]]
name = "md5"
version = "0.7.0"
@ -2279,12 +2204,6 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "opaque-debug"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
[[package]]
name = "openssl"
version = "0.10.48"
@ -2809,88 +2728,6 @@ dependencies = [
"winreg",
]
[[package]]
name = "rusoto_core"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1db30db44ea73551326269adcf7a2169428a054f14faf9e1768f2163494f2fa2"
dependencies = [
"async-trait",
"base64 0.13.1",
"bytes",
"crc32fast",
"futures",
"http",
"hyper",
"hyper-tls",
"lazy_static",
"log",
"rusoto_credential",
"rusoto_signature",
"rustc_version",
"serde",
"serde_json",
"tokio",
"xml-rs",
]
[[package]]
name = "rusoto_credential"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee0a6c13db5aad6047b6a44ef023dbbc21a056b6dab5be3b79ce4283d5c02d05"
dependencies = [
"async-trait",
"chrono",
"dirs-next",
"futures",
"hyper",
"serde",
"serde_json",
"shlex",
"tokio",
"zeroize",
]
[[package]]
name = "rusoto_s3"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7aae4677183411f6b0b412d66194ef5403293917d66e70ab118f07cc24c5b14d"
dependencies = [
"async-trait",
"bytes",
"futures",
"rusoto_core",
"xml-rs",
]
[[package]]
name = "rusoto_signature"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5ae95491c8b4847931e291b151127eccd6ff8ca13f33603eb3d0035ecb05272"
dependencies = [
"base64 0.13.1",
"bytes",
"chrono",
"digest 0.9.0",
"futures",
"hex",
"hmac 0.11.0",
"http",
"hyper",
"log",
"md-5",
"percent-encoding",
"pin-project-lite",
"rusoto_credential",
"rustc_version",
"serde",
"sha2 0.9.9",
"tokio",
]
[[package]]
name = "rust-ini"
version = "0.18.0"
@ -2913,7 +2750,7 @@ dependencies = [
"base64 0.13.1",
"cfg-if",
"hex",
"hmac 0.12.1",
"hmac",
"http",
"log",
"maybe-async",
@ -2924,7 +2761,7 @@ dependencies = [
"serde",
"serde-xml-rs",
"serde_derive",
"sha2 0.10.6",
"sha2",
"thiserror",
"time 0.3.20",
"tokio",
@ -3155,7 +2992,7 @@ checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
dependencies = [
"cfg-if",
"cpufeatures",
"digest 0.10.6",
"digest",
]
[[package]]
@ -3164,19 +3001,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012"
[[package]]
name = "sha2"
version = "0.9.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800"
dependencies = [
"block-buffer 0.9.0",
"cfg-if",
"cpufeatures",
"digest 0.9.0",
"opaque-debug",
]
[[package]]
name = "sha2"
version = "0.10.6"
@ -3185,7 +3009,7 @@ checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0"
dependencies = [
"cfg-if",
"cpufeatures",
"digest 0.10.6",
"digest",
]
[[package]]
@ -3203,12 +3027,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]]
name = "shlex"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]]
name = "signal-hook"
version = "0.3.15"
@ -4262,12 +4080,6 @@ dependencies = [
"linked-hash-map",
]
[[package]]
name = "zeroize"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9"
[[package]]
name = "zstd"
version = "0.12.3+zstd.1.5.2"

View File

@ -13,7 +13,7 @@ name = "bitque_config"
path = "./src/lib.rs"
[features]
aws-s3 = ["rusoto_s3", "rusoto_core", "rusoto_signature"]
aws-s3 = ["rust-s3"]
local-storage = []
database = []
hi = []
@ -23,8 +23,7 @@ websocket = []
default = ["local-storage", "database", "hi", "mail", "web", "websocket"]
[dependencies]
rusoto_core = { optional = true, version = "0.48.0" }
rusoto_s3 = { optional = true, version = "0.48.0" }
rusoto_signature = { optional = true, version = "0.48.0" }
serde = { version = "*" }
toml = { version = "*" }
rust-s3 = { version = "*", optional = true }
tracing = { version = "*" }

View File

@ -1,5 +1,8 @@
use rusoto_signature::Region;
use std::str::FromStr;
use s3::Region;
use serde::{Deserialize, Serialize};
use tracing::warn;
#[derive(Debug, Deserialize, Serialize)]
pub struct Configuration {
@ -18,7 +21,11 @@ impl Default for Configuration {
access_key_id: "".to_string(),
secret_access_key: "".to_string(),
bucket: "".to_string(),
region_name: Region::default().name().to_string(),
region_name: Region::Custom {
region: "http://localhost:9000".to_string(),
endpoint: "http://localhost:9000".to_string(),
}
.to_string(),
active: true,
concurrency: 2,
}
@ -35,7 +42,10 @@ impl Configuration {
}
pub fn region(&self) -> Region {
self.region_name.parse::<Region>().unwrap_or_default()
self.region_name.parse::<Region>().unwrap_or_else(|e| {
warn!("{e}");
Region::from_str("http://localhost:9000").expect("Parse S3 Region is infallible")
})
}
pub fn set_variables(&self) {

View File

@ -12,12 +12,8 @@ license = "MPL-2.0"
actix = { version = "0.13.0" }
bitque-config = { workspace = true, features = ["mail", "web", "local-storage"] }
bytes = { version = "1" }
futures = { version = "0.3.8" }
libc = { version = "0.2.0", default-features = false }
serde = { version = "*" }
tokio = { version = "1", features = ["full"] }
tracing = { version = "0.1.37" }
uuid = { version = "1.3.0", features = ["serde", "v4", "v5"] }
rust-s3 = { version = "*" }
aws-creds = { version = "=0.30.0" }
aws-creds = { version = "=0.30.0", features = ['attohttpc'] }
thiserror = { version = "*" }