@@ -45,7 +45,7 @@ use stackable_operator::{
4545 } ,
4646 role_utils:: { JavaCommonConfig , RoleGroupConfig , with_validated_config} ,
4747 types:: {
48- kubernetes:: ConfigMapName ,
48+ kubernetes:: { ConfigMapName , ListenerClassName } ,
4949 operator:: { RoleGroupName , RoleName } ,
5050 } ,
5151 } ,
@@ -199,11 +199,6 @@ pub enum Error {
199199 "the Vector agent is enabled but the Vector aggregator ConfigMap name is missing"
200200 ) ) ]
201201 MissingVectorAggregatorConfigMapName ,
202-
203- #[ snafu( display( "invalid Vector aggregator ConfigMap name" ) ) ]
204- ParseVectorAggregatorConfigMapName {
205- source : stackable_operator:: v2:: macros:: attributed_string_type:: Error ,
206- } ,
207202}
208203
209204#[ versioned(
@@ -328,14 +323,14 @@ pub mod versioned {
328323 /// Provide the name of the ZooKeeper [discovery ConfigMap](DOCS_BASE_URL_PLACEHOLDER/concepts/service_discovery)
329324 /// here. When using the [Stackable operator for Apache ZooKeeper](DOCS_BASE_URL_PLACEHOLDER/zookeeper/)
330325 /// to deploy a ZooKeeper cluster, this will simply be the name of your ZookeeperCluster resource.
331- pub zookeeper_config_map_name : String ,
326+ pub zookeeper_config_map_name : ConfigMapName ,
332327
333328 /// Name of the Vector aggregator [discovery ConfigMap](DOCS_BASE_URL_PLACEHOLDER/concepts/service_discovery).
334329 /// It must contain the key `ADDRESS` with the address of the Vector aggregator.
335330 /// Follow the [logging tutorial](DOCS_BASE_URL_PLACEHOLDER/tutorials/logging-vector-aggregator)
336331 /// to learn how to configure log aggregation with Vector.
337332 #[ serde( skip_serializing_if = "Option::is_none" ) ]
338- pub vector_aggregator_config_map_name : Option < String > ,
333+ pub vector_aggregator_config_map_name : Option < ConfigMapName > ,
339334
340335 /// Extra volumes similar to `.spec.volumes` on a Pod to mount into every container, this can be useful to for
341336 /// example make client certificates, keytabs or similar things available to processors. These volumes will be
@@ -351,7 +346,7 @@ pub mod versioned {
351346 pub generic : GenericRoleConfig ,
352347
353348 #[ serde( default = "druid_default_listener_class" ) ]
354- pub listener_class : String ,
349+ pub listener_class : ListenerClassName ,
355350 }
356351}
357352
@@ -468,16 +463,14 @@ impl v1alpha1::DruidCluster {
468463 let deep_storage = & self . spec . cluster_config . deep_storage ;
469464 let name = self . name_any ( ) ;
470465
471- // The Vector aggregator discovery ConfigMap name (validated here so an invalid name fails
472- // up-front). It is only required when the Vector agent is enabled for a role group.
466+ // The Vector aggregator discovery ConfigMap name (a typed `ConfigMapName`, so an invalid
467+ // name is already rejected at deserialization). It is only required when the Vector agent
468+ // is enabled for a role group.
473469 let vector_aggregator_config_map_name = self
474470 . spec
475471 . cluster_config
476472 . vector_aggregator_config_map_name
477- . as_deref ( )
478- . map ( ConfigMapName :: from_str)
479- . transpose ( )
480- . context ( ParseVectorAggregatorConfigMapNameSnafu ) ?;
473+ . clone ( ) ;
481474
482475 // All roles erase to an identical `ValidatedDruidConfig`; only the typed config, the role
483476 // config type and the `RoleResource` variant (historicals carry typed storage) differ.
@@ -705,8 +698,8 @@ impl Default for v1alpha1::DruidRoleConfig {
705698 }
706699}
707700
708- fn druid_default_listener_class ( ) -> String {
709- "cluster-internal" . to_string ( )
701+ fn druid_default_listener_class ( ) -> ListenerClassName {
702+ ListenerClassName :: from_str ( "cluster-internal" ) . expect ( "a valid listener class name" )
710703}
711704
712705#[ derive(
@@ -851,7 +844,7 @@ impl DruidRole {
851844 }
852845 }
853846
854- pub fn listener_class_name ( & self , druid : & v1alpha1:: DruidCluster ) -> Option < String > {
847+ pub fn listener_class_name ( & self , druid : & v1alpha1:: DruidCluster ) -> Option < ListenerClassName > {
855848 match self {
856849 Self :: Broker => Some ( druid. spec . brokers . role_config . listener_class . to_owned ( ) ) ,
857850 Self :: Coordinator => Some (
@@ -893,7 +886,7 @@ pub struct HdfsDeepStorageSpec {
893886 /// The [discovery ConfigMap](DOCS_BASE_URL_PLACEHOLDER/concepts/service_discovery)
894887 /// for the HDFS instance. When running an HDFS cluster with the Stackable operator, the operator
895888 /// will create this ConfigMap for you. It has the same name as your HDFSCluster resource.
896- pub config_map_name : String ,
889+ pub config_map_name : ConfigMapName ,
897890 /// The directory inside of HDFS where Druid should store its data.
898891 pub directory : String ,
899892}
0 commit comments