33#![ allow( clippy:: result_large_err) ]
44use std:: sync:: Arc ;
55
6+ use anyhow:: anyhow;
67use clap:: Parser ;
78use crd:: v1alpha1:: NifiClusteringBackend ;
8- use futures:: { FutureExt , StreamExt } ;
9+ use futures:: { FutureExt , StreamExt , TryFutureExt } ;
910use stackable_operator:: {
1011 YamlSchema ,
1112 cli:: { Command , RunArguments } ,
@@ -34,6 +35,7 @@ use stackable_operator::{
3435use crate :: {
3536 controller:: NIFI_FULL_CONTROLLER_NAME ,
3637 crd:: { NifiCluster , NifiClusterVersion , authorization:: NifiOpaConfig , v1alpha1} ,
38+ webhooks:: conversion:: create_webhook_server,
3739} ;
3840
3941mod config;
@@ -45,12 +47,14 @@ mod product_logging;
4547mod reporting_task;
4648mod security;
4749mod service;
50+ mod webhooks;
4851
4952mod built_info {
5053 include ! ( concat!( env!( "OUT_DIR" ) , "/built.rs" ) ) ;
5154}
5255
5356const OPERATOR_NAME : & str = "nifi.stackable.tech" ;
57+ const FIELD_MANAGER : & str = "nifi-operator" ;
5458
5559#[ derive( Parser ) ]
5660#[ clap( about, author) ]
@@ -66,7 +70,7 @@ async fn main() -> anyhow::Result<()> {
6670 Command :: Crd => NifiCluster :: merged_crd ( NifiClusterVersion :: V1Alpha1 ) ?
6771 . print_yaml_schema ( built_info:: PKG_VERSION , SerializeOptions :: default ( ) ) ?,
6872 Command :: Run ( RunArguments {
69- operator_environment : _ ,
73+ operator_environment,
7074 watch_namespace,
7175 product_config,
7276 maintenance,
@@ -98,17 +102,28 @@ async fn main() -> anyhow::Result<()> {
98102 . run ( sigterm_watcher. handle ( ) )
99103 . map ( anyhow:: Ok ) ;
100104
101- let product_config = product_config. load ( & [
102- "deploy/config-spec/properties.yaml" ,
103- "/etc/stackable/nifi-operator/config-spec/properties.yaml" ,
104- ] ) ?;
105-
106105 let client = stackable_operator:: client:: initialize_operator (
107106 Some ( OPERATOR_NAME . to_string ( ) ) ,
108107 & common. cluster_info ,
109108 )
110109 . await ?;
111110
111+ let webhook_server = create_webhook_server (
112+ & operator_environment,
113+ maintenance. disable_crd_maintenance ,
114+ client. as_kube_client ( ) ,
115+ )
116+ . await ?;
117+
118+ let webhook_server = webhook_server
119+ . run ( sigterm_watcher. handle ( ) )
120+ . map_err ( |err| anyhow ! ( err) . context ( "failed to run webhook server" ) ) ;
121+
122+ let product_config = product_config. load ( & [
123+ "deploy/config-spec/properties.yaml" ,
124+ "/etc/stackable/nifi-operator/config-spec/properties.yaml" ,
125+ ] ) ?;
126+
112127 let event_recorder = Arc :: new ( Recorder :: new (
113128 client. as_kube_client ( ) ,
114129 Reporter {
@@ -188,7 +203,7 @@ async fn main() -> anyhow::Result<()> {
188203 )
189204 . map ( anyhow:: Ok ) ;
190205
191- futures:: try_join!( nifi_controller, eos_checker) ?;
206+ futures:: try_join!( nifi_controller, eos_checker, webhook_server ) ?;
192207 }
193208 }
194209
0 commit comments