Skip to content

Commit 3ce21f5

Browse files
committed
Added unescape_java_properties.
1 parent b6412d7 commit 3ce21f5

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

rust/operator-binary/src/druid_controller.rs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -489,18 +489,7 @@ fn build_rolegroup_config_map(
489489
// transformed_config.iter(),
490490
// )
491491
// .context(PropertiesWriteSnafu)?;
492-
let runtime_properties: String = transformed_config
493-
.iter()
494-
.map(|kv| {
495-
format!(
496-
"{}={}",
497-
kv.0,
498-
kv.1.clone().unwrap_or_else(|| "".to_string())
499-
)
500-
})
501-
.reduce(|content, line| format!("{content}\n{line}"))
502-
.unwrap_or_else(|| "".to_string());
503-
492+
let runtime_properties = unescape_java_properties(&transformed_config);
504493
cm_conf_data.insert(RUNTIME_PROPS.to_string(), runtime_properties);
505494
}
506495
PropertyNameKind::File(file_name) if file_name == JVM_CONFIG => {
@@ -555,6 +544,20 @@ fn build_rolegroup_config_map(
555544
})
556545
}
557546

547+
fn unescape_java_properties(props: &BTreeMap<String, Option<String>>) -> String {
548+
props
549+
.iter()
550+
.map(|kv| {
551+
format!(
552+
"{}={}",
553+
kv.0,
554+
kv.1.clone().unwrap_or_else(|| "".to_string())
555+
)
556+
})
557+
.reduce(|content, line| format!("{content}\n{line}"))
558+
.unwrap_or_else(|| "".to_string())
559+
}
560+
558561
/// The rolegroup [`Service`] is a headless service that allows direct access to the instances of a certain rolegroup
559562
///
560563
/// This is mostly useful for internal communication between peers, or for clients that perform client-side load balancing.
@@ -940,4 +943,18 @@ mod test {
940943

941944
Ok(())
942945
}
946+
947+
948+
#[test]
949+
fn test_unescape_java_properties() {
950+
let expected = r#"druid.auth.authenticator.ldap.credentialsValidator.baseDn=ou=users,dc=example,dc=org
951+
druid.auth.authenticator.ldap.credentialsValidator.bindPassword=admin"#;
952+
953+
let props: BTreeMap<String, Option<String>> = vec![
954+
("druid.auth.authenticator.ldap.credentialsValidator.bindPassword".to_string(), Some("admin".to_string())),
955+
("druid.auth.authenticator.ldap.credentialsValidator.baseDn".to_string(), Some("ou=users,dc=example,dc=org".to_string())),
956+
].into_iter().collect();
957+
958+
assert_eq!(expected.to_string(), unescape_java_properties(&props));
959+
}
943960
}

0 commit comments

Comments
 (0)