in order to configure keyserver to talk to prod/staging environments, we need to rewrite getCommConfig in Rust
Diff Detail
Diff Detail
- Repository
- rCOMM Comm
- Branch
- new-master (branched from master)
- Lint
No Lint Coverage - Unit
No Test Coverage
Event Timeline
Comment Actions
tested by creating a file called src/main.rs and running cargo run
diff --git a/keyserver/addons/rust-node-addon/src/main.rs b/keyserver/addons/rust-node-addon/src/main.rs new file mode 100644 index 000000000..4755eac9b --- /dev/null +++ b/keyserver/addons/rust-node-addon/src/main.rs @@ -0,0 +1,10 @@ +use std::collections::HashMap; + +use crate::config::{get_comm_config, ConfigName}; + +mod config; +fn main() { + let json: Option<HashMap<String, String>> = + get_comm_config(ConfigName::Secrets("db_config".to_string())); + println!("{:?}", json); +}
here was the output:
Some({"password": "REDACTED", "database": "comm", "dbType": "mariadb10.8", "host": "localhost", "user": "comm"})
Comment Actions
I think a better solution long term would be to have a struct which reflects the values specific to the config in question:
#[derive(Serialize, Deserialize)] pub struct KeyserverConfig { password: String, database: String, dbType: String, host: String user: String }
And just hold a reference to the config. I'm not sure who this is meant to be used from code, but I'm assuming something like:
get_key_for_config_name(ConfigName::Secrets("keyserver")).unwrap().password
would just be:
CONFIG.password
keyserver/addons/rust-node-addon/src/config.rs | ||
---|---|---|
6–27 | Feel like this is more inline with what you're trying to express filename is probably more appropriate than just name | |
56 | can we at least use expect, so there's something to grep for if/when this does fail? | |
72–74 | this seems really odd and just hardcoding current behavior | |
76–80 | Pretty sure this should work. |