@@ -45,6 +45,8 @@ pub struct MutatingWebhookServer<H, S, R> {
4545}
4646
4747impl < H , S , R > MutatingWebhookServer < H , S , R > {
48+ /// All webhooks need to set the admissionReviewVersions to `["v1"]`, as this mutating webhook
49+ /// only supports that version! A failure to do so will result in a panic.
4850 pub fn new (
4951 mutating_webhook_configuration : MutatingWebhookConfiguration ,
5052 handler : H ,
@@ -53,6 +55,14 @@ impl<H, S, R> MutatingWebhookServer<H, S, R> {
5355 client : Client ,
5456 field_manager : String ,
5557 ) -> Self {
58+ for webhook in mutating_webhook_configuration. webhooks . iter ( ) . flatten ( ) {
59+ assert_eq ! (
60+ webhook. admission_review_versions,
61+ vec![ "v1" ] ,
62+ "We decide how we de-serialize the JSON and with that what AdmissionReview version we support (currently only v1)"
63+ ) ;
64+ }
65+
5666 Self {
5767 mutating_webhook_configuration,
5868 handler,
@@ -118,17 +128,6 @@ where
118128 ) ;
119129
120130 for webhook in mutating_webhook_configuration. webhooks . iter_mut ( ) . flatten ( ) {
121- // TODO: Think is this is a bit excessive
122- // assert!(
123- // webhook.failure_policy.is_some(),
124- // "Users of the mutating webhook need to make an explicit choice on the failure policy"
125- // );
126- assert_eq ! (
127- webhook. admission_review_versions,
128- vec![ "v1" ] ,
129- "We decide how we de-serialize the JSON and with that what AdmissionReview version we support (currently only v1)"
130- ) ;
131-
132131 // We know how we can be called (and with what certificate), so we can always set that
133132 webhook. client_config = WebhookClientConfig {
134133 service : Some ( ServiceReference {
0 commit comments