@@ -53,30 +53,9 @@ pub const FIELD_MANAGER: &str = "zookeeper-operator";
5353pub const ZOOKEEPER_PROPERTIES_FILE : & str = "zoo.cfg" ;
5454pub const JVM_SECURITY_PROPERTIES_FILE : & str = "security.properties" ;
5555
56- /// Typed config overrides for ZooKeeper. Each field corresponds to a known config file.
57- #[ derive( Clone , Debug , Default , Deserialize , JsonSchema , PartialEq , Serialize ) ]
58- #[ serde( rename_all = "camelCase" ) ]
59- pub struct ZookeeperConfigOverrides {
60- #[ serde( rename = "zoo.cfg" , default ) ]
61- pub zoo_cfg : KeyValueConfigOverrides ,
62-
63- #[ serde( rename = "security.properties" , default ) ]
64- pub security_properties : KeyValueConfigOverrides ,
65- }
66-
67- impl KeyValueOverridesProvider for ZookeeperConfigOverrides {
68- fn get_key_value_overrides ( & self , file : & str ) -> BTreeMap < String , Option < String > > {
69- match file {
70- ZOOKEEPER_PROPERTIES_FILE => self . zoo_cfg . as_product_config_overrides ( ) ,
71- JVM_SECURITY_PROPERTIES_FILE => self . security_properties . as_product_config_overrides ( ) ,
72- _ => BTreeMap :: new ( ) ,
73- }
74- }
75- }
76-
7756pub type ZookeeperServerRoleType = Role <
7857 v1alpha1:: ZookeeperConfigFragment ,
79- ZookeeperConfigOverrides ,
58+ v1alpha1 :: ZookeeperConfigOverrides ,
8059 ZookeeperServerRoleConfig ,
8160 JavaCommonConfig ,
8261> ;
@@ -187,14 +166,7 @@ pub mod versioned {
187166
188167 // no doc - it's in the struct.
189168 #[ serde( skip_serializing_if = "Option::is_none" ) ]
190- pub servers : Option <
191- Role <
192- ZookeeperConfigFragment ,
193- ZookeeperConfigOverrides ,
194- ZookeeperServerRoleConfig ,
195- JavaCommonConfig ,
196- > ,
197- > ,
169+ pub servers : Option < ZookeeperServerRoleType > ,
198170 }
199171
200172 #[ derive( Clone , Debug , Deserialize , JsonSchema , PartialEq , Serialize ) ]
@@ -310,6 +282,20 @@ pub mod versioned {
310282 Zookeeper ,
311283 }
312284
285+ #[ derive( Clone , Debug , Default , Deserialize , JsonSchema , PartialEq , Serialize ) ]
286+ #[ serde( rename_all = "camelCase" ) ]
287+ pub struct ZookeeperConfigOverrides {
288+ #[ serde( default , rename = "zoo.cfg" , skip_serializing_if = "Option::is_none" ) ]
289+ pub zoo_cfg : Option < KeyValueConfigOverrides > ,
290+
291+ #[ serde(
292+ default ,
293+ rename = "security.properties" ,
294+ skip_serializing_if = "Option::is_none"
295+ ) ]
296+ pub security_properties : Option < KeyValueConfigOverrides > ,
297+ }
298+
313299 #[ derive( Clone , Default , Debug , Deserialize , Eq , JsonSchema , PartialEq , Serialize ) ]
314300 #[ serde( rename_all = "camelCase" ) ]
315301 pub struct ZookeeperClusterStatus {
@@ -361,6 +347,19 @@ pub mod versioned {
361347 }
362348}
363349
350+ impl KeyValueOverridesProvider for v1alpha1:: ZookeeperConfigOverrides {
351+ fn get_key_value_overrides ( & self , file : & str ) -> BTreeMap < String , Option < String > > {
352+ let field = match file {
353+ ZOOKEEPER_PROPERTIES_FILE => self . zoo_cfg . as_ref ( ) ,
354+ JVM_SECURITY_PROPERTIES_FILE => self . security_properties . as_ref ( ) ,
355+ _ => None ,
356+ } ;
357+ field
358+ . map ( KeyValueConfigOverrides :: as_product_config_overrides)
359+ . unwrap_or_default ( )
360+ }
361+ }
362+
364363#[ derive(
365364 Clone ,
366365 Debug ,
@@ -613,7 +612,11 @@ impl v1alpha1::ZookeeperCluster {
613612 & self ,
614613 rolegroup_ref : & RoleGroupRef < v1alpha1:: ZookeeperCluster > ,
615614 ) -> Result <
616- RoleGroup < v1alpha1:: ZookeeperConfigFragment , JavaCommonConfig , ZookeeperConfigOverrides > ,
615+ RoleGroup <
616+ v1alpha1:: ZookeeperConfigFragment ,
617+ JavaCommonConfig ,
618+ v1alpha1:: ZookeeperConfigOverrides ,
619+ > ,
617620 Error ,
618621 > {
619622 let role_variant = ZookeeperRole :: from_str ( & rolegroup_ref. role ) . with_context ( |_| {
0 commit comments