Skip to content

Commit c00cd97

Browse files
committed
Add listener volume scope for secret volume builders
See https://docs.stackable.tech/home/stable/secret-operator/scope#listener-volume
1 parent 2cf690b commit c00cd97

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,12 @@ impl SecretOperatorVolumeSourceBuilder {
309309
self
310310
}
311311

312+
pub fn with_listener_volume_scope(&mut self, name: impl Into<String>) -> &mut Self {
313+
self.scopes
314+
.push(SecretOperatorVolumeScope::ListenerVolume { name: name.into() });
315+
self
316+
}
317+
312318
pub fn with_format(&mut self, format: SecretFormat) -> &mut Self {
313319
self.format = Some(format);
314320
self
@@ -394,6 +400,7 @@ pub enum SecretOperatorVolumeScope {
394400
Node,
395401
Pod,
396402
Service { name: String },
403+
ListenerVolume { name: String },
397404
}
398405

399406
/// Reference to a listener class or listener name

crates/stackable-operator/src/commons/secret_class.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ impl SecretClassVolume {
5252
for service in &scope.services {
5353
secret_operator_volume_builder.with_service_scope(service);
5454
}
55+
for listener_volume in &scope.listener_volumes {
56+
secret_operator_volume_builder.with_listener_volume_scope(listener_volume);
57+
}
5558
}
5659

5760
secret_operator_volume_builder
@@ -84,6 +87,11 @@ pub struct SecretClassVolumeScope {
8487
/// This should typically correspond to Service objects that the Pod participates in.
8588
#[serde(default)]
8689
pub services: Vec<String>,
90+
91+
/// The listener volume scope allows Node and Service scopes to be inferred from the applicable listeners.
92+
/// This must correspond to Volume names in the Pod that mount Listeners.
93+
#[serde(default)]
94+
pub listener_volumes: Vec<String>,
8795
}
8896

8997
#[cfg(test)]
@@ -99,6 +107,7 @@ mod tests {
99107
pod: true,
100108
node: false,
101109
services: vec!["myservice".to_string()],
110+
listener_volumes: vec!["mylistener".to_string()],
102111
}),
103112
}
104113
.to_ephemeral_volume_source()
@@ -111,7 +120,7 @@ mod tests {
111120
),
112121
(
113122
"secrets.stackable.tech/scope".to_string(),
114-
"pod,service=myservice".to_string(),
123+
"pod,service=myservice,listener-volume=mylistener".to_string(),
115124
),
116125
]);
117126

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ impl Annotation {
104104
value.push_str("service=");
105105
value.push_str(name);
106106
}
107+
SecretOperatorVolumeScope::ListenerVolume { name } => {
108+
value.push_str("listener-volume=");
109+
value.push_str(name);
110+
}
107111
}
108112
}
109113

0 commit comments

Comments
 (0)