aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-05-25 13:07:19 +0200
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-05-25 13:07:19 +0200
commitaf25c853b9ca57ad4bc2ff65813f8a5167bd95d9 (patch)
tree7a916dcd3c402c866262e1d9ba106cadaeb6db3a /src
parent8192d062baf7f783af9519b9419647dc907a3c8c (diff)
downloadaerogramme-af25c853b9ca57ad4bc2ff65813f8a5167bd95d9.tar.gz
aerogramme-af25c853b9ca57ad4bc2ff65813f8a5167bd95d9.zip
Explore config file generation
Diffstat (limited to 'src')
-rw-r--r--src/config.rs10
-rw-r--r--src/test.rs31
2 files changed, 36 insertions, 5 deletions
diff --git a/src/config.rs b/src/config.rs
index b77288b..6c3801c 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -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,
diff --git a/src/test.rs b/src/test.rs
new file mode 100644
index 0000000..4d32a6f
--- /dev/null
+++ b/src/test.rs
@@ -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);
+}