Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Add helper function SecretOperatorVolumeSourceBuilder::with_kerberos_service_name #568

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ All notable changes to this project will be documented in this file.

### Added

- Helper Method to add a restart_policy to PodBuilder([#565]).
- Helper function to add a restart_policy to PodBuilder ([#565]).
- Add helper function `SecretOperatorVolumeSourceBuilder::with_kerberos_service_name` ([#567]).

[#565]: https://github.com/stackabletech/operator-rs/pull/565
[#567]: https://github.com/stackabletech/operator-rs/pull/567
sbernauer marked this conversation as resolved.
Show resolved Hide resolved

## [0.37.0] - 2023-03-06

Expand Down
14 changes: 14 additions & 0 deletions src/builder/pod/volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,15 @@ impl VolumeMountBuilder {
pub struct SecretOperatorVolumeSourceBuilder {
secret_class: String,
scopes: Vec<SecretOperatorVolumeScope>,
kerberos_service_names: Vec<String>,
}

impl SecretOperatorVolumeSourceBuilder {
pub fn new(secret_class: impl Into<String>) -> Self {
Self {
secret_class: secret_class.into(),
scopes: Vec::new(),
kerberos_service_names: Vec::new(),
}
}

Expand All @@ -291,6 +293,11 @@ impl SecretOperatorVolumeSourceBuilder {
self
}

pub fn with_kerberos_service_name(&mut self, name: impl Into<String>) -> &mut Self {
self.kerberos_service_names.push(name.into());
self
}

pub fn build(&self) -> EphemeralVolumeSource {
let mut attrs = BTreeMap::from([(
"secrets.stackable.tech/class".to_string(),
Expand All @@ -315,6 +322,13 @@ impl SecretOperatorVolumeSourceBuilder {
attrs.insert("secrets.stackable.tech/scope".to_string(), scopes);
}

if !self.kerberos_service_names.is_empty() {
attrs.insert(
"secrets.stackable.tech/kerberos.service.names".to_string(),
self.kerberos_service_names.join(","),
);
}

EphemeralVolumeSource {
volume_claim_template: Some(PersistentVolumeClaimTemplate {
metadata: Some(ObjectMetaBuilder::new().annotations(attrs).build()),
Expand Down