11use std:: collections:: BTreeMap ;
22
33use product_config:: writer:: to_hadoop_xml;
4+ use snafu:: { ResultExt , Snafu } ;
45use stackable_hbase_crd:: { HbaseCluster , HbaseRole , HBASE_SITE_XML } ;
56use stackable_operator:: {
6- builder:: { ConfigMapBuilder , ObjectMetaBuilder } ,
7+ builder:: { ConfigMapBuilder , ObjectMetaBuilder , ObjectMetaBuilderError } ,
78 commons:: product_image_selection:: ResolvedProductImage ,
8- error:: OperatorResult ,
99 k8s_openapi:: api:: core:: v1:: ConfigMap ,
1010} ;
1111
1212use crate :: {
1313 hbase_controller:: build_recommended_labels, zookeeper:: ZookeeperConnectionInformation ,
1414} ;
1515
16+ type Result < T , E = Error > = std:: result:: Result < T , E > ;
17+
18+ #[ derive( Snafu , Debug ) ]
19+ pub enum Error {
20+ #[ snafu( display( "failed to build ConfigMap" ) ) ]
21+ BuildConfigMap {
22+ source : stackable_operator:: error:: Error ,
23+ } ,
24+
25+ #[ snafu( display( "failed to build object meta data" ) ) ]
26+ ObjectMeta { source : ObjectMetaBuilderError } ,
27+ }
28+
1629/// Creates a discovery config map containing the `hbase-site.xml` for clients.
1730pub fn build_discovery_configmap (
1831 hbase : & HbaseCluster ,
1932 zookeeper_connection_information : & ZookeeperConnectionInformation ,
2033 resolved_product_image : & ResolvedProductImage ,
21- ) -> OperatorResult < ConfigMap > {
34+ ) -> Result < ConfigMap > {
2235 let hbase_site = zookeeper_connection_information. as_hbase_settings ( ) ;
2336
2437 ConfigMapBuilder :: new ( )
@@ -32,6 +45,7 @@ pub fn build_discovery_configmap(
3245 & HbaseRole :: RegionServer . to_string ( ) ,
3346 "discovery" ,
3447 ) )
48+ . context ( ObjectMetaSnafu ) ?
3549 . build ( ) ,
3650 )
3751 . add_data (
@@ -45,4 +59,5 @@ pub fn build_discovery_configmap(
4559 ) ,
4660 )
4761 . build ( )
62+ . context ( BuildConfigMapSnafu )
4863}
0 commit comments