Skip to content

Commit

Permalink
fix: added file options arg source
Browse files Browse the repository at this point in the history
  • Loading branch information
juicycleff committed Jan 4, 2024
1 parent 6b7dd05 commit ceabe22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion crates/north-config/src/config_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ fn process_envs(option: EnvSourceOptions) -> Result<Value, Error> {

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)
Expand Down
6 changes: 3 additions & 3 deletions crates/north-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Names>
}

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());
Expand All @@ -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");
}
Expand Down

0 comments on commit ceabe22

Please sign in to comment.