Skip to content

Commit 568cda7

Browse files
committed
chore: Dont use OperatorEnvironmentOptions
1 parent 39fe001 commit 568cda7

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

crates/stackable-webhook/src/servers/conversion.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use kube::{
1818
api::{Patch, PatchParams},
1919
};
2020
use snafu::{OptionExt, ResultExt, Snafu};
21-
use stackable_operator::cli::OperatorEnvironmentOptions;
2221
use tokio::{sync::mpsc, try_join};
2322
use tracing::instrument;
2423
use x509_cert::{
@@ -70,13 +69,15 @@ where
7069
// TODO: Add a builder, maybe with `bon`.
7170
#[derive(Debug)]
7271
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-
7772
/// The bind address to bind the HTTPS server to.
7873
pub socket_addr: SocketAddr,
7974

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+
8081
/// The field manager used to apply Kubernetes objects, typically the operator name, e.g.
8182
/// `airflow-operator`.
8283
pub field_manager: String,
@@ -197,13 +198,10 @@ impl ConversionWebhookServer {
197198
} = self;
198199

199200
let ConversionWebhookOptions {
200-
operator_environment:
201-
OperatorEnvironmentOptions {
202-
operator_namespace,
203-
operator_service_name,
204-
},
205201
socket_addr,
206202
field_manager,
203+
namespace: operator_namespace,
204+
service_name: operator_service_name,
207205
} = &options;
208206

209207
// This is how Kubernetes calls us, so it decides about the naming.
@@ -233,7 +231,8 @@ impl ConversionWebhookServer {
233231
&client,
234232
field_manager,
235233
&crds,
236-
&options.operator_environment,
234+
&operator_namespace,
235+
&operator_service_name,
237236
current_cert,
238237
)
239238
.await
@@ -246,7 +245,8 @@ impl ConversionWebhookServer {
246245
&client,
247246
field_manager,
248247
&crds,
249-
&options.operator_environment,
248+
&operator_namespace,
249+
&operator_service_name,
250250
),
251251
)?;
252252

@@ -262,14 +262,16 @@ impl ConversionWebhookServer {
262262
client: &Client,
263263
field_manager: &str,
264264
crds: &[CustomResourceDefinition],
265-
operator_environment: &OperatorEnvironmentOptions,
265+
operator_namespace: &str,
266+
operator_service_name: &str,
266267
) -> Result<(), ConversionWebhookError> {
267268
while let Some(current_cert) = cert_rx.recv().await {
268269
Self::reconcile_crds(
269270
client,
270271
field_manager,
271272
crds,
272-
operator_environment,
273+
operator_namespace,
274+
operator_service_name,
273275
current_cert,
274276
)
275277
.await
@@ -283,7 +285,8 @@ impl ConversionWebhookServer {
283285
client: &Client,
284286
field_manager: &str,
285287
crds: &[CustomResourceDefinition],
286-
operator_environment: &OperatorEnvironmentOptions,
288+
operator_namespace: &str,
289+
operator_service_name: &str,
287290
current_cert: Certificate,
288291
) -> Result<(), ConversionWebhookError> {
289292
tracing::info!(
@@ -307,8 +310,8 @@ impl ConversionWebhookServer {
307310
conversion_review_versions: vec!["v1".to_string()],
308311
client_config: Some(WebhookClientConfig {
309312
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(),
312315
path: Some(format!("/convert/{crd_name}")),
313316
port: Some(DEFAULT_HTTPS_PORT.into()),
314317
}),

0 commit comments

Comments
 (0)