Skip to content

Commit

Permalink
ensure top level keys don't collide
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Moeglich committed Nov 13, 2024
1 parent 1a00953 commit 6f0cf8a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/resolve_spaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,30 @@ fn resolve_space(
}
}

if let Some(variables) = &variables {
let mut environment_keys: HashSet<String> = HashSet::new();
for env in &space.environments {
let keys: Option<HashSet<String>> = variables
.get(env)
.map(|v| v.as_object().unwrap().keys().cloned().collect());
if let Some(keys) = keys {
environment_keys.extend(keys);
}
}

// ensure the environment keys do not conflict with the top level keys
for key in variables.keys() {
if environment_keys.contains(key) {
return Err(anyhow::anyhow!(
"Environment key {:?} conflicts with top level key: {:?} in the space {:?}",
key,
environment_keys,
name
));
}
}
}

resolved_spaces.insert(
name.to_string(),
ResolvedSpace {
Expand Down

0 comments on commit 6f0cf8a

Please sign in to comment.