Skip to content

Commit 5c0b3b8

Browse files
committed
Revert "Remove missleading function"
This reverts commit 08759f1.
1 parent 8472dbf commit 5c0b3b8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

crates/stackable-operator/src/role_utils.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,15 @@ use kube::{runtime::reflector::ObjectRef, Resource};
100100
use regex::Regex;
101101
use schemars::JsonSchema;
102102
use serde::{Deserialize, Serialize};
103+
use snafu::{OptionExt, Snafu};
103104
use tracing::instrument;
104105

106+
#[derive(Debug, Snafu)]
107+
pub enum Error {
108+
#[snafu(display("missing roleGroup {role_group:?}"))]
109+
MissingRoleGroup { role_group: String },
110+
}
111+
105112
#[derive(Clone, Debug, Default, Deserialize, JsonSchema, PartialEq, Serialize)]
106113
#[serde(
107114
rename_all = "camelCase",
@@ -358,6 +365,30 @@ where
358365
.collect(),
359366
}
360367
}
368+
369+
/// Returns the product specific common config from
370+
/// 1. The role
371+
/// 2. The role group
372+
pub fn merged_product_specific_common_configs<'a>(
373+
&'a self,
374+
role_group: &str,
375+
) -> Result<
376+
(
377+
&'a ProductSpecificCommonConfig,
378+
&'a ProductSpecificCommonConfig,
379+
),
380+
Error,
381+
> {
382+
let from_role = &self.config.product_specific_common_config;
383+
let from_role_group = &self
384+
.role_groups
385+
.get(role_group)
386+
.with_context(|| MissingRoleGroupSnafu { role_group })?
387+
.config
388+
.product_specific_common_config;
389+
390+
Ok((from_role, from_role_group))
391+
}
361392
}
362393

363394
/// This is a product-agnostic RoleConfig, which is sufficient for most of the products.
@@ -489,6 +520,10 @@ mod tests {
489520
)
490521
.unwrap();
491522

523+
// let mut merged = role_group;
524+
// merged.merge(&role);
525+
// merged.merge(&operator_generated);
526+
492527
// Please note that merge order is different than we normally do!
493528
// This is not trivial, as the merge operation is not purely additive (as it is with e.g.
494529
// PodTemplateSpec).

0 commit comments

Comments
 (0)