Skip to content

Commit 7fd1204

Browse files
committed
fix: use SecretClassName consistently
1 parent c34f8a1 commit 7fd1204

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

rust/operator-binary/src/controller/validate.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ pub(crate) mod test_support {
397397
database_connections::drivers::jdbc::JdbcDatabaseConnection,
398398
kube::ResourceExt,
399399
v2::types::{
400-
kubernetes::{NamespaceName, Uid},
400+
kubernetes::{NamespaceName, SecretClassName, Uid},
401401
operator::ClusterName,
402402
},
403403
};
@@ -474,7 +474,10 @@ spec:
474474
)
475475
.expect("test: resolvable product image");
476476

477-
let druid_tls_security = DruidTlsSecurity::new(false, Some("tls".to_string()));
477+
let druid_tls_security = DruidTlsSecurity::new(
478+
false,
479+
Some(SecretClassName::from_str("tls").expect("test: valid secret class")),
480+
);
478481

479482
let mut role_group_configs: BTreeMap<DruidRole, BTreeMap<RoleGroupName, _>> =
480483
BTreeMap::new();

rust/operator-binary/src/crd/security.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use stackable_operator::v2::types::kubernetes::SecretClassName;
2+
13
use crate::crd::{
24
STACKABLE_TRUST_STORE_PASSWORD, authentication::AuthenticationClassesResolved, v1alpha1,
35
};
@@ -9,7 +11,7 @@ pub struct DruidTlsSecurity {
911
tls_authentication_enabled: bool,
1012
/// The TLS `SecretClass` used for external client -> server and server <-> server
1113
/// communication, if any.
12-
server_and_internal_secret_class: Option<String>,
14+
server_and_internal_secret_class: Option<SecretClassName>,
1315
}
1416

1517
// Port names (shared with the build-side renderer and other build modules)
@@ -26,7 +28,7 @@ impl DruidTlsSecurity {
2628
#[cfg(test)]
2729
pub(crate) fn new(
2830
tls_authentication_enabled: bool,
29-
server_and_internal_secret_class: Option<String>,
31+
server_and_internal_secret_class: Option<SecretClassName>,
3032
) -> Self {
3133
Self {
3234
tls_authentication_enabled,
@@ -42,13 +44,12 @@ impl DruidTlsSecurity {
4244
) -> Self {
4345
DruidTlsSecurity {
4446
tls_authentication_enabled: auth_classes.tls_authentication_enabled(),
45-
server_and_internal_secret_class: druid.spec.cluster_config.tls.as_ref().and_then(
46-
|tls| {
47-
tls.server_and_internal_secret_class
48-
.as_ref()
49-
.map(|secret_class| secret_class.to_string())
50-
},
51-
),
47+
server_and_internal_secret_class: druid
48+
.spec
49+
.cluster_config
50+
.tls
51+
.as_ref()
52+
.and_then(|tls| tls.server_and_internal_secret_class.clone()),
5253
}
5354
}
5455

@@ -71,8 +72,8 @@ impl DruidTlsSecurity {
7172

7273
/// The optional TLS `SecretClass` for external client -> server and server <-> server
7374
/// communication.
74-
pub(crate) fn server_and_internal_secret_class(&self) -> Option<&str> {
75-
self.server_and_internal_secret_class.as_deref()
75+
pub(crate) fn server_and_internal_secret_class(&self) -> Option<&SecretClassName> {
76+
self.server_and_internal_secret_class.as_ref()
7677
}
7778
}
7879

0 commit comments

Comments
 (0)