Skip to content

Commit 2ec9b73

Browse files
committed
Rework CLI structs and names
1 parent 0c52f5f commit 2ec9b73

File tree

5 files changed

+40
-37
lines changed

5 files changed

+40
-37
lines changed

crates/stackable-operator/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ All notable changes to this project will be documented in this file.
3737
- BREAKING: Return type for `ListenerOperatorVolumeSourceBuilder::new()` is no longer a `Result` ([#1058]).
3838
- BREAKING: Require two new CLI arguments: `--operator-namespace` and `-operator-service-name`.
3939
These are required, so that the operator knows what Service it needs to enter as CRD conversion webhook ([#1066]).
40+
- BREAKING: The `ProductOperatorRun` used for CLI arguments has some field renamed for consistency ([#1066]):
41+
- `telemetry_arguments` -> `telemetry`
42+
- `cluster_info_opts` -> `cluster_info`
4043

4144
### Fixed
4245

crates/stackable-operator/src/cli.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ use product_config::ProductConfigManager;
116116
use snafu::{ResultExt, Snafu};
117117
use stackable_telemetry::tracing::TelemetryOptions;
118118

119-
use crate::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOpts};
119+
use crate::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOptions};
120120

121121
pub const AUTHOR: &str = "Stackable GmbH - [email protected]";
122122

@@ -163,10 +163,10 @@ pub enum Command<Run: Args = ProductOperatorRun> {
163163
/// Can be embedded into an extended argument set:
164164
///
165165
/// ```rust
166-
/// # use stackable_operator::cli::{Command, OperatorEnvironmentOpts, ProductOperatorRun, ProductConfigPath};
166+
/// # use stackable_operator::cli::{Command, OperatorEnvironmentOptions, ProductOperatorRun, ProductConfigPath};
167+
/// # use stackable_operator::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOptions};
168+
/// # use stackable_telemetry::tracing::TelemetryOptions;
167169
/// use clap::Parser;
168-
/// use stackable_operator::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOpts};
169-
/// use stackable_telemetry::tracing::TelemetryOptions;
170170
///
171171
/// #[derive(clap::Parser, Debug, PartialEq, Eq)]
172172
/// struct Run {
@@ -197,12 +197,12 @@ pub enum Command<Run: Args = ProductOperatorRun> {
197197
/// common: ProductOperatorRun {
198198
/// product_config: ProductConfigPath::from("bar".as_ref()),
199199
/// watch_namespace: WatchNamespace::One("foobar".to_string()),
200-
/// telemetry_arguments: TelemetryOptions::default(),
201-
/// cluster_info_opts: KubernetesClusterInfoOpts {
200+
/// telemetry: TelemetryOptions::default(),
201+
/// cluster_info: KubernetesClusterInfoOptions {
202202
/// kubernetes_cluster_domain: None,
203203
/// kubernetes_node_name: "baz".to_string(),
204204
/// },
205-
/// operator_environment: OperatorEnvironmentOpts {
205+
/// operator_environment: OperatorEnvironmentOptions {
206206
/// operator_namespace: "stackable-operators".to_string(),
207207
/// operator_service_name: "foo-operator".to_string(),
208208
/// },
@@ -239,13 +239,13 @@ pub struct ProductOperatorRun {
239239
pub watch_namespace: WatchNamespace,
240240

241241
#[command(flatten)]
242-
pub operator_environment: OperatorEnvironmentOpts,
242+
pub operator_environment: OperatorEnvironmentOptions,
243243

244244
#[command(flatten)]
245-
pub telemetry_arguments: TelemetryOptions,
245+
pub telemetry: TelemetryOptions,
246246

247247
#[command(flatten)]
248-
pub cluster_info_opts: KubernetesClusterInfoOpts,
248+
pub cluster_info: KubernetesClusterInfoOptions,
249249
}
250250

251251
/// A path to a [`ProductConfigManager`] spec file
@@ -304,7 +304,7 @@ impl ProductConfigPath {
304304
}
305305

306306
#[derive(clap::Parser, Debug, PartialEq, Eq)]
307-
pub struct OperatorEnvironmentOpts {
307+
pub struct OperatorEnvironmentOptions {
308308
/// The namespace the operator is running in, usually `stackable-operators`.
309309
#[arg(long, env)]
310310
pub operator_namespace: String,
@@ -440,12 +440,12 @@ mod tests {
440440
ProductOperatorRun {
441441
product_config: ProductConfigPath::from("bar".as_ref()),
442442
watch_namespace: WatchNamespace::One("foo".to_string()),
443-
cluster_info_opts: KubernetesClusterInfoOpts {
443+
cluster_info: KubernetesClusterInfoOptions {
444444
kubernetes_cluster_domain: None,
445445
kubernetes_node_name: "baz".to_string()
446446
},
447-
telemetry_arguments: Default::default(),
448-
operator_environment: OperatorEnvironmentOpts {
447+
telemetry: Default::default(),
448+
operator_environment: OperatorEnvironmentOptions {
449449
operator_namespace: "stackable-operators".to_string(),
450450
operator_service_name: "foo-operator".to_string(),
451451
}
@@ -469,12 +469,12 @@ mod tests {
469469
ProductOperatorRun {
470470
product_config: ProductConfigPath::from("bar".as_ref()),
471471
watch_namespace: WatchNamespace::All,
472-
cluster_info_opts: KubernetesClusterInfoOpts {
472+
cluster_info: KubernetesClusterInfoOptions {
473473
kubernetes_cluster_domain: None,
474474
kubernetes_node_name: "baz".to_string()
475475
},
476-
telemetry_arguments: Default::default(),
477-
operator_environment: OperatorEnvironmentOpts {
476+
telemetry: Default::default(),
477+
operator_environment: OperatorEnvironmentOptions {
478478
operator_namespace: "stackable-operators".to_string(),
479479
operator_service_name: "foo-operator".to_string(),
480480
}
@@ -493,12 +493,12 @@ mod tests {
493493
ProductOperatorRun {
494494
product_config: ProductConfigPath::from("bar".as_ref()),
495495
watch_namespace: WatchNamespace::One("foo".to_string()),
496-
cluster_info_opts: KubernetesClusterInfoOpts {
496+
cluster_info: KubernetesClusterInfoOptions {
497497
kubernetes_cluster_domain: None,
498498
kubernetes_node_name: "baz".to_string()
499499
},
500-
telemetry_arguments: Default::default(),
501-
operator_environment: OperatorEnvironmentOpts {
500+
telemetry: Default::default(),
501+
operator_environment: OperatorEnvironmentOptions {
502502
operator_namespace: "stackable-operators".to_string(),
503503
operator_service_name: "foo-operator".to_string(),
504504
}

crates/stackable-operator/src/client.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use tracing::trace;
2121

2222
use crate::{
2323
kvp::LabelSelectorExt,
24-
utils::cluster_info::{KubernetesClusterInfo, KubernetesClusterInfoOpts},
24+
utils::cluster_info::{KubernetesClusterInfo, KubernetesClusterInfoOptions},
2525
};
2626

2727
pub type Result<T, E = Error> = std::result::Result<T, E>;
@@ -529,13 +529,13 @@ impl Client {
529529
/// use k8s_openapi::api::core::v1::Pod;
530530
/// use stackable_operator::{
531531
/// client::{Client, initialize_operator},
532-
/// utils::cluster_info::KubernetesClusterInfoOpts,
532+
/// utils::cluster_info::KubernetesClusterInfoOptions,
533533
/// };
534534
///
535535
/// #[tokio::main]
536536
/// async fn main() {
537-
/// let cluster_info_opts = KubernetesClusterInfoOpts::parse();
538-
/// let client = initialize_operator(None, &cluster_info_opts)
537+
/// let cluster_info_options = KubernetesClusterInfoOptions::parse();
538+
/// let client = initialize_operator(None, &cluster_info_options)
539539
/// .await
540540
/// .expect("Unable to construct client.");
541541
/// let watcher_config: watcher::Config =
@@ -652,7 +652,7 @@ where
652652

653653
pub async fn initialize_operator(
654654
field_manager: Option<String>,
655-
cluster_info_opts: &KubernetesClusterInfoOpts,
655+
cluster_info_opts: &KubernetesClusterInfoOptions,
656656
) -> Result<Client> {
657657
let kubeconfig: Config = kube::Config::infer()
658658
.await
@@ -687,10 +687,10 @@ mod tests {
687687
};
688688
use tokio::time::error::Elapsed;
689689

690-
use crate::utils::cluster_info::KubernetesClusterInfoOpts;
690+
use crate::utils::cluster_info::KubernetesClusterInfoOptions;
691691

692-
async fn test_cluster_info_opts() -> KubernetesClusterInfoOpts {
693-
KubernetesClusterInfoOpts {
692+
async fn test_cluster_info_opts() -> KubernetesClusterInfoOptions {
693+
KubernetesClusterInfoOptions {
694694
// We have to hard-code a made-up cluster domain,
695695
// since kubernetes_node_name (probably) won't be a valid Node that we can query.
696696
kubernetes_cluster_domain: Some(

crates/stackable-operator/src/utils/cluster_info.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct KubernetesClusterInfo {
1616
}
1717

1818
#[derive(clap::Parser, Debug, PartialEq, Eq)]
19-
pub struct KubernetesClusterInfoOpts {
19+
pub struct KubernetesClusterInfoOptions {
2020
/// Kubernetes cluster domain, usually this is `cluster.local`.
2121
// We are not using a default value here, as we query the cluster if it is not specified.
2222
#[arg(long, env)]
@@ -30,18 +30,18 @@ pub struct KubernetesClusterInfoOpts {
3030
impl KubernetesClusterInfo {
3131
pub async fn new(
3232
client: &Client,
33-
cluster_info_opts: &KubernetesClusterInfoOpts,
33+
cluster_info_opts: &KubernetesClusterInfoOptions,
3434
) -> Result<Self, Error> {
3535
let cluster_domain = match cluster_info_opts {
36-
KubernetesClusterInfoOpts {
36+
KubernetesClusterInfoOptions {
3737
kubernetes_cluster_domain: Some(cluster_domain),
3838
..
3939
} => {
4040
tracing::info!(%cluster_domain, "Using configured Kubernetes cluster domain");
4141

4242
cluster_domain.clone()
4343
}
44-
KubernetesClusterInfoOpts {
44+
KubernetesClusterInfoOptions {
4545
kubernetes_node_name: node_name,
4646
..
4747
} => {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use kube::{
1818
api::{Patch, PatchParams},
1919
};
2020
use snafu::{OptionExt, ResultExt, Snafu};
21-
use stackable_operator::cli::OperatorEnvironmentOpts;
21+
use stackable_operator::cli::OperatorEnvironmentOptions;
2222
use tokio::{sync::mpsc, try_join};
2323
use tracing::instrument;
2424
use x509_cert::{
@@ -75,7 +75,7 @@ pub struct ConversionWebhookServer {
7575
client: Client,
7676
field_manager: String,
7777
crds: Vec<CustomResourceDefinition>,
78-
operator_environment: OperatorEnvironmentOpts,
78+
operator_environment: OperatorEnvironmentOptions,
7979
}
8080

8181
impl ConversionWebhookServer {
@@ -144,7 +144,7 @@ impl ConversionWebhookServer {
144144
options: Options,
145145
client: Client,
146146
field_manager: impl Into<String> + Debug,
147-
operator_environment: OperatorEnvironmentOpts,
147+
operator_environment: OperatorEnvironmentOptions,
148148
) -> Result<Self, ConversionWebhookError>
149149
where
150150
H: WebhookHandler<ConversionReview, ConversionReview> + Clone + Send + Sync + 'static,
@@ -241,7 +241,7 @@ impl ConversionWebhookServer {
241241
client: &Client,
242242
field_manager: &str,
243243
crds: &[CustomResourceDefinition],
244-
operator_environment: &OperatorEnvironmentOpts,
244+
operator_environment: &OperatorEnvironmentOptions,
245245
) -> Result<(), ConversionWebhookError> {
246246
while let Some(current_cert) = cert_rx.recv().await {
247247
Self::reconcile_crds(
@@ -262,7 +262,7 @@ impl ConversionWebhookServer {
262262
client: &Client,
263263
field_manager: &str,
264264
crds: &[CustomResourceDefinition],
265-
operator_environment: &OperatorEnvironmentOpts,
265+
operator_environment: &OperatorEnvironmentOptions,
266266
current_cert: &Certificate,
267267
) -> Result<(), ConversionWebhookError> {
268268
tracing::info!(

0 commit comments

Comments
 (0)