44
55use std:: sync:: Arc ;
66
7+ use anyhow:: anyhow;
78use clap:: Parser ;
89use druid_controller:: { DRUID_CONTROLLER_NAME , FULL_CONTROLLER_NAME } ;
9- use futures:: { FutureExt , StreamExt } ;
10+ use futures:: { FutureExt , StreamExt , TryFutureExt } ;
1011use stackable_operator:: {
1112 YamlSchema ,
1213 cli:: { Command , RunArguments } ,
@@ -31,7 +32,10 @@ use stackable_operator::{
3132 utils:: signal:: SignalWatcher ,
3233} ;
3334
34- use crate :: crd:: { DruidCluster , DruidClusterVersion , OPERATOR_NAME , v1alpha1} ;
35+ use crate :: {
36+ crd:: { DruidCluster , DruidClusterVersion , OPERATOR_NAME , v1alpha1} ,
37+ webhooks:: conversion:: create_webhook_server,
38+ } ;
3539
3640mod authentication;
3741mod config;
@@ -44,6 +48,7 @@ mod listener;
4448mod operations;
4549mod product_logging;
4650mod service;
51+ mod webhooks;
4752
4853mod built_info {
4954 include ! ( concat!( env!( "OUT_DIR" ) , "/built.rs" ) ) ;
@@ -63,7 +68,7 @@ async fn main() -> anyhow::Result<()> {
6368 Command :: Crd => DruidCluster :: merged_crd ( DruidClusterVersion :: V1Alpha1 ) ?
6469 . print_yaml_schema ( built_info:: PKG_VERSION , SerializeOptions :: default ( ) ) ?,
6570 Command :: Run ( RunArguments {
66- operator_environment : _ ,
71+ operator_environment,
6772 watch_namespace,
6873 product_config,
6974 maintenance,
@@ -95,16 +100,28 @@ async fn main() -> anyhow::Result<()> {
95100 . run ( sigterm_watcher. handle ( ) )
96101 . map ( anyhow:: Ok ) ;
97102
98- let product_config = product_config. load ( & [
99- "deploy/config-spec/properties.yaml" ,
100- "/etc/stackable/druid-operator/config-spec/properties.yaml" ,
101- ] ) ?;
102103 let client = stackable_operator:: client:: initialize_operator (
103104 Some ( OPERATOR_NAME . to_string ( ) ) ,
104105 & common. cluster_info ,
105106 )
106107 . await ?;
107108
109+ let webhook_server = create_webhook_server (
110+ & operator_environment,
111+ maintenance. disable_crd_maintenance ,
112+ client. as_kube_client ( ) ,
113+ )
114+ . await ?;
115+
116+ let webhook_server = webhook_server
117+ . run ( sigterm_watcher. handle ( ) )
118+ . map_err ( |err| anyhow ! ( err) . context ( "failed to run webhook server" ) ) ;
119+
120+ let product_config = product_config. load ( & [
121+ "deploy/config-spec/properties.yaml" ,
122+ "/etc/stackable/druid-operator/config-spec/properties.yaml" ,
123+ ] ) ?;
124+
108125 let event_recorder = Arc :: new ( Recorder :: new (
109126 client. as_kube_client ( ) ,
110127 Reporter {
@@ -170,7 +187,7 @@ async fn main() -> anyhow::Result<()> {
170187 )
171188 . map ( anyhow:: Ok ) ;
172189
173- futures:: try_join!( druid_controller, eos_checker) ?;
190+ futures:: try_join!( druid_controller, eos_checker, webhook_server ) ?;
174191 }
175192 }
176193
0 commit comments