Skip to content

Commit

Permalink
make function stand-alone
Browse files Browse the repository at this point in the history
  • Loading branch information
adwk67 committed Aug 20, 2024
1 parent 4aa0d75 commit 0545c9c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
46 changes: 23 additions & 23 deletions rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,28 +671,28 @@ impl HbaseCluster {
tracing::debug!("Merged config: {:?}", conf_rolegroup);
fragment::validate(conf_rolegroup).context(FragmentValidationFailureSnafu)
}
}

pub fn merged_env(&self, rolegroup_config: Option<&BTreeMap<String, String>>) -> Vec<EnvVar> {
let merged_env: Vec<EnvVar> = if let Some(rolegroup_config) = rolegroup_config {
let env_vars_from_config: BTreeMap<String, EnvVar> = rolegroup_config
.iter()
.map(|(env_name, env_value)| {
(
env_name.clone(),
EnvVar {
name: env_name.clone(),
value: Some(env_value.to_owned()),
value_from: None,
},
)
})
.collect();
env_vars_from_config.into_values().collect()
} else {
vec![]
};
merged_env
}
pub fn merged_env(rolegroup_config: Option<&BTreeMap<String, String>>) -> Vec<EnvVar> {
let merged_env: Vec<EnvVar> = if let Some(rolegroup_config) = rolegroup_config {
let env_vars_from_config: BTreeMap<String, EnvVar> = rolegroup_config
.iter()
.map(|(env_name, env_value)| {
(
env_name.clone(),
EnvVar {
name: env_name.clone(),
value: Some(env_value.to_owned()),
value_from: None,
},
)
})
.collect();
env_vars_from_config.into_values().collect()
} else {
vec![]
};
merged_env
}

#[cfg(test)]
Expand All @@ -704,7 +704,7 @@ mod tests {
transform_all_roles_to_config, validate_all_roles_and_groups_config,
};

use crate::{HbaseCluster, HbaseRole};
use crate::{merged_env, HbaseCluster, HbaseRole};

use product_config::{types::PropertyNameKind, ProductConfigManager};

Expand Down Expand Up @@ -779,7 +779,7 @@ spec:
.get("default")
.unwrap()
.get(&PropertyNameKind::Env);
let merged_env = hbase.merged_env(rolegroup_config);
let merged_env = merged_env(rolegroup_config);

let env_map: BTreeMap<&str, Option<String>> = merged_env
.iter()
Expand Down
8 changes: 4 additions & 4 deletions rust/operator-binary/src/hbase_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ use stackable_operator::{
use strum::{EnumDiscriminants, IntoStaticStr, ParseError};

use stackable_hbase_crd::{
Container, HbaseCluster, HbaseClusterStatus, HbaseConfig, HbaseConfigFragment, HbaseRole,
APP_NAME, CONFIG_DIR_NAME, HBASE_ENV_SH, HBASE_HEAPSIZE, HBASE_MANAGES_ZK, HBASE_MASTER_OPTS,
HBASE_REGIONSERVER_OPTS, HBASE_REST_OPTS, HBASE_REST_PORT_NAME_HTTP,
merged_env, Container, HbaseCluster, HbaseClusterStatus, HbaseConfig, HbaseConfigFragment,
HbaseRole, APP_NAME, CONFIG_DIR_NAME, HBASE_ENV_SH, HBASE_HEAPSIZE, HBASE_MANAGES_ZK,
HBASE_MASTER_OPTS, HBASE_REGIONSERVER_OPTS, HBASE_REST_OPTS, HBASE_REST_PORT_NAME_HTTP,
HBASE_REST_PORT_NAME_HTTPS, HBASE_SITE_XML, JVM_HEAP_FACTOR, JVM_SECURITY_PROPERTIES_FILE,
METRICS_PORT, SSL_CLIENT_XML, SSL_SERVER_XML,
};
Expand Down Expand Up @@ -820,7 +820,7 @@ fn build_rolegroup_statefulset(
..probe_template
};

let merged_env = hbase.merged_env(rolegroup_config.get(&PropertyNameKind::Env));
let merged_env = merged_env(rolegroup_config.get(&PropertyNameKind::Env));

let log4j_properties_file_name =
log4j_properties_file_name(&resolved_product_image.product_version);
Expand Down

0 comments on commit 0545c9c

Please sign in to comment.