1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::path::PathBuf;
use holochain_conductor_api::config::conductor::ConductorConfig;
use holochain_conductor_api::config::conductor::KeystoreConfig;
pub const CONDUCTOR_CONFIG: &str = "conductor-config.yaml";
pub fn create_config(environment_path: PathBuf) -> ConductorConfig {
let mut conductor_config = ConductorConfig {
environment_path: environment_path.clone().into(),
..Default::default()
};
let mut keystore_path = environment_path;
keystore_path.push("keystore");
conductor_config.keystore = KeystoreConfig::LairServerLegacyDeprecated {
keystore_path: Some(keystore_path),
danger_passphrase_insecure_from_config: "default-insecure-passphrase".into(),
};
conductor_config
}
pub fn write_config(mut path: PathBuf, config: &ConductorConfig) -> PathBuf {
path.push(CONDUCTOR_CONFIG);
std::fs::write(path.clone(), serde_yaml::to_string(&config).unwrap()).unwrap();
path
}
pub fn read_config(mut path: PathBuf) -> anyhow::Result<Option<ConductorConfig>> {
path.push(CONDUCTOR_CONFIG);
match std::fs::read_to_string(path) {
Ok(yaml) => Ok(Some(serde_yaml::from_str(&yaml)?)),
Err(_) => Ok(None),
}
}