11use std:: { fmt:: Display , ops:: Deref } ;
22
33use serde:: { Deserialize , Serialize } ;
4- use snafu:: { ResultExt , Snafu } ;
5- use stackable_operator:: {
6- cli:: { MaintenanceOptions , OperatorEnvironmentOptions } ,
7- kube:: { Client , core:: crd:: MergeError } ,
8- schemars:: { self , JsonSchema } ,
9- webhook:: {
10- maintainer:: CustomResourceDefinitionMaintainer ,
11- servers:: { ConversionWebhookError , ConversionWebhookServer } ,
12- } ,
13- } ;
4+ use snafu:: Snafu ;
5+ use stackable_operator:: schemars:: { self , JsonSchema } ;
146
157mod secret_class;
168mod trust_store;
@@ -26,11 +18,8 @@ pub mod v1alpha2 {
2618 pub use crate :: crd:: secret_class:: v1alpha2:: * ;
2719}
2820
29- use tokio:: sync:: oneshot;
3021pub use trust_store:: { TrustStore , TrustStoreVersion } ;
3122
32- use crate :: FIELD_MANAGER ;
33-
3423#[ derive( Debug , Snafu ) ]
3524#[ snafu( module) ]
3625pub enum InvalidKerberosPrincipal {
@@ -87,50 +76,3 @@ impl Deref for KerberosPrincipal {
8776 & self . 0
8877 }
8978}
90-
91- /// Contains errors which can be encountered when creating the conversion webhook server and the
92- /// CRD maintainer.
93- #[ derive( Debug , Snafu ) ]
94- pub enum Error {
95- #[ snafu( display( "failed to merge CRD" ) ) ]
96- MergeCrd { source : MergeError } ,
97-
98- #[ snafu( display( "failed to create conversion webhook server" ) ) ]
99- CreateConversionWebhook { source : ConversionWebhookError } ,
100- }
101-
102- /// Creates and returns a [`ConversionWebhookServer`] and a [`CustomResourceDefinitionMaintainer`].
103- pub async fn create_conversion_webhook_and_maintainer < ' a > (
104- operator_environment : & ' a OperatorEnvironmentOptions ,
105- maintenance : & MaintenanceOptions ,
106- client : Client ,
107- ) -> Result <
108- (
109- ConversionWebhookServer ,
110- CustomResourceDefinitionMaintainer < ' a > ,
111- oneshot:: Receiver < ( ) > ,
112- ) ,
113- Error ,
114- > {
115- let crds_and_handlers = [
116- (
117- SecretClass :: merged_crd ( SecretClassVersion :: V1Alpha2 ) . context ( MergeCrdSnafu ) ?,
118- SecretClass :: try_convert as fn ( _) -> _ ,
119- ) ,
120- (
121- TrustStore :: merged_crd ( TrustStoreVersion :: V1Alpha1 ) . context ( MergeCrdSnafu ) ?,
122- TrustStore :: try_convert as fn ( _) -> _ ,
123- ) ,
124- ] ;
125-
126- ConversionWebhookServer :: with_maintainer (
127- crds_and_handlers,
128- & operator_environment. operator_service_name ,
129- & operator_environment. operator_namespace ,
130- FIELD_MANAGER ,
131- maintenance. disable_crd_maintenance ,
132- client,
133- )
134- . await
135- . context ( CreateConversionWebhookSnafu )
136- }
0 commit comments