-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmod.rs
More file actions
51 lines (42 loc) · 1.54 KB
/
Copy pathmod.rs
File metadata and controls
51 lines (42 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use std::sync::Arc;
use snafu::{ResultExt, Snafu};
use stackable_operator::{
cli::OperatorEnvironmentOptions,
kube::Client,
webhook::{WebhookServer, WebhookServerError, WebhookServerOptions, webhooks::Webhook},
};
use crate::restart_controller::statefulset::Ctx;
mod conversion;
mod restarter_mutate_sts;
#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display("failed to create webhook server"))]
CreateWebhookServer { source: WebhookServerError },
}
pub async fn create_webhook_server(
ctx: Arc<Ctx>,
operator_environment: &OperatorEnvironmentOptions,
disable_restarter_mutating_webhook: bool,
disable_crd_maintenance: bool,
client: Client,
) -> Result<WebhookServer, Error> {
let mut webhooks: Vec<Box<dyn Webhook>> = vec![];
if let Some(webhook) = restarter_mutate_sts::create_webhook(
ctx,
disable_restarter_mutating_webhook,
client.clone(),
) {
webhooks.push(webhook);
}
// TODO (@Techassi): The conversion webhook should also allow to be disabled, rework the
// granularity of these options.
webhooks.push(conversion::create_webhook(disable_crd_maintenance, client));
let webhook_options = WebhookServerOptions {
socket_addr: WebhookServer::DEFAULT_SOCKET_ADDRESS,
webhook_namespace: operator_environment.operator_namespace.to_owned(),
webhook_service_name: operator_environment.operator_service_name.to_owned(),
};
WebhookServer::new(webhooks, webhook_options)
.await
.context(CreateWebhookServerSnafu)
}