Skip to content

Commit

Permalink
perf(pipeline): modify env loader
Browse files Browse the repository at this point in the history
- [x] support = sign in environment variable names;
  • Loading branch information
rfprod committed Oct 28, 2023
1 parent bb5966f commit 3490624
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/data_pipeline/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ impl DataPipelineEnvironment {
let config: Vec<_> = lines
.iter()
.flat_map(|x| {
let split_pair = x.split('=').collect::<Vec<&str>>();
let mut split_pair = x.split('=').collect::<Vec<&str>>();
let split_key = split_pair.first();
let some_key = split_key.is_some();
let key = if some_key {
Expand All @@ -99,16 +99,8 @@ impl DataPipelineEnvironment {
} else {
String::new()
};
let split_value = split_pair.get(1);
let some_value = split_value.is_some();
let value = if some_value {
match split_value.unwrap().trim().parse::<String>() {
Ok(value) => value,
Err(_) => String::new(),
}
} else {
String::new()
};
split_pair.remove(0);
let value = split_pair.join("");
let map = vec![(key, value)];
map
})
Expand Down

0 comments on commit 3490624

Please sign in to comment.