File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 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 {
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+
4465pub 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 }
You can’t perform that action at this time.
0 commit comments