Skip to content

Commit

Permalink
Prepare index
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosthe19916 committed Jan 8, 2024
1 parent db5ea97 commit d500ab0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
24 changes: 4 additions & 20 deletions openubl/storage/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ pub struct LocalStorage {

#[derive(clap::Args, Debug)]
pub struct MinioStorage {
#[arg(
id = "storage-minio-host",
long,
env = "STORAGE_MINIO_HOST"
)]
#[arg(id = "storage-minio-host", long, env = "STORAGE_MINIO_HOST")]
pub host: String,

#[arg(
Expand Down Expand Up @@ -65,11 +61,7 @@ pub struct MinioStorage {

#[derive(clap::Args, Debug)]
pub struct S3Storage {
#[arg(
id = "storage-s3-region",
long,
env = "STORAGE_S3_REGION"
)]
#[arg(id = "storage-s3-region", long, env = "STORAGE_S3_REGION")]
pub region: String,

#[arg(
Expand All @@ -88,17 +80,9 @@ pub struct S3Storage {
)]
pub bucket_index: String,

#[arg(
id = "storage-s3-access-key",
long,
env = "STORAGE_S3_ACCESS_KEY"
)]
#[arg(id = "storage-s3-access-key", long, env = "STORAGE_S3_ACCESS_KEY")]
pub access_key: String,

#[arg(
id = "storage-s3-secret-key",
long,
env = "STORAGE_S3_SECRET_KEY"
)]
#[arg(id = "storage-s3-secret-key", long, env = "STORAGE_S3_SECRET_KEY")]
pub secret_key: String,
}
14 changes: 6 additions & 8 deletions openubl/storage/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::fs;
use std::fs::{File, rename};
use std::fs::{rename, File};
use std::io::{Read, Write};
use std::path::Path;
use std::str::FromStr;

use anyhow::anyhow;
use aws_config::BehaviorVersion;
use aws_config::meta::region::RegionProviderChain;
use aws_config::retry::RetryConfig;
use aws_config::BehaviorVersion;
use aws_sdk_s3::client::Client as S3Client;
use aws_sdk_s3::error::SdkError;
use aws_sdk_s3::operation::get_object::GetObjectError;
Expand Down Expand Up @@ -128,12 +128,10 @@ impl From<ZipError> for StorageSystemErr {
impl StorageSystem {
pub async fn new(config: &Storage) -> anyhow::Result<Self> {
match config {
Storage::Local(config) => {
Ok(Self::FileSystem(Directories {
ubl: config.dir_ubl.clone(),
index: config.dir_index.clone(),
}))
}
Storage::Local(config) => Ok(Self::FileSystem(Directories {
ubl: config.dir_ubl.clone(),
index: config.dir_index.clone(),
})),
Storage::Minio(config) => {
let static_provider =
StaticProvider::new(&config.access_key, &config.secret_key, None);
Expand Down

0 comments on commit d500ab0

Please sign in to comment.