✨ Add configurable rules directory support
- Add rules configuration option to ClientConfig - Support custom rules file paths via config and CLI - Add --rules-dir option to init command - Update Rules struct to accept custom file paths - Add helper functions for rules path resolution - Fix doc comment formatting issues - Add integration tests for custom rules paths
This commit is contained in:
committed by
Jeremiah Russell
parent
e914e492e8
commit
d4cc2621db
@@ -539,6 +539,24 @@ async fn run_rules(client: &mut GmailClient, rules: Rules, execute: bool) -> Res
|
||||
/// - Container deployments with injected token environment variables
|
||||
/// - CI/CD pipelines with stored token secrets
|
||||
/// - Ephemeral compute environments requiring periodic Gmail access
|
||||
fn restore_tokens_if_available(config: &Config, client_config: &ClientConfig) -> Result<()> {
|
||||
let token_env_var = config
|
||||
.get_string("token_cache_env")
|
||||
.unwrap_or_else(|_| "CULL_GMAIL_TOKEN_CACHE".to_string());
|
||||
|
||||
if let Ok(token_data) = env::var(&token_env_var) {
|
||||
log::info!("Found {token_env_var} environment variable, restoring tokens");
|
||||
restore_tokens_from_string(&token_data, client_config.persist_path())?;
|
||||
log::info!("Tokens successfully restored from environment variable");
|
||||
} else {
|
||||
log::debug!(
|
||||
"No {token_env_var} environment variable found, proceeding with normal token flow"
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Gets the rules file path from configuration.
|
||||
///
|
||||
/// Reads the `rules` configuration value and resolves it using path prefixes.
|
||||
@@ -566,24 +584,6 @@ fn get_rules_path(config: &Config) -> Result<Option<PathBuf>> {
|
||||
Ok(Some(path))
|
||||
}
|
||||
|
||||
fn restore_tokens_if_available(config: &Config, client_config: &ClientConfig) -> Result<()> {
|
||||
let token_env_var = config
|
||||
.get_string("token_cache_env")
|
||||
.unwrap_or_else(|_| "CULL_GMAIL_TOKEN_CACHE".to_string());
|
||||
|
||||
if let Ok(token_data) = env::var(&token_env_var) {
|
||||
log::info!("Found {token_env_var} environment variable, restoring tokens");
|
||||
restore_tokens_from_string(&token_data, client_config.persist_path())?;
|
||||
log::info!("Tokens successfully restored from environment variable");
|
||||
} else {
|
||||
log::debug!(
|
||||
"No {token_env_var} environment variable found, proceeding with normal token flow"
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Executes the specified end-of-life action on messages for a Gmail label.
|
||||
///
|
||||
/// This function performs the actual message operations (trash or delete) based on
|
||||
|
||||
Reference in New Issue
Block a user