Explore config file generation

This commit is contained in:
Quentin 2022-05-25 13:07:19 +02:00
parent 8192d062ba
commit af25c853b9
Signed by: quentin
GPG Key ID: E9602264D639FF68
4 changed files with 42 additions and 7 deletions

2
Cargo.lock generated
View File

@ -669,7 +669,7 @@ dependencies = [
[[package]]
name = "k2v-client"
version = "0.1.0"
source = "git+https://git.deuxfleurs.fr/Deuxfleurs/garage.git?branch=improve-k2v-client#a73f174ada005f71a77f12e185da154aa5c254a9"
source = "git+https://git.deuxfleurs.fr/Deuxfleurs/garage.git?branch=main#9f303f6308a313c8310c3597ecb6828e46352821"
dependencies = [
"base64",
"http",

View File

@ -31,5 +31,9 @@ tokio = "1.17.0"
toml = "0.5"
zstd = { version = "0.9", default-features = false }
k2v-client = { git = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git", branch = "improve-k2v-client" }
k2v-client = { git = "https://git.deuxfleurs.fr/Deuxfleurs/garage.git", branch = "main" }
#k2v-client = { path = "../garage/src/k2v-client" }
[[bin]]
name = "test"
path = "src/test.rs"

View File

@ -3,9 +3,9 @@ use std::io::Read;
use std::path::PathBuf;
use anyhow::Result;
use serde::Deserialize;
use serde::{Serialize,Deserialize};
#[derive(Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Config {
pub s3_endpoint: String,
pub k2v_endpoint: String,
@ -15,13 +15,13 @@ pub struct Config {
pub login_ldap: Option<LoginLdapConfig>,
}
#[derive(Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LoginStaticConfig {
pub default_bucket: Option<String>,
pub users: HashMap<String, LoginStaticUser>,
}
#[derive(Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LoginStaticUser {
pub password: String,
@ -37,7 +37,7 @@ pub struct LoginStaticUser {
pub secret_key: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct LoginLdapConfig {
pub ldap_server: String,

31
src/test.rs Normal file
View File

@ -0,0 +1,31 @@
mod config;
use serde::Serialize;
use std::collections::HashMap;
fn main() {
let config = config::Config {
s3_endpoint: "http://127.0.0.1:3900".to_string(),
k2v_endpoint: "http://127.0.0.1:3904".to_string(),
aws_region: "garage".to_string(),
login_static: Some(config::LoginStaticConfig {
default_bucket: Some("mailrage".to_string()),
users: HashMap::from([
("quentin".to_string(), config::LoginStaticUser {
password: "toto".to_string(),
aws_access_key_id: "GKxxx".to_string(),
aws_secret_access_key: "ffff".to_string(),
bucket: Some("mailrage-quentin".to_string()),
user_secret: "xxx".to_string(),
alternate_user_secrets: vec![],
master_key: None,
secret_key: None,
}),
]),
}),
login_ldap: None,
};
let ser = toml::to_string(&config).unwrap();
println!("{}", ser);
}