Skip to content

Commit

Permalink
feat(config): Error on invalid types
Browse files Browse the repository at this point in the history
Fixes #221
  • Loading branch information
Ed Page committed Apr 7, 2021
1 parent 10d9794 commit 57ace37
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,18 @@ impl<'s> ConfigEngine<'s> {
type_matcher.add_defaults();
let mut types: std::collections::HashMap<_, _> = Default::default();
for (type_name, type_engine) in type_.into_iter() {
for glob in type_engine.extend_glob.iter() {
type_matcher.add(type_name.as_str(), glob.as_str())?;
if type_engine.extend_glob.is_empty() {
if type_matcher
.definitions()
.iter()
.all(|def| def.name() != type_name.as_str())
{
anyhow::bail!("Unknown type definition `{}`, pass `--type-list` to see valid names or set `extend_globs` to add a new one.", type_name);
}
} else {
for glob in type_engine.extend_glob.iter() {
type_matcher.add(type_name.as_str(), glob.as_str())?;
}
}

let mut new_type_engine = default.clone();
Expand Down

0 comments on commit 57ace37

Please sign in to comment.