Skip to content

Commit 1c7e503

Browse files
One more DefinitionSetTransformer
1 parent 045d0b1 commit 1c7e503

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/transformers.rs

+24
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ impl DefinitionSetTransformer for StripCmqPolicies {
4141
}
4242
}
4343

44+
#[derive(Default)]
45+
pub struct DropEmptyPolicies {}
46+
47+
impl DefinitionSetTransformer for DropEmptyPolicies {
48+
fn transform<'a>(&self, defs: &'a mut ClusterDefinitionSet) -> &'a mut ClusterDefinitionSet {
49+
let non_empty = defs
50+
.policies
51+
.iter()
52+
.filter(|p| !p.is_empty())
53+
.cloned()
54+
.collect::<Vec<_>>();
55+
defs.policies = non_empty;
56+
57+
defs
58+
}
59+
}
60+
61+
//
62+
// Transformation chain
63+
//
64+
4465
pub struct TransformationChain {
4566
pub chain: Vec<Box<dyn DefinitionSetTransformer>>,
4667
}
@@ -54,6 +75,9 @@ impl From<Vec<&str>> for TransformationChain {
5475
"strip_cmq_policies" => {
5576
vec.push(Box::new(StripCmqPolicies::default()));
5677
}
78+
"drop_empty_policies" => {
79+
vec.push(Box::new(DropEmptyPolicies::default()));
80+
}
5781
_ => (),
5882
}
5983
}

0 commit comments

Comments
 (0)