diff --git a/crates/stackable-operator/crds/Scaler.yaml b/crates/stackable-operator/crds/Scaler.yaml index d764f36f2..221d9e84b 100644 --- a/crates/stackable-operator/crds/Scaler.yaml +++ b/crates/stackable-operator/crds/Scaler.yaml @@ -33,8 +33,8 @@ spec: Upstream issues: - - https://github.com/kubernetes/kubernetes/issues/105533 - - https://github.com/Arnavion/k8s-openapi/issues/136 + - + - format: uint16 maximum: 65535.0 minimum: 0.0 diff --git a/crates/stackable-operator/src/v2/config_file_writer.rs b/crates/stackable-operator/src/v2/config_file_writer.rs index 194ac1aaf..77f1e0d6d 100644 --- a/crates/stackable-operator/src/v2/config_file_writer.rs +++ b/crates/stackable-operator/src/v2/config_file_writer.rs @@ -19,43 +19,37 @@ pub enum PropertiesWriterError { /// `property_1=value_1\nproperty_2=value_2\n`. pub fn to_java_properties_string<'a, T>(properties: T) -> Result where - T: Iterator)>, + T: Iterator, { let mut output = Vec::new(); write_java_properties(&mut output, properties)?; String::from_utf8(output).context(FromUtf8Snafu) } -/// Writes Java properties to the given writer. A `None` value is written as an -/// empty value (`key=`). +/// Writes Java properties to the given writer. fn write_java_properties<'a, W, T>(writer: W, properties: T) -> Result<(), PropertiesWriterError> where W: Write, - T: Iterator)>, + T: Iterator, { let mut writer = PropertiesWriter::new(writer); for (k, v) in properties { - let property_value = v.as_deref().unwrap_or_default(); - writer.write(k, property_value).context(PropertiesSnafu)?; + writer.write(k, v).context(PropertiesSnafu)?; } writer.flush().context(PropertiesSnafu)?; Ok(()) } /// Converts properties into a Hadoop configuration XML, including the wrapping -/// `...` elements. Properties with a `None` value -/// are skipped. Keys and values are XML-escaped. +/// `...` elements. pub fn to_hadoop_xml<'a, T>(properties: T) -> String where - T: Iterator)>, + T: Iterator, { let mut snippet = String::new(); for (k, v) in properties { - let escaped_value = match v { - Some(value) => escape_str_attribute(value), - None => continue, - }; let escaped_key = escape_str_attribute(k); + let escaped_value = escape_str_attribute(v); write!( snippet, " \n {escaped_key}\n {escaped_value}\n \n" @@ -71,18 +65,18 @@ mod tests { use super::*; - fn xml(pairs: &[(&str, Option<&str>)]) -> String { - let map: BTreeMap> = pairs + fn xml(pairs: &[(&str, &str)]) -> String { + let map: BTreeMap = pairs .iter() - .map(|(k, v)| (k.to_string(), v.map(str::to_string))) + .map(|(k, v)| (k.to_string(), v.to_string())) .collect(); to_hadoop_xml(map.iter()) } - fn props(pairs: &[(&str, Option<&str>)]) -> String { - let map: BTreeMap> = pairs + fn props(pairs: &[(&str, &str)]) -> String { + let map: BTreeMap = pairs .iter() - .map(|(k, v)| (k.to_string(), v.map(str::to_string))) + .map(|(k, v)| (k.to_string(), v.to_string())) .collect(); to_java_properties_string(map.iter()).unwrap() } @@ -98,26 +92,16 @@ mod tests { #[test] fn hadoop_xml_renders_single_property() { assert_eq!( - xml(&[("fs.defaultFS", Some("hdfs://hdfs/"))]), + xml(&[("fs.defaultFS", "hdfs://hdfs/")]), "\n\n \ \n fs.defaultFS\n \ hdfs://hdfs/\n \n" ); } - #[test] - fn hadoop_xml_skips_none_values() { - assert_eq!( - xml(&[("kept", Some("1")), ("dropped", None)]), - "\n\n \ - \n kept\n \ - 1\n \n" - ); - } - #[test] fn hadoop_xml_escapes_special_characters() { - let rendered = xml(&[("k", Some("&b"))]); + let rendered = xml(&[("k", "&b")]); assert!( rendered.contains("<a>&b"), "{rendered}" @@ -126,18 +110,18 @@ mod tests { #[test] fn java_properties_renders_key_value() { - assert_eq!(props(&[("a", Some("1")), ("b", Some("2"))]), "a=1\nb=2\n"); + assert_eq!(props(&[("a", "1"), ("b", "2")]), "a=1\nb=2\n"); } #[test] - fn java_properties_renders_none_as_empty() { - assert_eq!(props(&[("none", None)]), "none=\n"); + fn java_properties_renders_empty() { + assert_eq!(props(&[("empty", "")]), "empty=\n"); } #[test] fn java_properties_escapes_colon_in_value() { assert_eq!( - props(&[("url", Some("file://this/location/file.abc"))]), + props(&[("url", "file://this/location/file.abc")]), "url=file\\://this/location/file.abc\n" ); }