Skip to content

Commit 4e7da65

Browse files
committed
chore(webhook): Adjust CA bundle handling
1 parent 4aeabbc commit 4e7da65

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

crates/stackable-webhook/src/webhooks/conversion_webhook.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ use snafu::{ResultExt, Snafu};
2222
use tokio::sync::oneshot;
2323
use tracing::instrument;
2424

25-
use super::{Webhook, WebhookError};
26-
use crate::WebhookServerOptions;
25+
use crate::{Webhook, WebhookError, WebhookServerOptions};
2726

2827
#[derive(Debug, Snafu)]
2928
pub enum ConversionWebhookError {
@@ -138,7 +137,7 @@ impl<H> ConversionWebhook<H> {
138137
}
139138

140139
#[instrument(
141-
skip(self, crd, crd_api, new_ca_bundle),
140+
skip(self, crd, crd_api, ca_bundle),
142141
fields(
143142
name = crd.name_any(),
144143
kind = &crd.spec.names.kind
@@ -148,7 +147,7 @@ impl<H> ConversionWebhook<H> {
148147
&self,
149148
mut crd: CustomResourceDefinition,
150149
crd_api: &Api<CustomResourceDefinition>,
151-
new_ca_bundle: &ByteString,
150+
ca_bundle: ByteString,
152151
options: &WebhookServerOptions,
153152
) -> Result<(), WebhookError> {
154153
let crd_kind = &crd.spec.names.kind;
@@ -178,7 +177,7 @@ impl<H> ConversionWebhook<H> {
178177
port: Some(options.socket_addr.port().into()),
179178
}),
180179
// Here, ByteString takes care of encoding the provided content as base64.
181-
ca_bundle: Some(new_ca_bundle.to_owned()),
180+
ca_bundle: Some(ca_bundle),
182181
url: None,
183182
}),
184183
}),
@@ -247,15 +246,15 @@ where
247246
self.options.disable_crd_maintenance
248247
}
249248

250-
#[instrument(skip(self, new_ca_bundle))]
249+
#[instrument(skip(self, ca_bundle))]
251250
async fn handle_certificate_rotation(
252251
&mut self,
253-
new_ca_bundle: &ByteString,
252+
ca_bundle: &ByteString,
254253
options: &WebhookServerOptions,
255254
) -> Result<(), WebhookError> {
256255
let crd_api: Api<CustomResourceDefinition> = Api::all(self.client.clone());
257256
for (crd, _) in &self.crds_and_handlers {
258-
self.reconcile_crd(crd.clone(), &crd_api, new_ca_bundle, options)
257+
self.reconcile_crd(crd.clone(), &crd_api, ca_bundle.to_owned(), options)
259258
.await?;
260259
}
261260

crates/stackable-webhook/src/webhooks/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub trait Webhook {
4848
/// Webhooks are informed about new certificates by this function and can react accordingly.
4949
async fn handle_certificate_rotation(
5050
&mut self,
51-
new_ca_bundle: &ByteString,
51+
ca_bundle: &ByteString,
5252
options: &WebhookServerOptions,
5353
) -> Result<(), WebhookError>;
5454
}

crates/stackable-webhook/src/webhooks/mutating_webhook.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use serde::{Serialize, de::DeserializeOwned};
1212
use snafu::{ResultExt, Snafu};
1313
use tracing::instrument;
1414

15-
use super::{Webhook, WebhookError};
16-
use crate::{WebhookServerOptions, webhooks::create_webhook_client_config};
15+
use crate::{Webhook, WebhookError, WebhookServerOptions, webhooks::create_webhook_client_config};
1716

1817
#[derive(Debug, Snafu)]
1918
pub enum MutatingWebhookError {
@@ -209,14 +208,15 @@ where
209208
self.options.disable_mwc_maintenance
210209
}
211210

212-
#[instrument(skip(self, new_ca_bundle))]
211+
#[instrument(skip(self, ca_bundle))]
213212
async fn handle_certificate_rotation(
214213
&mut self,
215-
new_ca_bundle: &ByteString,
214+
ca_bundle: &ByteString,
216215
options: &WebhookServerOptions,
217216
) -> Result<(), WebhookError> {
218217
let mut mutating_webhook_configuration = self.mutating_webhook_configuration.clone();
219218
let mwc_name = mutating_webhook_configuration.name_any();
219+
220220
tracing::info!(
221221
k8s.mutatingwebhookconfiguration.name = mwc_name,
222222
"reconciling mutating webhook configurations"
@@ -225,7 +225,7 @@ where
225225
for webhook in mutating_webhook_configuration.webhooks.iter_mut().flatten() {
226226
// We know how we can be called (and with what certificate), so we can always set that
227227
webhook.client_config =
228-
create_webhook_client_config(options, new_ca_bundle.to_owned(), self.http_path());
228+
create_webhook_client_config(options, ca_bundle.to_owned(), self.http_path());
229229
}
230230

231231
let mwc_api: Api<MutatingWebhookConfiguration> = Api::all(self.client.clone());

0 commit comments

Comments
 (0)