44use snafu:: { ResultExt , Snafu } ;
55use stackable_operator:: {
66 builder:: { configmap:: ConfigMapBuilder , meta:: ObjectMetaBuilder } ,
7- commons:: product_image_selection:: ResolvedProductImage ,
87 crd:: listener:: v1alpha1:: Listener ,
98 k8s_openapi:: api:: core:: v1:: ConfigMap ,
10- kube:: { Resource , ResourceExt , runtime :: reflector :: ObjectRef } ,
9+ kube:: { Resource , ResourceExt } ,
1110} ;
1211
1312use crate :: {
1413 DRUID_CONTROLLER_NAME ,
15- crd:: { DruidRole , build_recommended_labels, security:: DruidTlsSecurity , v1alpha1} ,
14+ controller:: validate:: ValidatedCluster ,
15+ crd:: { DruidRole , build_recommended_labels} ,
1616 listener:: build_listener_connection_string,
1717} ;
1818
1919#[ derive( Snafu , Debug ) ]
2020pub enum Error {
21- #[ snafu( display( "object {} is missing metadata to build owner reference" , druid ) ) ]
21+ #[ snafu( display( "object is missing metadata to build owner reference" ) ) ]
2222 ObjectMissingMetadataForOwnerRef {
2323 source : stackable_operator:: builder:: meta:: Error ,
24- druid : ObjectRef < v1alpha1:: DruidCluster > ,
2524 } ,
2625
2726 #[ snafu( display( "failed to get service FQDN" ) ) ]
@@ -41,37 +40,28 @@ pub enum Error {
4140 ListenerConfiguration { source : crate :: listener:: Error } ,
4241}
4342
44- /// Builds discovery [`ConfigMap`]s for connecting to a [`v1alpha1::DruidCluster`] .
43+ /// Builds discovery [`ConfigMap`]s for connecting to a Druid cluster .
4544pub async fn build_discovery_configmaps (
46- druid : & v1alpha1 :: DruidCluster ,
45+ cluster : & ValidatedCluster ,
4746 owner : & impl Resource < DynamicType = ( ) > ,
48- resolved_product_image : & ResolvedProductImage ,
49- druid_tls_security : & DruidTlsSecurity ,
5047 listener : Listener ,
5148) -> Result < Vec < ConfigMap > , Error > {
5249 let name = owner. name_unchecked ( ) ;
5350 Ok ( vec ! [ build_discovery_configmap(
54- druid,
55- owner,
56- resolved_product_image,
57- druid_tls_security,
58- & name,
59- listener,
51+ cluster, owner, & name, listener,
6052 ) ?] )
6153}
6254
63- /// Build a discovery [`ConfigMap`] containing information about how to connect to a certain [`v1alpha1::DruidCluster`] .
55+ /// Build a discovery [`ConfigMap`] containing information about how to connect to a certain Druid cluster .
6456fn build_discovery_configmap (
65- druid : & v1alpha1 :: DruidCluster ,
57+ cluster : & ValidatedCluster ,
6658 owner : & impl Resource < DynamicType = ( ) > ,
67- resolved_product_image : & ResolvedProductImage ,
68- druid_tls_security : & DruidTlsSecurity ,
6959 name : & str ,
7060 listener : Listener ,
7161) -> Result < ConfigMap , Error > {
7262 let router_host = build_listener_connection_string (
7363 listener,
74- druid_tls_security,
64+ & cluster . cluster_config . druid_tls_security ,
7565 & DruidRole :: Router . to_string ( ) ,
7666 )
7767 . context ( ListenerConfigurationSnafu ) ?;
@@ -84,16 +74,14 @@ fn build_discovery_configmap(
8474 ConfigMapBuilder :: new ( )
8575 . metadata (
8676 ObjectMetaBuilder :: new ( )
87- . name_and_namespace ( druid )
77+ . name_and_namespace ( owner )
8878 . name ( name)
8979 . ownerreference_from_resource ( owner, None , Some ( true ) )
90- . with_context ( |_| ObjectMissingMetadataForOwnerRefSnafu {
91- druid : ObjectRef :: from_obj ( druid) ,
92- } ) ?
80+ . context ( ObjectMissingMetadataForOwnerRefSnafu ) ?
9381 . with_recommended_labels ( & build_recommended_labels (
94- druid ,
82+ owner ,
9583 DRUID_CONTROLLER_NAME ,
96- & resolved_product_image . app_version_label_value ,
84+ & cluster . image . app_version_label_value ,
9785 & DruidRole :: Router . to_string ( ) ,
9886 "discovery" ,
9987 ) )
0 commit comments