@@ -18,7 +18,6 @@ use kube::{
18
18
api:: { Patch , PatchParams } ,
19
19
} ;
20
20
use snafu:: { OptionExt , ResultExt , Snafu } ;
21
- use stackable_operator:: cli:: OperatorEnvironmentOptions ;
22
21
use tokio:: { sync:: mpsc, try_join} ;
23
22
use tracing:: instrument;
24
23
use x509_cert:: {
@@ -70,13 +69,15 @@ where
70
69
// TODO: Add a builder, maybe with `bon`.
71
70
#[ derive( Debug ) ]
72
71
pub struct ConversionWebhookOptions {
73
- /// The environment the operator is running in, notably the namespace and service name it is
74
- /// reachable at.
75
- pub operator_environment : OperatorEnvironmentOptions ,
76
-
77
72
/// The bind address to bind the HTTPS server to.
78
73
pub socket_addr : SocketAddr ,
79
74
75
+ /// The namespace the operator/webhook is running in.
76
+ pub namespace : String ,
77
+
78
+ /// The name of the Kubernetes service which points to the operator/webhook.
79
+ pub service_name : String ,
80
+
80
81
/// The field manager used to apply Kubernetes objects, typically the operator name, e.g.
81
82
/// `airflow-operator`.
82
83
pub field_manager : String ,
@@ -197,13 +198,10 @@ impl ConversionWebhookServer {
197
198
} = self ;
198
199
199
200
let ConversionWebhookOptions {
200
- operator_environment :
201
- OperatorEnvironmentOptions {
202
- operator_namespace,
203
- operator_service_name,
204
- } ,
205
201
socket_addr,
206
202
field_manager,
203
+ namespace : operator_namespace,
204
+ service_name : operator_service_name,
207
205
} = & options;
208
206
209
207
// This is how Kubernetes calls us, so it decides about the naming.
@@ -233,7 +231,8 @@ impl ConversionWebhookServer {
233
231
& client,
234
232
field_manager,
235
233
& crds,
236
- & options. operator_environment ,
234
+ & operator_namespace,
235
+ & operator_service_name,
237
236
current_cert,
238
237
)
239
238
. await
@@ -246,7 +245,8 @@ impl ConversionWebhookServer {
246
245
& client,
247
246
field_manager,
248
247
& crds,
249
- & options. operator_environment,
248
+ & operator_namespace,
249
+ & operator_service_name,
250
250
) ,
251
251
) ?;
252
252
@@ -262,14 +262,16 @@ impl ConversionWebhookServer {
262
262
client : & Client ,
263
263
field_manager : & str ,
264
264
crds : & [ CustomResourceDefinition ] ,
265
- operator_environment : & OperatorEnvironmentOptions ,
265
+ operator_namespace : & str ,
266
+ operator_service_name : & str ,
266
267
) -> Result < ( ) , ConversionWebhookError > {
267
268
while let Some ( current_cert) = cert_rx. recv ( ) . await {
268
269
Self :: reconcile_crds (
269
270
client,
270
271
field_manager,
271
272
crds,
272
- operator_environment,
273
+ operator_namespace,
274
+ operator_service_name,
273
275
current_cert,
274
276
)
275
277
. await
@@ -283,7 +285,8 @@ impl ConversionWebhookServer {
283
285
client : & Client ,
284
286
field_manager : & str ,
285
287
crds : & [ CustomResourceDefinition ] ,
286
- operator_environment : & OperatorEnvironmentOptions ,
288
+ operator_namespace : & str ,
289
+ operator_service_name : & str ,
287
290
current_cert : Certificate ,
288
291
) -> Result < ( ) , ConversionWebhookError > {
289
292
tracing:: info!(
@@ -307,8 +310,8 @@ impl ConversionWebhookServer {
307
310
conversion_review_versions : vec ! [ "v1" . to_string( ) ] ,
308
311
client_config : Some ( WebhookClientConfig {
309
312
service : Some ( ServiceReference {
310
- name : operator_environment . operator_service_name . to_owned ( ) ,
311
- namespace : operator_environment . operator_namespace . to_owned ( ) ,
313
+ name : operator_service_name. to_owned ( ) ,
314
+ namespace : operator_namespace. to_owned ( ) ,
312
315
path : Some ( format ! ( "/convert/{crd_name}" ) ) ,
313
316
port : Some ( DEFAULT_HTTPS_PORT . into ( ) ) ,
314
317
} ) ,
0 commit comments