Skip to content

Commit 5738ac8

Browse files
committed
refactor: use non optional property writers
1 parent 8f032c8 commit 5738ac8

6 files changed

Lines changed: 61 additions & 84 deletions

File tree

Cargo.nix

Lines changed: 41 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ impl HdfsSiteConfigBuilder {
215215
}
216216

217217
pub fn build_as_xml(&self) -> String {
218-
let transformed_config = to_optional_values(&self.config);
219-
220-
to_hadoop_xml(transformed_config.iter())
218+
to_hadoop_xml(self.config.iter())
221219
}
222220
}
223221

@@ -262,8 +260,7 @@ impl CoreSiteConfigBuilder {
262260
}
263261

264262
pub fn build_as_xml(&self) -> String {
265-
let transformed_config = to_optional_values(&self.config);
266-
to_hadoop_xml(transformed_config.iter())
263+
to_hadoop_xml(self.config.iter())
267264
}
268265

269266
pub fn enable_prometheus_endpoint(&mut self) -> &mut Self {
@@ -272,10 +269,3 @@ impl CoreSiteConfigBuilder {
272269
self
273270
}
274271
}
275-
276-
fn to_optional_values(config: &BTreeMap<String, String>) -> BTreeMap<String, Option<String>> {
277-
config
278-
.iter()
279-
.map(|(k, v)| (k.clone(), Some(v.clone())))
280-
.collect::<BTreeMap<String, Option<String>>>()
281-
}

rust/operator-binary/src/controller/build/properties/hadoop_policy.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ use crate::controller::build::properties::resolved_overrides;
1313

1414
/// Renders `hadoop-policy.xml` from the user-provided overrides only.
1515
pub fn build(overrides: KeyValueConfigOverrides) -> String {
16-
let config: BTreeMap<String, Option<String>> = resolved_overrides(overrides)
17-
.map(|(key, value)| (key, Some(value)))
18-
.collect();
16+
let config: BTreeMap<String, String> = resolved_overrides(overrides).collect();
1917
to_hadoop_xml(config.iter())
2018
}
2119

rust/operator-binary/src/controller/build/properties/security_properties.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,15 @@ pub fn build(overrides: KeyValueConfigOverrides) -> Result<String, PropertiesWri
1717
// Recommended JVM DNS cache TTLs. Caching forever (the JVM default for
1818
// successful lookups) breaks failover when a NameNode's IP changes, so cap
1919
// both positive and negative caches.
20-
let mut config: BTreeMap<String, Option<String>> = BTreeMap::from([
21-
(
22-
"networkaddress.cache.ttl".to_string(),
23-
Some("30".to_string()),
24-
),
20+
let mut config: BTreeMap<String, String> = BTreeMap::from([
21+
("networkaddress.cache.ttl".to_string(), "30".to_string()),
2522
(
2623
"networkaddress.cache.negative.ttl".to_string(),
27-
Some("0".to_string()),
24+
"0".to_string(),
2825
),
2926
]);
3027
// Overrides applied last so users win.
31-
config.extend(resolved_overrides(overrides).map(|(key, value)| (key, Some(value))));
28+
config.extend(resolved_overrides(overrides));
3229
to_java_properties_string(config.iter())
3330
}
3431

rust/operator-binary/src/controller/build/properties/ssl_client.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,25 @@ use crate::{
1616

1717
/// Renders `ssl-client.xml` for the given HTTPS state and user overrides.
1818
pub fn build(https_enabled: bool, overrides: KeyValueConfigOverrides) -> String {
19-
let mut config: BTreeMap<String, Option<String>> = BTreeMap::new();
19+
let mut config: BTreeMap<String, String> = BTreeMap::new();
2020
if https_enabled {
2121
config.extend([
2222
(
2323
"ssl.client.truststore.location".to_string(),
24-
Some(format!("{TLS_STORE_DIR}/truststore.p12")),
24+
format!("{TLS_STORE_DIR}/truststore.p12"),
2525
),
2626
(
2727
"ssl.client.truststore.type".to_string(),
28-
Some("pkcs12".to_string()),
28+
"pkcs12".to_string(),
2929
),
3030
(
3131
"ssl.client.truststore.password".to_string(),
32-
Some(TLS_STORE_PASSWORD.to_string()),
32+
TLS_STORE_PASSWORD.to_string(),
3333
),
3434
]);
3535
}
3636
// Overrides applied last so users win.
37-
config.extend(resolved_overrides(overrides).map(|(key, value)| (key, Some(value))));
37+
config.extend(resolved_overrides(overrides));
3838
to_hadoop_xml(config.iter())
3939
}
4040

0 commit comments

Comments
 (0)