Skip to content

Commit

Permalink
Bump Azalia commit & Nix hash, update remi crates to v0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
auguwu committed Oct 21, 2024
1 parent 9a4cf24 commit 8ffc1bd
Show file tree
Hide file tree
Showing 12 changed files with 128 additions and 79 deletions.
42 changes: 18 additions & 24 deletions Cargo.lock

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

11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ homepage = "https://charts.noelware.org"
license = "Apache-2.0"
publish = false
repository = "https://github.com/charted-dev/charted"
rust-version = "1.78"

[workspace.dependencies]
argon2 = "0.5.3"
Expand All @@ -47,10 +46,10 @@ diesel = { version = "2.2.4", features = ["postgres", "sqlite", "chrono"] }
eyre = "0.6.12"
multer = "3.1.0"
opentelemetry = "0.26.0"
remi = "0.8.0"
remi-azure = { version = "0.8.0", features = ["tracing"] }
remi-fs = { version = "0.8.0", features = ["tracing"] }
remi-s3 = { version = "0.8.0", features = ["tracing"] }
remi = "0.9.1"
remi-azure = { version = "0.9.1", features = ["tracing", "export-azure"] }
remi-fs = { version = "0.9.1", features = ["tracing"] }
remi-s3 = { version = "0.9.1", features = ["tracing", "export-crates"] }
schemars = "0.8.21"
semver = { version = "1.0.23", features = ["serde"] }
sentry = "0.34.0"
Expand All @@ -70,7 +69,7 @@ which = "6.0.3"
[workspace.dependencies.azalia]
version = "0.1.0"
git = "https://github.com/Noelware/azalia"
rev = "a08c495a81b37ea6684c94d8b6c67f32b37b67e1"
rev = "e70e14b9df6cea6759031ef20f9e4829af588e6b"

[profile.release]
codegen-units = 1 # use a single codegen unit
Expand Down
17 changes: 0 additions & 17 deletions clippy.toml

This file was deleted.

1 change: 1 addition & 0 deletions crates/authz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ authors.workspace = true
path = "lib.rs"

[dependencies]
azalia.workspace = true
charted-core = { workspace = true, default-features = false }
charted-types = { workspace = true, default-features = false }
derive_more = { workspace = true, features = ["display"] }
Expand Down
3 changes: 2 additions & 1 deletion crates/authz/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use azalia::rust::AsArcAny;
use charted_core::BoxedFuture;
use charted_types::User;
use std::{
Expand All @@ -27,7 +28,7 @@ pub struct InvalidPassword;
impl Error for InvalidPassword {}

/// Trait that allows to build an authenticator that allows to authenticate users.
pub trait Authenticator: Send + Sync {
pub trait Authenticator: AsArcAny + Send + Sync {
/// Authenticate a given [`User`] with the password given.
fn authenticate<'u>(&'u self, user: &'u User, password: String) -> BoxedFuture<'u, eyre::Result<()>>;
}
Expand Down
2 changes: 0 additions & 2 deletions crates/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ repository.workspace = true
authors.workspace = true

[dependencies]
aws-sdk-s3 = "1.56.0"
azalia = { workspace = true, features = [
"config",
"config-derive",
"serde",
"serde-tracing",
] }
azure_storage = "0.21.0"
charted-core = { version = "0.1.0", path = "../core", default-features = false, features = [
"merge",
] }
Expand Down
31 changes: 15 additions & 16 deletions crates/config/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
// limitations under the License.

use crate::helpers;
use aws_sdk_s3::{
config::Region,
types::{BucketCannedAcl, ObjectCannedAcl},
};
use azalia::{
config::{env, merge::Merge, TryFromEnv},
TRUTHY_REGEX,
};
use azure_storage::CloudLocation;
use eyre::{eyre, Context, Report};
use remi_azure::Credential;
use remi_azure::{core::storage::CloudLocation, Credential};
use remi_s3::aws::s3::{
config::Region,
types::{BucketCannedAcl, ObjectCannedAcl},
};
use serde::{Deserialize, Serialize};
use std::{borrow::Cow, path::PathBuf, str::FromStr};

Expand All @@ -33,7 +32,7 @@ use std::{borrow::Cow, path::PathBuf, str::FromStr};
#[serde(rename_all = "lowercase")]
pub enum Config {
/// Uses the local filesystem to store external media and chart indexes.
Filesystem(remi_fs::Config),
Filesystem(remi_fs::StorageConfig),

/// Uses Microsoft's [Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs) to store
/// external media and chart indexes.
Expand Down Expand Up @@ -182,7 +181,7 @@ impl Merge for Config {

impl Default for Config {
fn default() -> Config {
Config::Filesystem(remi_fs::Config {
Config::Filesystem(remi_fs::StorageConfig {
directory: PathBuf::from("./data"),
})
}
Expand All @@ -195,14 +194,14 @@ impl TryFromEnv for Config {
fn try_from_env() -> Result<Self::Output, Self::Error> {
match env!("CHARTED_STORAGE_SERVICE") {
Ok(res) => match res.to_lowercase().as_str() {
"filesystem" | "fs" => Ok(Config::Filesystem(remi_fs::Config {
"filesystem" | "fs" => Ok(Config::Filesystem(remi_fs::StorageConfig {
directory: helpers::env_from_str("CHARTED_STORAGE_FILESYSTEM_DIRECTORY", PathBuf::from("./data"))?,
})),

"azure" => Ok(Config::Azure(remi_azure::StorageConfig {
credentials: to_env_credentials()?,
location: to_env_location()?,
container: env!("CHARTED_STORAGE_AZURE_CONTAINER", optional).unwrap_or("ume".into()),
container: env!("CHARTED_STORAGE_AZURE_CONTAINER", optional).unwrap_or("charted".into()),
})),

"s3" => Ok(Config::S3(remi_s3::StorageConfig {
Expand All @@ -221,7 +220,7 @@ impl TryFromEnv for Config {
endpoint: env!("CHARTED_STORAGE_S3_ENDPOINT", optional),
prefix: env!("CHARTED_STORAGE_S3_PREFIX", optional),
region: env!("CHARTED_STORAGE_S3_REGION", |val| Some(Region::new(Cow::Owned(val))); or Some(Region::new(Cow::Owned("us-east-1".to_owned())))),
bucket: env!("CHARTED_STORAGE_S3_BUCKET", optional).unwrap_or("ume".into()),
bucket: env!("CHARTED_STORAGE_S3_BUCKET", optional).unwrap_or("charted".into()),
})),

loc => Err(eyre!("expected [filesystem/fs, azure, s3]; received '{loc}'")),
Expand Down Expand Up @@ -262,27 +261,27 @@ fn to_env_credentials() -> eyre::Result<Credential> {
}
}

fn to_env_location() -> eyre::Result<azure_storage::CloudLocation> {
fn to_env_location() -> eyre::Result<CloudLocation> {
match env!("CHARTED_STORAGE_AZURE_LOCATION") {
Ok(res) => match res.as_str() {
"public" => Ok(azure_storage::CloudLocation::Public {
"public" => Ok(CloudLocation::Public {
account: env!("CHARTED_STORAGE_AZURE_ACCOUNT")
.context("missing required env [CHARTED_STORAGE_AZURE_ACCOUNT]")?,
}),

"china" => Ok(azure_storage::CloudLocation::China {
"china" => Ok(CloudLocation::China {
account: env!("CHARTED_STORAGE_AZURE_ACCOUNT")
.context("missing required env [CHARTED_STORAGE_AZURE_ACCOUNT]")?,
}),

"emulator" => Ok(azure_storage::CloudLocation::Emulator {
"emulator" => Ok(CloudLocation::Emulator {
address: env!("CHARTED_STORAGE_AZURE_EMULATOR_ADDRESS")
.context("missing required env [CHARTED_STORAGE_AZURE_EMULATOR_ADDRESS]")?,

port: helpers::env_from_str("CHARTED_STORAGE_AZURE_EMULATOR_PORT", 10000u16)?,
}),

"custom" => Ok(azure_storage::CloudLocation::Custom {
"custom" => Ok(CloudLocation::Custom {
account: env!("CHARTED_STORAGE_AZURE_ACCOUNT")
.context("missing required env [CHARTED_STORAGE_AZURE_ACCOUNT]")?,

Expand Down
2 changes: 1 addition & 1 deletion crates/helm-charts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ mod tests {
let tempdir = ::tempfile::TempDir::new().unwrap();
let path = tempdir.into_path();
let $storage = ::azalia::remi::StorageService::Filesystem(::remi_fs::StorageService::with_config(
remi_fs::Config::new(&path),
remi_fs::StorageConfig::new(&path),
));

($storage).init().await.expect("failed to initialize");
Expand Down
4 changes: 1 addition & 3 deletions crates/server/src/routing/v1/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ use serde_json::json;
"idOrName" = NameOrUlid,
Path,
description = "Parameter that can take a `Name` or `Ulid`",
example = json!("noel"),
example = json!("01J647WVTPF2W5W99H5MBT0YQE")
description = "Parameter that can take a `Name` or `Ulid`"
),
),
responses(
Expand Down
Loading

0 comments on commit 8ffc1bd

Please sign in to comment.