Skip to content

Commit 7939b35

Browse files
authored
feat: Add TLS cert lifetime setter to SecretOperatorVolumeSourceBuilder (#915)
* feat: make autotls cert lifetime configurable * fix: changelog * fix changelog (again)
1 parent c61e799 commit 7939b35

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

crates/stackable-operator/CHANGELOG.md

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

55
## [Unreleased]
66

7+
### Added
8+
9+
- Added cert lifetime setter to `SecretOperatorVolumeSourceBuilder` ([#915])
10+
711
### Changed
812

913
- Replace unmaintained `derivative` crate with `educe` ([#907]).
1014
- Bump dependencies, notably rustls 0.23.15 to 0.23.19 to fix [RUSTSEC-2024-0399] ([#917]).
1115

1216
[#907]: https://github.com/stackabletech/operator-rs/pull/907
17+
[#915]: https://github.com/stackabletech/operator-rs/pull/915
1318
[#917]: https://github.com/stackabletech/operator-rs/pull/917
1419
[RUSTSEC-2024-0399]: https://rustsec.org/advisories/RUSTSEC-2024-0399
1520

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use tracing::warn;
1515
use crate::{
1616
builder::meta::ObjectMetaBuilder,
1717
kvp::{Annotation, AnnotationError, Annotations, LabelError, Labels},
18+
time::Duration,
1819
};
1920

2021
/// A builder to build [`Volume`] objects. May only contain one `volume_source`
@@ -280,6 +281,7 @@ pub struct SecretOperatorVolumeSourceBuilder {
280281
format: Option<SecretFormat>,
281282
kerberos_service_names: Vec<String>,
282283
tls_pkcs12_password: Option<String>,
284+
auto_tls_cert_lifetime: Option<Duration>,
283285
}
284286

285287
impl SecretOperatorVolumeSourceBuilder {
@@ -290,9 +292,15 @@ impl SecretOperatorVolumeSourceBuilder {
290292
format: None,
291293
kerberos_service_names: Vec::new(),
292294
tls_pkcs12_password: None,
295+
auto_tls_cert_lifetime: None,
293296
}
294297
}
295298

299+
pub fn with_auto_tls_cert_lifetime(&mut self, lifetime: impl Into<Duration>) -> &mut Self {
300+
self.auto_tls_cert_lifetime = Some(lifetime.into());
301+
self
302+
}
303+
296304
pub fn with_node_scope(&mut self) -> &mut Self {
297305
self.scopes.push(SecretOperatorVolumeScope::Node);
298306
self
@@ -364,6 +372,13 @@ impl SecretOperatorVolumeSourceBuilder {
364372
}
365373
}
366374

375+
if let Some(lifetime) = &self.auto_tls_cert_lifetime {
376+
annotations.insert(
377+
Annotation::auto_tls_cert_lifetime(&lifetime.to_string())
378+
.context(ParseAnnotationSnafu)?,
379+
);
380+
}
381+
367382
Ok(EphemeralVolumeSource {
368383
volume_claim_template: Some(PersistentVolumeClaimTemplate {
369384
metadata: Some(ObjectMetaBuilder::new().annotations(annotations).build()),

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ impl Annotation {
137137
))?;
138138
Ok(Self(kvp))
139139
}
140+
141+
/// Constructs a `secrets.stackable.tech/backend.autotls.cert.lifetime` annotation.
142+
pub fn auto_tls_cert_lifetime(lifetime: &str) -> Result<Self, AnnotationError> {
143+
let kvp = KeyValuePair::try_from((
144+
"secrets.stackable.tech/backend.autotls.cert.lifetime",
145+
lifetime,
146+
))?;
147+
Ok(Self(kvp))
148+
}
140149
}
141150

142151
/// A validated set/list of Kubernetes annotations.

0 commit comments

Comments
 (0)