@@ -2,12 +2,7 @@ use std::{fmt::Debug, marker::PhantomData, sync::Arc};
22
33use async_trait:: async_trait;
44use axum:: { Json , Router , routing:: post} ;
5- use k8s_openapi:: {
6- ByteString ,
7- api:: admissionregistration:: v1:: {
8- MutatingWebhookConfiguration , ServiceReference , WebhookClientConfig ,
9- } ,
10- } ;
5+ use k8s_openapi:: { ByteString , api:: admissionregistration:: v1:: MutatingWebhookConfiguration } ;
116use kube:: {
127 Api , Client , Resource , ResourceExt ,
138 api:: { Patch , PatchParams } ,
@@ -19,7 +14,7 @@ use tracing::instrument;
1914use x509_cert:: Certificate ;
2015
2116use super :: { Webhook , WebhookError } ;
22- use crate :: WebhookServerOptions ;
17+ use crate :: { WebhookServerOptions , webhooks :: get_webhook_client_config } ;
2318
2419#[ derive( Debug , Snafu ) ]
2520pub enum MutatingWebhookError {
@@ -203,17 +198,8 @@ where
203198
204199 for webhook in mutating_webhook_configuration. webhooks . iter_mut ( ) . flatten ( ) {
205200 // We know how we can be called (and with what certificate), so we can always set that
206- webhook. client_config = WebhookClientConfig {
207- service : Some ( ServiceReference {
208- name : options. webhook_service_name . to_owned ( ) ,
209- namespace : options. webhook_namespace . to_owned ( ) ,
210- path : Some ( self . http_path ( ) ) ,
211- port : Some ( options. socket_addr . port ( ) . into ( ) ) ,
212- } ) ,
213- // Here, ByteString takes care of encoding the provided content as base64.
214- ca_bundle : Some ( new_ca_bundle. to_owned ( ) ) ,
215- url : None ,
216- } ;
201+ webhook. client_config =
202+ get_webhook_client_config ( options, new_ca_bundle. to_owned ( ) , self . http_path ( ) ) ;
217203 }
218204
219205 let mwc_api: Api < MutatingWebhookConfiguration > = Api :: all ( self . client . clone ( ) ) ;
0 commit comments