Skip to content

Commit 2af6a04

Browse files
committed
refactor: use v2 SecretName
1 parent fd3966e commit 2af6a04

3 files changed

Lines changed: 25 additions & 20 deletions

File tree

rust/operator-binary/src/authentication/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use stackable_operator::{
1919
crd::authentication::core,
2020
k8s_openapi::api::core::v1::{Container, EnvVar, Volume, VolumeMount},
2121
kube::{ResourceExt, runtime::reflector::ObjectRef},
22+
v2::types::kubernetes::SecretName,
2223
};
2324
use strum::EnumDiscriminants;
2425
use tracing::trace;
@@ -95,7 +96,7 @@ pub struct TrinoAuthenticationConfig {
9596
/// Additional side car container for the provided role
9697
sidecar_containers: HashMap<TrinoRole, Vec<Container>>,
9798
/// Secrets which can be hot-reloaded and should be excluded from the restart controller
98-
hot_reloaded_secrets: BTreeSet<String>,
99+
hot_reloaded_secrets: BTreeSet<SecretName>,
99100
}
100101

101102
impl TrinoAuthenticationConfig {
@@ -371,12 +372,12 @@ impl TrinoAuthenticationConfig {
371372
}
372373

373374
/// Retrieve all Secrets which can be hot-reloaded
374-
pub fn hot_reloaded_secrets(&self) -> &BTreeSet<String> {
375+
pub fn hot_reloaded_secrets(&self) -> &BTreeSet<SecretName> {
375376
&self.hot_reloaded_secrets
376377
}
377378

378379
/// Add a Secret which can be hot-reloaded
379-
pub fn add_hot_reloaded_secret(&mut self, secret_name: String) {
380+
pub fn add_hot_reloaded_secret(&mut self, secret_name: SecretName) {
380381
self.hot_reloaded_secrets.insert(secret_name);
381382
}
382383

rust/operator-binary/src/authentication/password/mod.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
//! - volume and volume mounts
99
//! - extra containers and commands
1010
//!
11+
use std::str::FromStr;
12+
1113
use snafu::{ResultExt, Snafu};
12-
use stackable_operator::commons::product_image_selection::ResolvedProductImage;
14+
use stackable_operator::{
15+
commons::product_image_selection::ResolvedProductImage, v2::types::kubernetes::SecretName,
16+
};
1317
use tracing::trace;
1418

1519
use crate::{
@@ -37,6 +41,11 @@ pub enum Error {
3741

3842
#[snafu(display("failed to create LDAP Volumes and VolumeMounts"))]
3943
BuildPasswordFileUpdateContainer { source: file::Error },
44+
45+
#[snafu(display("failed to parse user credentials Secret name"))]
46+
ParseSecretName {
47+
source: stackable_operator::v2::macros::attributed_string_type::Error,
48+
},
4049
}
4150

4251
#[derive(Clone, Debug, Default)]
@@ -105,8 +114,10 @@ impl TrinoPasswordAuthentication {
105114
FileAuthenticator::password_db_volume_mount(),
106115
);
107116

108-
password_authentication_config
109-
.add_hot_reloaded_secret(file_authenticator.secret_name());
117+
password_authentication_config.add_hot_reloaded_secret(
118+
SecretName::from_str(&file_authenticator.secret_name())
119+
.context(ParseSecretNameSnafu)?,
120+
);
110121
}
111122
TrinoPasswordAuthenticator::Ldap(ldap_authenticator) => {
112123
let config_file_name = ldap_authenticator.config_file_name();

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use stackable_operator::{
3939
statefulset::restarter_ignore_secret_annotations,
4040
},
4141
product_logging::framework::{ValidatedContainerLogConfigChoice, vector_container},
42-
types::kubernetes::{ContainerName, SecretName, VolumeName},
42+
types::kubernetes::{ContainerName, VolumeName},
4343
},
4444
};
4545

@@ -105,11 +105,6 @@ pub enum Error {
105105
source: stackable_operator::kvp::KeyValuePairError<Infallible>,
106106
},
107107

108-
#[snafu(display("failed to parse hot-reloaded Secret name"))]
109-
ParseSecretName {
110-
source: stackable_operator::v2::macros::attributed_string_type::Error,
111-
},
112-
113108
#[snafu(display("failed to build Metadata"))]
114109
MetadataBuild {
115110
source: stackable_operator::builder::meta::Error,
@@ -451,14 +446,12 @@ pub fn build_rolegroup_statefulset(
451446
pod_template.merge_from(role.config.pod_overrides.clone());
452447
pod_template.merge_from(rolegroup.config.pod_overrides.clone());
453448

454-
let ignore_secrets = trino_authentication_config
455-
.hot_reloaded_secrets()
456-
.iter()
457-
.map(|secret_name| SecretName::from_str(secret_name))
458-
.collect::<std::result::Result<Vec<_>, _>>()
459-
.context(ParseSecretNameSnafu)?;
460-
461-
let annotations = restarter_ignore_secret_annotations(ignore_secrets);
449+
let annotations = restarter_ignore_secret_annotations(
450+
trino_authentication_config
451+
.hot_reloaded_secrets()
452+
.iter()
453+
.cloned(),
454+
);
462455

463456
Ok(StatefulSet {
464457
metadata: ObjectMetaBuilder::new()

0 commit comments

Comments
 (0)