@@ -209,44 +209,34 @@ impl ReconcilerError for Error {
209209 }
210210}
211211
212+ pub type RoleGroupName = String ;
213+
212214/// The validated cluster. Carries everything the build steps need, resolved once
213215/// here so downstream code never re-derives it or touches the raw spec.
214216///
215217/// The cluster identity (`name`, `namespace`, `uid`) is captured here so that owner
216218/// references for child objects can be built straight from this struct (via its
217219/// [`Resource`] impl) without threading the raw [`v1alpha1::KafkaCluster`] around.
218220/// This mirrors the hive-/opensearch-operator's `ValidatedCluster`.
219- pub struct ValidatedKafkaCluster {
221+ pub struct ValidatedCluster {
220222 /// `ObjectMeta` carrying `name`, `namespace` and `uid`, so this struct can act as the
221223 /// owner [`Resource`] for child objects.
222224 metadata : ObjectMeta ,
223225 pub name : ClusterName ,
224226 pub namespace : NamespaceName ,
225227 pub image : ResolvedProductImage ,
226- pub kafka_security : KafkaTlsSecurity ,
227- // DESIGN DECISION: the dereferenced authorization config is folded into the
228- // validated cluster (read from here downstream). The other dereferenced input,
229- // the authentication classes, is intentionally NOT stored: it is fully consumed
230- // here to build `kafka_security`. Alternative: also store the resolved auth
231- // classes — rejected because nothing downstream needs them beyond kafka_security.
232- pub authorization_config : Option < KafkaAuthorizationConfig > ,
233- pub role_groups : BTreeMap < KafkaRole , BTreeMap < String , ValidatedRoleGroupConfig > > ,
234- pub pod_descriptors : Vec < KafkaPodDescriptor > ,
235- pub metadata_manager : MetadataManager ,
228+ pub cluster_config : ValidatedClusterConfig ,
229+ pub role_group_configs : BTreeMap < KafkaRole , BTreeMap < RoleGroupName , ValidatedRoleGroupConfig > > ,
236230}
237231
238- impl ValidatedKafkaCluster {
239- #[ allow( clippy:: too_many_arguments) ]
232+ impl ValidatedCluster {
240233 pub fn new (
241234 name : ClusterName ,
242235 namespace : NamespaceName ,
243236 uid : Uid ,
244237 image : ResolvedProductImage ,
245- kafka_security : KafkaTlsSecurity ,
246- authorization_config : Option < KafkaAuthorizationConfig > ,
247- role_groups : BTreeMap < KafkaRole , BTreeMap < String , ValidatedRoleGroupConfig > > ,
248- pod_descriptors : Vec < KafkaPodDescriptor > ,
249- metadata_manager : MetadataManager ,
238+ cluster_config : ValidatedClusterConfig ,
239+ role_group_configs : BTreeMap < KafkaRole , BTreeMap < RoleGroupName , ValidatedRoleGroupConfig > > ,
250240 ) -> Self {
251241 Self {
252242 metadata : ObjectMeta {
@@ -258,18 +248,26 @@ impl ValidatedKafkaCluster {
258248 name,
259249 namespace,
260250 image,
261- kafka_security,
262- authorization_config,
263- role_groups,
264- pod_descriptors,
265- metadata_manager,
251+ cluster_config,
252+ role_group_configs,
266253 }
267254 }
268255}
269256
270- /// Lets [`ValidatedKafkaCluster`] act as the owner [`Resource`] for child objects, so owner
257+ /// Cluster-wide settings resolved during validation and dereferencing.
258+ ///
259+ /// Everything the build steps need is resolved here so they never have to read the
260+ /// raw [`v1alpha1::KafkaCluster`] spec.
261+ pub struct ValidatedClusterConfig {
262+ pub kafka_security : KafkaTlsSecurity ,
263+ pub authorization_config : Option < KafkaAuthorizationConfig > ,
264+ pub pod_descriptors : Vec < KafkaPodDescriptor > ,
265+ pub metadata_manager : MetadataManager ,
266+ }
267+
268+ /// Lets [`ValidatedCluster`] act as the owner [`Resource`] for child objects, so owner
271269/// references are built from it (via the captured `metadata`) rather than the raw CR.
272- impl Resource for ValidatedKafkaCluster {
270+ impl Resource for ValidatedCluster {
273271 type DynamicType = <v1alpha1:: KafkaCluster as Resource >:: DynamicType ;
274272 type Scope = <v1alpha1:: KafkaCluster as Resource >:: Scope ;
275273
@@ -348,10 +346,10 @@ pub async fn reconcile_kafka(
348346 . context ( CreateClusterResourcesSnafu ) ?;
349347
350348 tracing:: debug!(
351- kerberos_enabled = validated_cluster. kafka_security. has_kerberos_enabled( ) ,
352- kerberos_secret_class = ?validated_cluster. kafka_security. kerberos_secret_class( ) ,
353- tls_enabled = validated_cluster. kafka_security. tls_enabled( ) ,
354- tls_client_authentication_class = ?validated_cluster. kafka_security. tls_client_authentication_class( ) ,
349+ kerberos_enabled = validated_cluster. cluster_config . kafka_security. has_kerberos_enabled( ) ,
350+ kerberos_secret_class = ?validated_cluster. cluster_config . kafka_security. kerberos_secret_class( ) ,
351+ tls_enabled = validated_cluster. cluster_config . kafka_security. tls_enabled( ) ,
352+ tls_client_authentication_class = ?validated_cluster. cluster_config . kafka_security. tls_client_authentication_class( ) ,
355353 "The following security settings are used"
356354 ) ;
357355
@@ -377,15 +375,15 @@ pub async fn reconcile_kafka(
377375
378376 let mut bootstrap_listeners = Vec :: < listener:: v1alpha1:: Listener > :: new ( ) ;
379377
380- for ( kafka_role, rg_map) in & validated_cluster. role_groups {
378+ for ( kafka_role, rg_map) in & validated_cluster. role_group_configs {
381379 for ( rolegroup_name, validated_rg) in rg_map {
382380 let rolegroup_ref = kafka. rolegroup_ref ( kafka_role, rolegroup_name) ;
383381
384382 let rg_headless_service = build_rolegroup_headless_service (
385383 & validated_cluster,
386384 & validated_cluster. image ,
387385 & rolegroup_ref,
388- & validated_cluster. kafka_security ,
386+ & validated_cluster. cluster_config . kafka_security ,
389387 )
390388 . context ( BuildServiceSnafu ) ?;
391389
@@ -398,7 +396,7 @@ pub async fn reconcile_kafka(
398396
399397 let kafka_listeners = get_kafka_listener_config (
400398 kafka,
401- & validated_cluster. kafka_security ,
399+ & validated_cluster. cluster_config . kafka_security ,
402400 & rolegroup_ref,
403401 & client. kubernetes_cluster_info ,
404402 )
0 commit comments