Skip to content

Commit 4869e79

Browse files
committed
Dont pass all CLI args
1 parent da4df86 commit 4869e79

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

crates/stackable-operator/src/client.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use snafu::{OptionExt, ResultExt, Snafu};
2020
use tracing::trace;
2121

2222
use crate::{
23-
cli::ProductOperatorRun, kvp::LabelSelectorExt, utils::cluster_info::KubernetesClusterInfo,
23+
commons::networking::DomainName, kvp::LabelSelectorExt,
24+
utils::cluster_info::KubernetesClusterInfo,
2425
};
2526

2627
pub type Result<T, E = Error> = std::result::Result<T, E>;
@@ -517,18 +518,15 @@ impl Client {
517518
///
518519
/// ```no_run
519520
/// use std::time::Duration;
520-
/// use clap::Parser;
521521
/// use tokio::time::error::Elapsed;
522522
/// use kube::runtime::watcher;
523523
/// use k8s_openapi::api::core::v1::Pod;
524-
/// use stackable_operator::{cli::ProductOperatorRun, client::{Client, initialize_operator}};
524+
/// use stackable_operator::client::{Client, initialize_operator};
525525
///
526526
/// #[tokio::main]
527527
/// async fn main(){
528528
///
529-
/// // Parse CLI arguments with Opts::parse() instead
530-
/// let cli_opts = ProductOperatorRun::parse_from(["run"]);
531-
/// let client: Client = initialize_operator(&cli_opts, None).await.expect("Unable to construct client.");
529+
/// let client: Client = initialize_operator(&None, None).await.expect("Unable to construct client.");
532530
/// let watcher_config: watcher::Config =
533531
/// watcher::Config::default().fields(&format!("metadata.name=nonexistent-pod"));
534532
///
@@ -636,7 +634,7 @@ where
636634
}
637635

638636
pub async fn initialize_operator(
639-
cli_opts: &ProductOperatorRun,
637+
cli_kubernetes_cluster_domain: &Option<DomainName>,
640638
field_manager: Option<String>,
641639
) -> Result<Client> {
642640
let kubeconfig: Config = kube::Config::infer()
@@ -645,7 +643,7 @@ pub async fn initialize_operator(
645643
.context(InferKubeConfigSnafu)?;
646644
let default_namespace = kubeconfig.default_namespace.clone();
647645
let client = kube::Client::try_from(kubeconfig).context(CreateKubeClientSnafu)?;
648-
let cluster_info = KubernetesClusterInfo::new(cli_opts);
646+
let cluster_info = KubernetesClusterInfo::new(cli_kubernetes_cluster_domain);
649647

650648
Ok(Client::new(
651649
client,
@@ -659,7 +657,6 @@ pub async fn initialize_operator(
659657
mod tests {
660658
use std::{collections::BTreeMap, time::Duration};
661659

662-
use clap::Parser;
663660
use futures::StreamExt;
664661
use k8s_openapi::{
665662
api::core::v1::{Container, Pod, PodSpec},
@@ -671,13 +668,10 @@ mod tests {
671668
};
672669
use tokio::time::error::Elapsed;
673670

674-
use crate::cli::ProductOperatorRun;
675-
676671
#[tokio::test]
677672
#[ignore = "Tests depending on Kubernetes are not ran by default"]
678673
async fn k8s_test_wait_created() {
679-
let cli_opts = ProductOperatorRun::parse_from(["run"]);
680-
let client = super::initialize_operator(&cli_opts, None)
674+
let client = super::initialize_operator(&None, None)
681675
.await
682676
.expect("KUBECONFIG variable must be configured.");
683677

@@ -755,8 +749,7 @@ mod tests {
755749
#[tokio::test]
756750
#[ignore = "Tests depending on Kubernetes are not ran by default"]
757751
async fn k8s_test_wait_created_timeout() {
758-
let cli_opts = ProductOperatorRun::parse_from(["run"]);
759-
let client = super::initialize_operator(&cli_opts, None)
752+
let client = super::initialize_operator(&None, None)
760753
.await
761754
.expect("KUBECONFIG variable must be configured.");
762755

@@ -776,8 +769,7 @@ mod tests {
776769
#[tokio::test]
777770
#[ignore = "Tests depending on Kubernetes are not ran by default"]
778771
async fn k8s_test_list_with_label_selector() {
779-
let cli_opts = ProductOperatorRun::parse_from(["run"]);
780-
let client = super::initialize_operator(&cli_opts, None)
772+
let client = super::initialize_operator(&None, None)
781773
.await
782774
.expect("KUBECONFIG variable must be configured.");
783775

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::str::FromStr;
22

3-
use crate::{cli::ProductOperatorRun, commons::networking::DomainName};
3+
use crate::commons::networking::DomainName;
44

55
const KUBERNETES_CLUSTER_DOMAIN_DEFAULT: &str = "cluster.local";
66

@@ -10,8 +10,8 @@ pub struct KubernetesClusterInfo {
1010
}
1111

1212
impl KubernetesClusterInfo {
13-
pub fn new(cli_opts: &ProductOperatorRun) -> Self {
14-
let cluster_domain = match &cli_opts.kubernetes_cluster_domain {
13+
pub fn new(cli_kubernetes_cluster_domain: &Option<DomainName>) -> Self {
14+
let cluster_domain = match cli_kubernetes_cluster_domain {
1515
Some(cluster_domain) => {
1616
tracing::info!(%cluster_domain, "Using configured Kubernetes cluster domain");
1717

0 commit comments

Comments
 (0)