Skip to content

Commit c4e3374

Browse files
chore: Version ZookeeperConfigOverrides
1 parent 8a47f0a commit c4e3374

2 files changed

Lines changed: 38 additions & 35 deletions

File tree

extra/crds.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,22 +647,22 @@ spec:
647647
security.properties:
648648
additionalProperties:
649649
type: string
650-
default: {}
651650
description: |-
652651
Flat key-value overrides for `*.properties`, Hadoop XML, etc.
653652
654653
This is backwards-compatible with the existing flat key-value YAML format
655654
used by `HashMap<String, String>`.
655+
nullable: true
656656
type: object
657657
zoo.cfg:
658658
additionalProperties:
659659
type: string
660-
default: {}
661660
description: |-
662661
Flat key-value overrides for `*.properties`, Hadoop XML, etc.
663662
664663
This is backwards-compatible with the existing flat key-value YAML format
665664
used by `HashMap<String, String>`.
665+
nullable: true
666666
type: object
667667
type: object
668668
envOverrides:
@@ -1202,22 +1202,22 @@ spec:
12021202
security.properties:
12031203
additionalProperties:
12041204
type: string
1205-
default: {}
12061205
description: |-
12071206
Flat key-value overrides for `*.properties`, Hadoop XML, etc.
12081207
12091208
This is backwards-compatible with the existing flat key-value YAML format
12101209
used by `HashMap<String, String>`.
1210+
nullable: true
12111211
type: object
12121212
zoo.cfg:
12131213
additionalProperties:
12141214
type: string
1215-
default: {}
12161215
description: |-
12171216
Flat key-value overrides for `*.properties`, Hadoop XML, etc.
12181217
12191218
This is backwards-compatible with the existing flat key-value YAML format
12201219
used by `HashMap<String, String>`.
1220+
nullable: true
12211221
type: object
12221222
type: object
12231223
envOverrides:

rust/operator-binary/src/crd/mod.rs

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,30 +53,9 @@ pub const FIELD_MANAGER: &str = "zookeeper-operator";
5353
pub const ZOOKEEPER_PROPERTIES_FILE: &str = "zoo.cfg";
5454
pub 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-
7756
pub 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

Comments
 (0)