From 083245b4478cd05c01cc0448bd1cb251805fbd98 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Wed, 10 Sep 2025 21:48:09 -0600 Subject: [PATCH] Updated the README to properly show managarr config injection --- README.md | 4 ++-- src/bin/gman/cli.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 46bfc0f..3c70d1c 100644 --- a/README.md +++ b/README.md @@ -242,12 +242,12 @@ radarr: - name: Radarr host: 192.168.0.105 port: 7878 - api_token: {{RADARR_API_KEY}} # This will be replaced by gman with the actual secret value + api_token: '{{RADARR_API_KEY}}' # This will be replaced by gman with the actual secret value sonarr: - name: Sonarr host: 192.168.0.105 port: 8989 - api_token: {{sonarr_api_key}} # gman is case-insensitive, so this will also be replaced correctly + api_token: '{{sonarr_api_key}}' # gman is case-insensitive, so this will also be replaced correctly ``` Then, all you need to do to run `managarr` with the secrets injected is: diff --git a/src/bin/gman/cli.rs b/src/bin/gman/cli.rs index 17fe14a..ed59e58 100644 --- a/src/bin/gman/cli.rs +++ b/src/bin/gman/cli.rs @@ -243,3 +243,35 @@ pub fn parse_args( } Ok(args) } + +#[cfg(test)] +mod tests { + use std::collections::HashMap; + use gman::config::RunConfig; + use crate::cli::generate_files_secret_injections; + + #[test] + fn test_generate_files_secret_injections() { + let mut secrets = HashMap::new(); + secrets.insert("SECRET1".to_string(), "value1".to_string()); + let temp_dir = tempfile::tempdir().unwrap(); + let file_path = temp_dir.path().join("test.txt"); + std::fs::write(&file_path, "{{secret1}}").unwrap(); + + let run_config = RunConfig { + name: Some("test".to_string()), + secrets: Some(vec!["secret1".to_string()]), + files: Some(vec![file_path.clone()]), + flag: None, + flag_position: None, + arg_format: None, + }; + + let result = generate_files_secret_injections(secrets, &run_config).unwrap(); + + assert_eq!(result.len(), 1); + assert_eq!(result[0].0, &file_path); + assert_eq!(result[0].1, "{{secret1}}"); + assert_eq!(result[0].2, "value1"); + } +}