Skip to content

Commit fd3966e

Browse files
committed
refactor: use restarter_ignore_secret_annotations
1 parent fb858b0 commit fd3966e

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Builds the per-rolegroup [`StatefulSet`] that runs a Trino role group.
22
3-
use std::{collections::BTreeMap, convert::Infallible, str::FromStr};
3+
use std::{convert::Infallible, str::FromStr};
44

55
use snafu::{OptionExt, ResultExt, Snafu};
66
use stackable_operator::{
@@ -30,13 +30,16 @@ use stackable_operator::{
3030
},
3131
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
3232
},
33-
kvp::{Annotation, Annotations},
33+
kvp::Annotation,
3434
product_logging,
3535
shared::time::Duration,
3636
v2::{
37-
builder::{meta::ownerreference_from_resource, pod::container::EnvVarSet},
37+
builder::{
38+
meta::ownerreference_from_resource, pod::container::EnvVarSet,
39+
statefulset::restarter_ignore_secret_annotations,
40+
},
3841
product_logging::framework::{ValidatedContainerLogConfigChoice, vector_container},
39-
types::kubernetes::{ContainerName, VolumeName},
42+
types::kubernetes::{ContainerName, SecretName, VolumeName},
4043
},
4144
};
4245

@@ -102,6 +105,11 @@ pub enum Error {
102105
source: stackable_operator::kvp::KeyValuePairError<Infallible>,
103106
},
104107

108+
#[snafu(display("failed to parse hot-reloaded Secret name"))]
109+
ParseSecretName {
110+
source: stackable_operator::v2::macros::attributed_string_type::Error,
111+
},
112+
105113
#[snafu(display("failed to build Metadata"))]
106114
MetadataBuild {
107115
source: stackable_operator::builder::meta::Error,
@@ -443,20 +451,14 @@ pub fn build_rolegroup_statefulset(
443451
pod_template.merge_from(role.config.pod_overrides.clone());
444452
pod_template.merge_from(rolegroup.config.pod_overrides.clone());
445453

446-
let ignore_secret_annotations = trino_authentication_config
454+
let ignore_secrets = trino_authentication_config
447455
.hot_reloaded_secrets()
448456
.iter()
449-
.enumerate()
450-
.map(|(i, secret_name)| {
451-
(
452-
format!("restarter.stackable.tech/ignore-secret.{i}"),
453-
secret_name,
454-
)
455-
})
456-
.collect::<BTreeMap<_, _>>();
457+
.map(|secret_name| SecretName::from_str(secret_name))
458+
.collect::<std::result::Result<Vec<_>, _>>()
459+
.context(ParseSecretNameSnafu)?;
457460

458-
let annotations =
459-
Annotations::try_from(ignore_secret_annotations).context(AnnotationBuildSnafu)?;
461+
let annotations = restarter_ignore_secret_annotations(ignore_secrets);
460462

461463
Ok(StatefulSet {
462464
metadata: ObjectMetaBuilder::new()

0 commit comments

Comments
 (0)