From ceabe225840d6aefc969de192dba18a8cc7e3d58 Mon Sep 17 00:00:00 2001 From: Rex Raphael Date: Thu, 4 Jan 2024 01:34:59 -0600 Subject: [PATCH] fix: added file options arg source --- crates/north-config/src/config_source.rs | 3 ++- crates/north-config/src/lib.rs | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/north-config/src/config_source.rs b/crates/north-config/src/config_source.rs index 1ae813f..76032da 100644 --- a/crates/north-config/src/config_source.rs +++ b/crates/north-config/src/config_source.rs @@ -687,7 +687,8 @@ fn process_envs(option: EnvSourceOptions) -> Result { let new_key = key.strip_prefix(prefix).expect("env var prefix missing"); let dot_key: String = new_key.replace(separator.clone(), ".").clone().to_case(case); - obj.dot_set(dot_key.as_str(), value).unwrap(); + let new_value: serde_json::Value = serde_json::from_str(value.as_str()).expect("go value"); + obj.dot_set(dot_key.as_str(), new_value).unwrap(); } Ok(obj) diff --git a/crates/north-config/src/lib.rs b/crates/north-config/src/lib.rs index fe0105b..de960c7 100644 --- a/crates/north-config/src/lib.rs +++ b/crates/north-config/src/lib.rs @@ -293,14 +293,14 @@ mod tests { fn read_deep_array_config_from_env_sources() { #[derive(Clone, serde::Deserialize, serde::Serialize, Debug)] struct Names { - pub first: String + pub first: i32 } #[derive(Clone, serde::Deserialize, serde::Serialize, Debug)] struct TestStr { pub names: Vec } - envmnt::set("NORTH_NAMES__0__FIRST", "Run"); + envmnt::set("NORTH_NAMES__0__FIRST", "50"); let mut env_opts = EnvSourceOptions::default(); env_opts.prefix = Some("NORTH".to_string()); @@ -314,7 +314,7 @@ mod tests { let names = config.names; assert_eq!(names.len(), 1); - assert_eq!(names[0].first, "Run"); + assert_eq!(names[0].first, 50); envmnt::remove("NORTH_NAMES__0__FIRST"); }