|  | 
| 4 | 4 | //! and helper functions | 
| 5 | 5 | //! | 
| 6 | 6 | //! This is required due to overlaps between TLS encryption and e.g. mTLS authentication or Kerberos | 
|  | 7 | +use std::collections::BTreeMap; | 
| 7 | 8 | 
 | 
| 8 |  | -use crate::{ | 
| 9 |  | - authentication, authentication::ResolvedAuthenticationClasses, listener, tls, KafkaCluster, | 
| 10 |  | - SERVER_PROPERTIES_FILE, STACKABLE_CONFIG_DIR, STACKABLE_TMP_DIR, | 
| 11 |  | -}; | 
| 12 |  | - | 
| 13 |  | -use crate::listener::KafkaListenerConfig; | 
|  | 9 | +use indoc::formatdoc; | 
| 14 | 10 | use snafu::{ResultExt, Snafu}; | 
| 15 | 11 | use stackable_operator::builder::SecretFormat; | 
|  | 12 | +use stackable_operator::product_logging::framework::{ | 
|  | 13 | + create_vector_shutdown_file_command, remove_vector_shutdown_file_command, | 
|  | 14 | +}; | 
| 16 | 15 | use stackable_operator::{ | 
| 17 | 16 |  builder::{ContainerBuilder, PodBuilder, SecretOperatorVolumeSourceBuilder, VolumeBuilder}, | 
| 18 | 17 |  client::Client, | 
| 19 | 18 |  commons::authentication::{AuthenticationClass, AuthenticationClassProvider}, | 
| 20 | 19 |  k8s_openapi::api::core::v1::Volume, | 
|  | 20 | + utils::COMMON_BASH_TRAP_FUNCTIONS, | 
|  | 21 | +}; | 
|  | 22 | + | 
|  | 23 | +use crate::STACKABLE_LOG_DIR; | 
|  | 24 | +use crate::{ | 
|  | 25 | + authentication::{self, ResolvedAuthenticationClasses}, | 
|  | 26 | + listener::{self, KafkaListenerConfig}, | 
|  | 27 | + tls, KafkaCluster, SERVER_PROPERTIES_FILE, STACKABLE_CONFIG_DIR, STACKABLE_TMP_DIR, | 
| 21 | 28 | }; | 
| 22 |  | -use std::collections::BTreeMap; | 
| 23 | 29 | 
 | 
| 24 | 30 | #[derive(Snafu, Debug)] | 
| 25 | 31 | pub enum Error { | 
| @@ -225,23 +231,26 @@ impl KafkaTlsSecurity { | 
| 225 | 231 |  kafka_listeners: &KafkaListenerConfig, | 
| 226 | 232 |  opa_connect_string: Option<&str>, | 
| 227 | 233 |  ) -> Vec<String> { | 
| 228 |  | - vec![ | 
| 229 |  | - "bin/kafka-server-start.sh".to_string(), | 
| 230 |  | - format!("{STACKABLE_CONFIG_DIR}/{SERVER_PROPERTIES_FILE}"), | 
| 231 |  | - "--override \"zookeeper.connect=$ZOOKEEPER\"".to_string(), | 
| 232 |  | - format!("--override \"listeners={}\"", kafka_listeners.listeners()), | 
| 233 |  | - format!( | 
| 234 |  | - "--override \"advertised.listeners={}\"", | 
| 235 |  | - kafka_listeners.advertised_listeners() | 
| 236 |  | - ), | 
| 237 |  | - format!( | 
| 238 |  | - "--override \"listener.security.protocol.map={}\"", | 
| 239 |  | - kafka_listeners.listener_security_protocol_map() | 
| 240 |  | - ), | 
| 241 |  | - opa_connect_string.map_or("".to_string(), |opa| { | 
| 242 |  | - format!("--override \"opa.authorizer.url={}\"", opa) | 
| 243 |  | - }), | 
| 244 |  | - ] | 
|  | 234 | + vec![formatdoc! {" | 
|  | 235 | + {COMMON_BASH_TRAP_FUNCTIONS} | 
|  | 236 | + {remove_vector_shutdown_file_command} | 
|  | 237 | + prepare_signal_handlers | 
|  | 238 | + bin/kafka-server-start.sh {STACKABLE_CONFIG_DIR}/{SERVER_PROPERTIES_FILE} --override \"zookeeper.connect=$ZOOKEEPER\" --override \"listeners={listeners}\" --override \"advertised.listeners={advertised_listeners}\" --override \"listener.security.protocol.map={listener_security_protocol_map}\"{opa_config} & | 
|  | 239 | + wait_for_termination $! | 
|  | 240 | + {create_vector_shutdown_file_command} | 
|  | 241 | + ", | 
|  | 242 | + remove_vector_shutdown_file_command = | 
|  | 243 | + remove_vector_shutdown_file_command(STACKABLE_LOG_DIR), | 
|  | 244 | + create_vector_shutdown_file_command = | 
|  | 245 | + create_vector_shutdown_file_command(STACKABLE_LOG_DIR), | 
|  | 246 | + listeners = kafka_listeners.listeners(), | 
|  | 247 | + advertised_listeners = kafka_listeners.advertised_listeners(), | 
|  | 248 | + listener_security_protocol_map = kafka_listeners.listener_security_protocol_map(), | 
|  | 249 | + opa_config = match opa_connect_string { | 
|  | 250 | + None => "".to_string(), | 
|  | 251 | + Some(opa_connect_string) => format!(" --override \"opa.authorizer.url={opa_connect_string}\""), | 
|  | 252 | + } | 
|  | 253 | + }] | 
| 245 | 254 |  } | 
| 246 | 255 | 
 | 
| 247 | 256 |  /// Adds required volumes and volume mounts to the pod and container builders | 
|  | 
0 commit comments