Skip to content

Commit 7171c3e

Browse files
committed
refactor: Make the DaemonSet builder take a ServiceAccount name
1 parent 172e18b commit 7171c3e

2 files changed

Lines changed: 6 additions & 22 deletions

File tree

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

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ use stackable_operator::{
3030
apps::v1::{DaemonSet, DaemonSetSpec, DaemonSetUpdateStrategy, RollingUpdateDaemonSet},
3131
core::v1::{
3232
EmptyDirVolumeSource, EnvVarSource, HTTPGetAction, ObjectFieldSelector, Probe,
33-
ResourceRequirements, SecretVolumeSource, ServiceAccount,
33+
ResourceRequirements, SecretVolumeSource,
3434
},
3535
},
3636
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
3737
},
38-
kube::ResourceExt,
3938
memory::{BinaryMultiple, MemoryQuantity},
4039
product_logging::{
4140
self,
@@ -245,7 +244,7 @@ pub fn build_server_rolegroup_daemonset(
245244
role_group: &OpaRoleGroupConfig,
246245
opa_bundle_builder_image: &str,
247246
user_info_fetcher_image: &str,
248-
service_account: &ServiceAccount,
247+
service_account_name: &str,
249248
cluster_info: &KubernetesClusterInfo,
250249
) -> Result<DaemonSet> {
251250
let resolved_product_image = &cluster.image;
@@ -405,7 +404,7 @@ pub fn build_server_rolegroup_daemonset(
405404
.build(),
406405
)
407406
.context(AddVolumeSnafu)?
408-
.service_account_name(service_account.name_any())
407+
.service_account_name(service_account_name)
409408
.security_context(PodSecurityContextBuilder::new().fs_group(1000).build());
410409

411410
if let Some(tls) = &cluster.cluster_config.tls {
@@ -847,12 +846,7 @@ fn build_prepare_start_command(
847846
#[cfg(test)]
848847
mod tests {
849848
use serde_json::json;
850-
use stackable_operator::{
851-
commons::networking::DomainName,
852-
k8s_openapi::{
853-
api::core::v1::ServiceAccount, apimachinery::pkg::apis::meta::v1::ObjectMeta,
854-
},
855-
};
849+
use stackable_operator::commons::networking::DomainName;
856850

857851
use super::*;
858852
use crate::{
@@ -865,16 +859,6 @@ mod tests {
865859
}
866860
}
867861

868-
fn service_account() -> ServiceAccount {
869-
ServiceAccount {
870-
metadata: ObjectMeta {
871-
name: Some("test-opa-serviceaccount".to_owned()),
872-
..Default::default()
873-
},
874-
..Default::default()
875-
}
876-
}
877-
878862
fn build(cluster: &ValidatedCluster) -> DaemonSet {
879863
let (role_group_name, role_group) = cluster.role_group_configs[&OpaRole::Server]
880864
.iter()
@@ -886,7 +870,7 @@ mod tests {
886870
role_group,
887871
"bundle-builder-image",
888872
"user-info-fetcher-image",
889-
&service_account(),
873+
"test-opa-serviceaccount",
890874
&cluster_info(),
891875
)
892876
.expect("the daemonset should build")

rust/operator-binary/src/opa_controller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pub async fn reconcile_opa(
228228
rolegroup,
229229
&ctx.opa_bundle_builder_image,
230230
&ctx.user_info_fetcher_image,
231-
&rbac_sa,
231+
&rbac_sa.name_any(),
232232
&ctx.cluster_info,
233233
)
234234
.with_context(|_| BuildRoleGroupDaemonSetSnafu {

0 commit comments

Comments
 (0)