Skip to content

Commit

Permalink
use snafu errors (stackabletech/operator-rs#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
NickLarsenNZ committed Jan 11, 2024
1 parent 38817d2 commit ebae1ae
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions rust/operator-binary/src/discovery.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
use std::collections::BTreeMap;

use product_config::writer::to_hadoop_xml;
use snafu::{ResultExt, Snafu};
use stackable_hbase_crd::{HbaseCluster, HbaseRole, HBASE_SITE_XML};
use stackable_operator::{
builder::{ConfigMapBuilder, ObjectMetaBuilder},
builder::{ConfigMapBuilder, ObjectMetaBuilder, ObjectMetaBuilderError},
commons::product_image_selection::ResolvedProductImage,
error::OperatorResult,
k8s_openapi::api::core::v1::ConfigMap,
};

use crate::{
hbase_controller::build_recommended_labels, zookeeper::ZookeeperConnectionInformation,
};

type Result<T, E = Error> = std::result::Result<T, E>;

#[derive(Snafu, Debug)]
pub enum Error {
#[snafu(display("failed to build ConfigMap"))]
BuildConfigMap {
source: stackable_operator::error::Error,
},

#[snafu(display("failed to build object meta data"))]
ObjectMeta { source: ObjectMetaBuilderError },
}

/// Creates a discovery config map containing the `hbase-site.xml` for clients.
pub fn build_discovery_configmap(
hbase: &HbaseCluster,
zookeeper_connection_information: &ZookeeperConnectionInformation,
resolved_product_image: &ResolvedProductImage,
) -> OperatorResult<ConfigMap> {
) -> Result<ConfigMap> {
let hbase_site = zookeeper_connection_information.as_hbase_settings();

ConfigMapBuilder::new()
Expand All @@ -32,6 +45,7 @@ pub fn build_discovery_configmap(
&HbaseRole::RegionServer.to_string(),
"discovery",
))
.context(ObjectMetaSnafu)?
.build(),
)
.add_data(
Expand All @@ -45,4 +59,5 @@ pub fn build_discovery_configmap(
),
)
.build()
.context(BuildConfigMapSnafu)
}

0 comments on commit ebae1ae

Please sign in to comment.