Skip to content

Commit 8dbaa56

Browse files
feat: Add SecretOperatorVolumeSourceBuilder::with_auto_tls_cert_domain_components_in_subject_dn (#1209)
* feat: Support the annotation "secrets.stackable.tech/backend.autotls.cert.domain-components-in-subject-dn" * chore: Update changelog * Revise code
1 parent 310758d commit 8dbaa56

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

crates/stackable-operator/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Support the annotation `secrets.stackable.tech/backend.autotls.cert.domain-components-in-subject-dn`
10+
in the `SecretOperatorVolumeSourceBuilder` ([#1209]).
11+
12+
[#1209]: https://github.com/stackabletech/operator-rs/pull/1209
13+
714
## [0.113.0] - 2026-06-22
815

916
### Added

crates/stackable-operator/src/builder/pod/volume.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ pub struct SecretOperatorVolumeSourceBuilder {
280280
kerberos_service_names: Vec<String>,
281281
tls_pkcs12_password: Option<String>,
282282
auto_tls_cert_lifetime: Option<Duration>,
283+
auto_tls_cert_domain_components_in_subject_dn: Option<bool>,
283284
provision_parts: SecretClassVolumeProvisionParts,
284285
}
285286

@@ -302,6 +303,7 @@ impl SecretOperatorVolumeSourceBuilder {
302303
kerberos_service_names: Vec::new(),
303304
tls_pkcs12_password: None,
304305
auto_tls_cert_lifetime: None,
306+
auto_tls_cert_domain_components_in_subject_dn: None,
305307
provision_parts,
306308
}
307309
}
@@ -311,6 +313,14 @@ impl SecretOperatorVolumeSourceBuilder {
311313
self
312314
}
313315

316+
pub fn with_auto_tls_cert_domain_components_in_subject_dn(
317+
&mut self,
318+
enabled: bool,
319+
) -> &mut Self {
320+
self.auto_tls_cert_domain_components_in_subject_dn = Some(enabled);
321+
self
322+
}
323+
314324
pub fn with_node_scope(&mut self) -> &mut Self {
315325
self.scopes.push(SecretOperatorVolumeScope::Node);
316326
self
@@ -391,6 +401,12 @@ impl SecretOperatorVolumeSourceBuilder {
391401
);
392402
}
393403

404+
if let Some(enabled) = self.auto_tls_cert_domain_components_in_subject_dn {
405+
annotations.insert(Annotation::auto_tls_cert_domain_components_in_subject_dn(
406+
enabled,
407+
));
408+
}
409+
394410
Ok(EphemeralVolumeSource {
395411
volume_claim_template: Some(PersistentVolumeClaimTemplate {
396412
metadata: Some(ObjectMetaBuilder::new().annotations(annotations).build()),

crates/stackable-operator/src/kvp/annotation/mod.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,26 @@ impl Annotation {
159159

160160
/// Constructs a `autoscaling.stackable.tech/retry` annotation.
161161
pub fn autoscaling_retry(retry: bool) -> Self {
162-
// SAFETY: We use expect here, because the input parameter can only be one of two possible
162+
// PANICS: We use expect here, because the input parameter can only be one of two possible
163163
// values: true or false. This fact in combination with the known annotation key length
164-
// allows use to use expect here, instead of bubbling up the error.
164+
// allows us to use expect here, instead of bubbling up the error.
165165
let kvp = KeyValuePair::try_from(("autoscaling.stackable.tech/retry", retry.to_string()))
166166
.expect("autoscaling retry annotation must be valid");
167167
Self(kvp)
168168
}
169+
170+
/// Constructs a `secrets.stackable.tech/backend.autotls.cert.domain-components-in-subject-dn` annotation.
171+
pub fn auto_tls_cert_domain_components_in_subject_dn(enabled: bool) -> Self {
172+
// PANICS: We use expect here, because the input parameter can only be one of two possible
173+
// values: true or false. This fact in combination with the known annotation key length
174+
// allows us to use expect here, instead of bubbling up the error.
175+
let kvp = KeyValuePair::try_from((
176+
"secrets.stackable.tech/backend.autotls.cert.domain-components-in-subject-dn",
177+
enabled.to_string(),
178+
))
179+
.expect("annotation secrets.stackable.tech/backend.autotls.cert.domain-components-in-subject-dn must be valid");
180+
Self(kvp)
181+
}
169182
}
170183

171184
/// A validated set/list of Kubernetes annotations.
@@ -357,4 +370,13 @@ mod test {
357370

358371
assert_eq!(annotations.len(), 2);
359372
}
373+
374+
#[test]
375+
fn test_boolean_annotations() {
376+
// Check that the functions do not fail for all possible inputs
377+
for value in [false, true] {
378+
Annotation::autoscaling_retry(value);
379+
Annotation::auto_tls_cert_domain_components_in_subject_dn(value);
380+
}
381+
}
360382
}

0 commit comments

Comments
 (0)