Skip to content

Commit 9c36cda

Browse files
committed
Derive Default for KubernetesClusterInfoOpts
1 parent c0b3650 commit 9c36cda

File tree

3 files changed

+10
-36
lines changed

3 files changed

+10
-36
lines changed

crates/stackable-operator/src/cli.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ pub enum Command<Run: Args = ProductOperatorRun> {
177177
/// use stackable_operator::{
178178
/// logging::TracingTarget,
179179
/// namespace::WatchNamespace,
180-
/// utils::cluster_info::KubernetesClusterInfoOpts
181180
/// };
182181
///
183182
/// let opts = Command::<Run>::parse_from(["foobar-operator", "run", "--name", "foo", "--product-config", "bar", "--watch-namespace", "foobar"]);
@@ -187,9 +186,7 @@ pub enum Command<Run: Args = ProductOperatorRun> {
187186
/// product_config: ProductConfigPath::from("bar".as_ref()),
188187
/// watch_namespace: WatchNamespace::One("foobar".to_string()),
189188
/// tracing_target: TracingTarget::None,
190-
/// cluster_info_opts: KubernetesClusterInfoOpts {
191-
/// kubernetes_cluster_domain: None
192-
/// }
189+
/// cluster_info_opts: Default::default(),
193190
/// },
194191
/// }));
195192
/// ```
@@ -399,9 +396,7 @@ mod tests {
399396
product_config: ProductConfigPath::from("bar".as_ref()),
400397
watch_namespace: WatchNamespace::One("foo".to_string()),
401398
tracing_target: TracingTarget::None,
402-
cluster_info_opts: KubernetesClusterInfoOpts {
403-
kubernetes_cluster_domain: None
404-
}
399+
cluster_info_opts: Default::default(),
405400
}
406401
);
407402

@@ -413,9 +408,7 @@ mod tests {
413408
product_config: ProductConfigPath::from("bar".as_ref()),
414409
watch_namespace: WatchNamespace::All,
415410
tracing_target: TracingTarget::None,
416-
cluster_info_opts: KubernetesClusterInfoOpts {
417-
kubernetes_cluster_domain: None
418-
}
411+
cluster_info_opts: Default::default(),
419412
}
420413
);
421414

@@ -428,9 +421,7 @@ mod tests {
428421
product_config: ProductConfigPath::from("bar".as_ref()),
429422
watch_namespace: WatchNamespace::One("foo".to_string()),
430423
tracing_target: TracingTarget::None,
431-
cluster_info_opts: KubernetesClusterInfoOpts {
432-
kubernetes_cluster_domain: None
433-
}
424+
cluster_info_opts: Default::default(),
434425
}
435426
);
436427
}

crates/stackable-operator/src/client.rs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -521,18 +521,12 @@ impl Client {
521521
/// use tokio::time::error::Elapsed;
522522
/// use kube::runtime::watcher;
523523
/// use k8s_openapi::api::core::v1::Pod;
524-
/// use stackable_operator::{
525-
/// client::{Client, initialize_operator},
526-
/// utils::cluster_info::KubernetesClusterInfoOpts
527-
/// };
524+
/// use stackable_operator::client::{Client, initialize_operator};
528525
///
529526
/// #[tokio::main]
530527
/// async fn main() {
531528
///
532-
/// let cluster_info_cli_opts = KubernetesClusterInfoOpts {
533-
/// kubernetes_cluster_domain: None,
534-
/// };
535-
/// let client = initialize_operator(None, &cluster_info_cli_opts)
529+
/// let client = initialize_operator(None, &Default::default())
536530
/// .await
537531
/// .expect("Unable to construct client.");
538532
/// let watcher_config: watcher::Config =
@@ -676,15 +670,10 @@ mod tests {
676670
};
677671
use tokio::time::error::Elapsed;
678672

679-
use crate::utils::cluster_info::KubernetesClusterInfoOpts;
680-
681673
#[tokio::test]
682674
#[ignore = "Tests depending on Kubernetes are not ran by default"]
683675
async fn k8s_test_wait_created() {
684-
let cluster_info_cli_opts = KubernetesClusterInfoOpts {
685-
kubernetes_cluster_domain: None,
686-
};
687-
let client = super::initialize_operator(None, &cluster_info_cli_opts)
676+
let client = super::initialize_operator(None, &Default::default())
688677
.await
689678
.expect("KUBECONFIG variable must be configured.");
690679

@@ -762,10 +751,7 @@ mod tests {
762751
#[tokio::test]
763752
#[ignore = "Tests depending on Kubernetes are not ran by default"]
764753
async fn k8s_test_wait_created_timeout() {
765-
let cluster_info_cli_opts = KubernetesClusterInfoOpts {
766-
kubernetes_cluster_domain: None,
767-
};
768-
let client = super::initialize_operator(None, &cluster_info_cli_opts)
754+
let client = super::initialize_operator(None, &Default::default())
769755
.await
770756
.expect("KUBECONFIG variable must be configured.");
771757

@@ -785,10 +771,7 @@ mod tests {
785771
#[tokio::test]
786772
#[ignore = "Tests depending on Kubernetes are not ran by default"]
787773
async fn k8s_test_list_with_label_selector() {
788-
let cluster_info_cli_opts = KubernetesClusterInfoOpts {
789-
kubernetes_cluster_domain: None,
790-
};
791-
let client = super::initialize_operator(None, &cluster_info_cli_opts)
774+
let client = super::initialize_operator(None, &Default::default())
792775
.await
793776
.expect("KUBECONFIG variable must be configured.");
794777

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct KubernetesClusterInfo {
99
pub cluster_domain: DomainName,
1010
}
1111

12-
#[derive(clap::Parser, Debug, PartialEq, Eq)]
12+
#[derive(clap::Parser, Debug, Default, PartialEq, Eq)]
1313
pub struct KubernetesClusterInfoOpts {
1414
/// Kubernetes cluster domain, usually this is `cluster.local`.
1515
// We are not using a default value here, as operators will probably do an more advanced

0 commit comments

Comments
 (0)