Skip to content

Commit 3032234

Browse files
committed
refactor: remove redudant paramters from build_statefulset
1 parent c6cefe5 commit 3032234

2 files changed

Lines changed: 15 additions & 25 deletions

File tree

rust/operator-binary/src/controller/build/resource/statefulset.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ use stackable_operator::{
1414
volume::{SecretFormat, SecretOperatorVolumeSourceBuilder, VolumeBuilder},
1515
},
1616
},
17-
commons::{
18-
product_image_selection::ResolvedProductImage,
19-
secret_class::SecretClassVolumeProvisionParts,
20-
},
17+
commons::secret_class::SecretClassVolumeProvisionParts,
2118
constants::RESTART_CONTROLLER_ENABLED_LABEL,
2219
k8s_openapi::{
2320
DeepMerge,
@@ -44,13 +41,12 @@ use stackable_operator::{
4441
};
4542

4643
use crate::{
47-
authentication::TrinoAuthenticationConfig,
4844
authorization::opa::{OPA_TLS_VOLUME_NAME, TrinoOpaConfig},
4945
catalog::config::CatalogConfig,
5046
command,
5147
config::{client_protocol, fault_tolerant_execution},
5248
controller::{
53-
ValidatedCluster, ValidatedTrinoConfig, build,
49+
TrinoRoleGroupConfig, ValidatedCluster, build,
5450
build::resource::listener::{
5551
LISTENER_VOLUME_DIR, LISTENER_VOLUME_NAME, build_group_listener_pvc,
5652
group_listener_name, secret_volume_listener_scope,
@@ -143,22 +139,25 @@ type Result<T, E = Error> = std::result::Result<T, E>;
143139
/// The [`Pod`](`stackable_operator::k8s_openapi::api::core::v1::Pod`)s are accessible through the
144140
/// corresponding [`stackable_operator::k8s_openapi::api::core::v1::Service`] (from
145141
/// [`build_rolegroup_headless_service`](super::service::build_rolegroup_headless_service)).
146-
#[allow(clippy::too_many_arguments)]
147142
pub fn build_rolegroup_statefulset(
148143
trino: &v1alpha1::TrinoCluster,
149144
cluster: &ValidatedCluster,
150145
trino_role: &TrinoRole,
151-
resolved_product_image: &ResolvedProductImage,
152146
role_group_name: &str,
153-
env_overrides: &EnvVarSet,
154-
merged_config: &ValidatedTrinoConfig,
155-
trino_authentication_config: &TrinoAuthenticationConfig,
156-
catalogs: &[CatalogConfig],
147+
role_group_config: &TrinoRoleGroupConfig,
157148
sa_name: &str,
158-
resolved_fte_config: &Option<fault_tolerant_execution::ResolvedFaultTolerantExecutionConfig>,
159-
resolved_spooling_config: &Option<client_protocol::ResolvedClientProtocolConfig>,
160-
trino_opa_config: &Option<TrinoOpaConfig>,
161149
) -> Result<StatefulSet> {
150+
// Everything below is derived from the validated cluster and the validated role-group config,
151+
// so the caller only needs to pass those (plus the applied ServiceAccount name).
152+
let resolved_product_image = &cluster.image;
153+
let trino_authentication_config = &cluster.cluster_config.authentication;
154+
let catalogs = cluster.cluster_config.catalogs.as_slice();
155+
let resolved_fte_config = &cluster.cluster_config.fault_tolerant_execution;
156+
let resolved_spooling_config = &cluster.cluster_config.client_protocol;
157+
let trino_opa_config = &cluster.cluster_config.authorization;
158+
let env_overrides = &role_group_config.env_overrides;
159+
let merged_config = &role_group_config.config;
160+
162161
let role = trino
163162
.role(trino_role)
164163
.context(InternalOperatorFailureSnafu)?;

rust/operator-binary/src/trino_controller.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,6 @@ pub async fn reconcile_trino(
249249

250250
for (trino_role, role_group_configs) in &validated_cluster.role_group_configs {
251251
for (role_group_name, rg) in role_group_configs {
252-
let merged_config = &rg.config;
253-
254252
let role_group_service_recommended_labels =
255253
validated_cluster.recommended_labels(trino_role, role_group_name);
256254

@@ -300,16 +298,9 @@ pub async fn reconcile_trino(
300298
trino,
301299
&validated_cluster,
302300
trino_role,
303-
&validated_cluster.image,
304301
role_group_name,
305-
&rg.env_overrides,
306-
merged_config,
307-
&validated_cluster.cluster_config.authentication,
308-
&validated_cluster.cluster_config.catalogs,
302+
rg,
309303
&rbac_sa.name_any(),
310-
&validated_cluster.cluster_config.fault_tolerant_execution,
311-
&validated_cluster.cluster_config.client_protocol,
312-
&validated_cluster.cluster_config.authorization,
313304
)
314305
.with_context(|_| BuildRoleGroupStatefulSetSnafu {
315306
rolegroup: role_group_name.clone(),

0 commit comments

Comments
 (0)