Skip to content

Commit 27f4653

Browse files
committed
Allow users to request a secret format (#610)
## Description The client side of stackabletech/secret-operator#286 Co-authored-by: Natalie Klestrup Röijezon <teo.roijezon@stackable.de> Co-authored-by: Natalie <teo@nullable.se>
1 parent f2c3f10 commit 27f4653

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

CHANGELOG.md

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

55
## [Unreleased]
66

7+
### Added
8+
9+
- Secrets can now be requested in a custom format ([#610]).
10+
11+
[#610]: https://github.com/stackabletech/operator-rs/pull/610
12+
713
## [0.42.2] - 2023-06-27
814

915
### Fixed

src/builder/pod/volume.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ impl VolumeMountBuilder {
265265
pub struct SecretOperatorVolumeSourceBuilder {
266266
secret_class: String,
267267
scopes: Vec<SecretOperatorVolumeScope>,
268+
format: Option<SecretFormat>,
268269
kerberos_service_names: Vec<String>,
269270
}
270271

@@ -273,6 +274,7 @@ impl SecretOperatorVolumeSourceBuilder {
273274
Self {
274275
secret_class: secret_class.into(),
275276
scopes: Vec::new(),
277+
format: None,
276278
kerberos_service_names: Vec::new(),
277279
}
278280
}
@@ -293,6 +295,11 @@ impl SecretOperatorVolumeSourceBuilder {
293295
self
294296
}
295297

298+
pub fn with_format(&mut self, format: SecretFormat) -> &mut Self {
299+
self.format = Some(format);
300+
self
301+
}
302+
296303
pub fn with_kerberos_service_name(&mut self, name: impl Into<String>) -> &mut Self {
297304
self.kerberos_service_names.push(name.into());
298305
self
@@ -322,6 +329,13 @@ impl SecretOperatorVolumeSourceBuilder {
322329
attrs.insert("secrets.stackable.tech/scope".to_string(), scopes);
323330
}
324331

332+
if let Some(format) = &self.format {
333+
attrs.insert(
334+
"secrets.stackable.tech/format".to_string(),
335+
format.as_ref().to_string(),
336+
);
337+
}
338+
325339
if !self.kerberos_service_names.is_empty() {
326340
attrs.insert(
327341
"secrets.stackable.tech/kerberos.service.names".to_string(),
@@ -346,6 +360,20 @@ impl SecretOperatorVolumeSourceBuilder {
346360
}
347361
}
348362

363+
/// A [secret format](https://docs.stackable.tech/home/stable/secret-operator/secretclass.html#format) known by secret-operator.
364+
///
365+
/// This must either match or be convertible from the corresponding secret class, or provisioning the volume will fail.
366+
#[derive(Clone, strum::AsRefStr)]
367+
#[strum(serialize_all = "kebab-case")]
368+
pub enum SecretFormat {
369+
/// A TLS certificate formatted as a PEM triple (`ca.crt`, `tls.crt`, `tls.key`) according to Kubernetes conventions.
370+
TlsPem,
371+
/// A TLS certificate formatted as a PKCS#12 store.
372+
TlsPkcs12,
373+
/// A Kerberos keytab.
374+
Kerberos,
375+
}
376+
349377
#[derive(Clone)]
350378
enum SecretOperatorVolumeScope {
351379
Node,

0 commit comments

Comments
 (0)