11use std:: { collections:: BTreeMap , sync:: Arc } ;
22
33use json_patch:: { AddOperation , Patch , PatchOperation , jsonptr:: PointerBuf } ;
4- use snafu:: { ResultExt , Snafu } ;
54use stackable_operator:: {
65 builder:: meta:: ObjectMetaBuilder ,
7- cli:: OperatorEnvironmentOptions ,
86 k8s_openapi:: {
97 api:: {
108 admissionregistration:: v1:: {
@@ -15,51 +13,16 @@ use stackable_operator::{
1513 } ,
1614 apimachinery:: pkg:: apis:: meta:: v1:: LabelSelector ,
1715 } ,
18- kube:: {
19- Client ,
20- core:: admission:: { AdmissionRequest , AdmissionResponse } ,
21- } ,
16+ kube:: core:: admission:: { AdmissionRequest , AdmissionResponse } ,
2217 kvp:: Label ,
23- webhook:: { WebhookError , WebhookOptions , WebhookServer , servers:: MutatingWebhookServer } ,
2418} ;
2519
2620use crate :: {
27- FIELD_MANAGER , OPERATOR_NAME ,
21+ OPERATOR_NAME ,
2822 restart_controller:: statefulset:: { Ctx , get_updated_restarter_annotations} ,
2923} ;
3024
31- #[ derive( Debug , Snafu ) ]
32- pub enum Error {
33- #[ snafu( display( "failed to create webhook server" ) ) ]
34- CreateWebhookServer { source : WebhookError } ,
35- }
36-
37- pub async fn create_webhook < ' a > (
38- ctx : Arc < Ctx > ,
39- operator_environment : & ' a OperatorEnvironmentOptions ,
40- disable_mutating_webhook_configuration_maintenance : bool ,
41- client : Client ,
42- ) -> Result < WebhookServer , Error > {
43- let mutating_webhook_server = MutatingWebhookServer :: new (
44- get_mutating_webhook_configuration ( ) ,
45- add_sts_restarter_annotation,
46- ctx,
47- disable_mutating_webhook_configuration_maintenance,
48- client,
49- FIELD_MANAGER . to_owned ( ) ,
50- ) ;
51-
52- let webhook_options = WebhookOptions {
53- socket_addr : WebhookServer :: DEFAULT_SOCKET_ADDRESS ,
54- operator_namespace : operator_environment. operator_namespace . to_owned ( ) ,
55- operator_service_name : operator_environment. operator_service_name . to_owned ( ) ,
56- } ;
57- WebhookServer :: new ( webhook_options, vec ! [ Box :: new( mutating_webhook_server) ] )
58- . await
59- . context ( CreateWebhookServerSnafu )
60- }
61-
62- fn get_mutating_webhook_configuration ( ) -> MutatingWebhookConfiguration {
25+ pub fn get_mutating_webhook_configuration ( ) -> MutatingWebhookConfiguration {
6326 let webhook_name = "restarter-sts-enricher.stackable.tech" ;
6427 let metadata = ObjectMetaBuilder :: new ( )
6528 . name ( webhook_name)
@@ -107,7 +70,7 @@ fn get_mutating_webhook_configuration() -> MutatingWebhookConfiguration {
10770 }
10871}
10972
110- async fn add_sts_restarter_annotation (
73+ pub async fn add_sts_restarter_annotation (
11174 ctx : Arc < Ctx > ,
11275 request : AdmissionRequest < StatefulSet > ,
11376) -> AdmissionResponse {
0 commit comments