diff options
| author | iximeow <git@iximeow.net> | 2022-12-26 00:50:26 +0000 | 
|---|---|---|
| committer | iximeow <git@iximeow.net> | 2022-12-26 00:50:26 +0000 | 
| commit | 7e84420dfe659494318630863ff97a75b0ad32ff (patch) | |
| tree | b24cd3318c2b5891e246ac4bd4678603f8bad3c9 /src/dbctx.rs | |
| parent | 99f81b94fdc7289dcdb34a98e57b9550b3bd170b (diff) | |
secrets are configurable now
Diffstat (limited to 'src/dbctx.rs')
| -rw-r--r-- | src/dbctx.rs | 18 | 
1 files changed, 13 insertions, 5 deletions
| diff --git a/src/dbctx.rs b/src/dbctx.rs index c4eb767..937b887 100644 --- a/src/dbctx.rs +++ b/src/dbctx.rs @@ -4,6 +4,8 @@ use rusqlite::{Connection, OptionalExtension};  use std::time::{SystemTime, UNIX_EPOCH};  use tokio::fs::{File, OpenOptions};  use tokio::io::{AsyncReadExt, AsyncWriteExt}; +use std::path::Path; +use std::path::PathBuf;  use crate::notifier::{RemoteNotifier, NotifierConfig};  use crate::sql; @@ -11,7 +13,7 @@ use crate::sql;  const TOKEN_EXPIRY_MS: u64 = 1000 * 60 * 30;  pub struct DbCtx { -    pub config_path: String, +    pub config_path: PathBuf,      // don't love this but.. for now...      pub conn: Mutex<Connection>,  } @@ -84,9 +86,9 @@ impl ArtifactDescriptor {  }  impl DbCtx { -    pub fn new(config_path: &str, db_path: &str) -> Self { +    pub fn new<P: AsRef<Path>>(config_path: P, db_path: P) -> Self {          DbCtx { -            config_path: config_path.to_owned(), +            config_path: config_path.as_ref().to_owned(),              conn: Mutex::new(Connection::open(db_path).unwrap())          }      } @@ -293,17 +295,23 @@ impl DbCtx {          for remote in remotes.into_iter() {              match remote.remote_api.as_str() {                  "github" => { +                    let mut notifier_path = self.config_path.clone(); +                    notifier_path.push(&remote.notifier_config_path); +                      let notifier = RemoteNotifier {                          remote_path: remote.remote_path, -                        notifier: NotifierConfig::github_from_file(&format!("{}/{}", self.config_path, remote.notifier_config_path)) +                        notifier: NotifierConfig::github_from_file(¬ifier_path)                              .expect("can load notifier config")                      };                      notifiers.push(notifier);                  },                  "email" => { +                    let mut notifier_path = self.config_path.clone(); +                    notifier_path.push(&remote.notifier_config_path); +                      let notifier = RemoteNotifier {                          remote_path: remote.remote_path, -                        notifier: NotifierConfig::email_from_file(&format!("{}/{}", self.config_path, remote.notifier_config_path)) +                        notifier: NotifierConfig::email_from_file(¬ifier_path)                              .expect("can load notifier config")                      };                      notifiers.push(notifier); | 
