@@ -78,6 +78,12 @@ pub struct ConversionWebhookOptions {
7878 /// The name of the Kubernetes service which points to the operator/webhook.
7979 pub service_name : String ,
8080
81+ /// If the CRDs should be maintained automatically. Use the (negated) value from
82+ /// `stackable_operator::cli::ProductOperatorRun::disable_crd_maintenance`
83+ /// for this.
84+ // # Because of https://github.com/rust-lang/cargo/issues/3475 we can not use a real link here
85+ pub maintain_crds : bool ,
86+
8187 /// The field manager used to apply Kubernetes objects, typically the operator name, e.g.
8288 /// `airflow-operator`.
8389 pub field_manager : String ,
@@ -91,7 +97,6 @@ pub struct ConversionWebhookServer {
9197 options : ConversionWebhookOptions ,
9298 router : Router ,
9399 client : Client ,
94- maintain_crds : bool ,
95100}
96101
97102impl ConversionWebhookServer {
@@ -104,9 +109,6 @@ impl ConversionWebhookServer {
104109 /// 2. A conversion function to convert between CRD versions. Typically you would use the
105110 /// the auto-generated `try_convert` function on CRD spec definition structs for this.
106111 /// 3. A [`kube::Client`] used to create/update the CRDs.
107- /// 4. If the CRDs should be maintained automatically. Use `stackable_operator::cli::ProductOperatorRun::disable_crd_maintenance`
108- /// for this.
109- // # Because of https://github.com/rust-lang/cargo/issues/3475 we can not use a real link here
110112 ///
111113 /// The [`ConversionWebhookServer`] takes care of reconciling the CRDs into the Kubernetes
112114 /// cluster and takes care of adding itself as conversion webhook. This includes TLS
@@ -149,17 +151,17 @@ impl ConversionWebhookServer {
149151 /// socket_addr: format!("0.0.0.0:{CONVERSION_WEBHOOK_HTTPS_PORT}")
150152 /// .parse()
151153 /// .expect("static address is always valid"),
152- /// field_manager: OPERATOR_NAME.to_owned(),
153154 /// namespace: operator_environment.operator_namespace,
154155 /// service_name: operator_environment.operator_service_name,
156+ /// maintain_crds: !disable_crd_maintenance,
157+ /// field_manager: OPERATOR_NAME.to_owned(),
155158 /// };
156159 ///
157160 /// // Construct the conversion webhook server
158161 /// let conversion_webhook = ConversionWebhookServer::new(
159162 /// crds_and_handlers,
160163 /// options,
161164 /// client,
162- /// !disable_crd_maintenance,
163165 /// )
164166 /// .await
165167 /// .expect("failed to create ConversionWebhookServer");
@@ -175,7 +177,6 @@ impl ConversionWebhookServer {
175177 crds_and_handlers : impl IntoIterator < Item = ( CustomResourceDefinition , H ) > ,
176178 options : ConversionWebhookOptions ,
177179 client : Client ,
178- maintain_crds : bool ,
179180 ) -> Result < Self , ConversionWebhookError >
180181 where
181182 H : WebhookHandler < ConversionReview , ConversionReview > + Clone + Send + Sync + ' static ,
@@ -201,7 +202,6 @@ impl ConversionWebhookServer {
201202 router,
202203 client,
203204 crds,
204- maintain_crds,
205205 } )
206206 }
207207
@@ -213,14 +213,14 @@ impl ConversionWebhookServer {
213213 router,
214214 client,
215215 crds,
216- maintain_crds,
217216 } = self ;
218217
219218 let ConversionWebhookOptions {
220219 socket_addr,
221- field_manager,
222220 namespace : operator_namespace,
223221 service_name : operator_service_name,
222+ maintain_crds,
223+ field_manager,
224224 } = & options;
225225
226226 // This is how Kubernetes calls us, so it decides about the naming.
@@ -247,7 +247,7 @@ impl ConversionWebhookServer {
247247 . await
248248 . context ( ReceiveCertificateFromChannelSnafu ) ?;
249249
250- if maintain_crds {
250+ if * maintain_crds {
251251 Self :: reconcile_crds (
252252 & client,
253253 field_manager,
0 commit comments