File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,27 @@ impl DefinitionSetTransformer for StripCmqPolicies {
41
41
}
42
42
}
43
43
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
+
44
65
pub struct TransformationChain {
45
66
pub chain : Vec < Box < dyn DefinitionSetTransformer > > ,
46
67
}
@@ -54,6 +75,9 @@ impl From<Vec<&str>> for TransformationChain {
54
75
"strip_cmq_policies" => {
55
76
vec. push ( Box :: new ( StripCmqPolicies :: default ( ) ) ) ;
56
77
}
78
+ "drop_empty_policies" => {
79
+ vec. push ( Box :: new ( DropEmptyPolicies :: default ( ) ) ) ;
80
+ }
57
81
_ => ( ) ,
58
82
}
59
83
}
You can’t perform that action at this time.
0 commit comments