11use std:: sync:: Arc ;
22
3- use restarter_mutate_sts:: {
4- add_sts_restarter_annotations_handler, get_sts_restarter_mutating_webhook_configuration,
5- } ;
63use snafu:: { ResultExt , Snafu } ;
74use stackable_operator:: {
85 cli:: OperatorEnvironmentOptions ,
96 kube:: Client ,
10- webhook:: {
11- WebhookServer , WebhookServerError , WebhookServerOptions ,
12- webhooks:: { MutatingWebhook , MutatingWebhookOptions , Webhook } ,
13- } ,
7+ webhook:: { WebhookServer , WebhookServerError , WebhookServerOptions , webhooks:: Webhook } ,
148} ;
159
16- use crate :: { FIELD_MANAGER , restart_controller:: statefulset:: Ctx } ;
10+ use crate :: restart_controller:: statefulset:: Ctx ;
1711
12+ mod conversion;
1813mod restarter_mutate_sts;
1914
2015#[ derive( Debug , Snafu ) ]
@@ -27,24 +22,23 @@ pub async fn create_webhook_server(
2722 ctx : Arc < Ctx > ,
2823 operator_environment : & OperatorEnvironmentOptions ,
2924 disable_restarter_mutating_webhook : bool ,
25+ disable_crd_maintenance : bool ,
3026 client : Client ,
3127) -> Result < WebhookServer , Error > {
3228 let mut webhooks: Vec < Box < dyn Webhook > > = vec ! [ ] ;
33- if !disable_restarter_mutating_webhook {
34- let mutating_webhook_options = MutatingWebhookOptions {
35- disable_mwc_maintenance : disable_restarter_mutating_webhook,
36- field_manager : FIELD_MANAGER . to_owned ( ) ,
37- } ;
38-
39- webhooks. push ( Box :: new ( MutatingWebhook :: new (
40- get_sts_restarter_mutating_webhook_configuration ( ) ,
41- add_sts_restarter_annotations_handler,
42- ctx,
43- client,
44- mutating_webhook_options,
45- ) ) ) ;
29+
30+ if let Some ( webhook) = restarter_mutate_sts:: create_webhook (
31+ ctx,
32+ disable_restarter_mutating_webhook,
33+ client. clone ( ) ,
34+ ) {
35+ webhooks. push ( webhook) ;
4636 }
4737
38+ // TODO (@Techassi): The conversion webhook should also allow to be disabled, rework the
39+ // granularity of these options.
40+ webhooks. push ( conversion:: create_webhook ( disable_crd_maintenance, client) ) ;
41+
4842 let webhook_options = WebhookServerOptions {
4943 socket_addr : WebhookServer :: DEFAULT_SOCKET_ADDRESS ,
5044 webhook_namespace : operator_environment. operator_namespace . to_owned ( ) ,
0 commit comments