diff --git a/src/kind.rs b/src/kind.rs index 4b2921e1..e7041fe0 100644 --- a/src/kind.rs +++ b/src/kind.rs @@ -1,8 +1,6 @@ use crate::helpers; use log::{info, warn}; -const DEFAULT_KIND_CLUSTER_NAME: &str = "stackable-data-platform"; - const KIND_CLUSTER_DEFINITION: &str = r#" kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 @@ -31,15 +29,12 @@ nodes: node-labels: node=3 "#; -pub fn handle_cli_arguments(kind_cluster: &Option>) { - if let Some(kind_cluster) = kind_cluster { +pub fn handle_cli_arguments(kind_cluster: bool, kind_cluster_name: &str) { + if kind_cluster { helpers::ensure_program_installed("docker"); helpers::ensure_program_installed("kind"); - match kind_cluster { - Some(kind_cluster_nane) => create_cluster_if_not_exists(kind_cluster_nane), - None => create_cluster_if_not_exists(DEFAULT_KIND_CLUSTER_NAME), - } + create_cluster_if_not_exists(kind_cluster_name); } } diff --git a/src/operator.rs b/src/operator.rs index 729f8d75..cb73c830 100644 --- a/src/operator.rs +++ b/src/operator.rs @@ -31,13 +31,19 @@ pub enum CliCommandOperator { #[clap(multiple_occurrences(true), required = true)] operators: Vec, - /// If this argument is specified a local kubernetes cluster for testing purposes is created. + /// If specified a local kubernetes cluster consisting of 4 nodes for testing purposes will be created. /// Kind is a tool to spin up a local kubernetes cluster running on docker on your machine. - /// This scripts creates such a cluster consisting of 4 nodes to test the Stackable Data Platform. - /// The default cluster name is `stackable-data-platform` which can be overwritten by specifying the cluster name after `--kind-cluster` - /// You need to have `docker` and `kind` installed. Have a look at the README at on how to install them + /// You need to have `docker` and `kind` installed. Have a look at the README at on how to install them. #[clap(short, long)] - kind_cluster: Option>, + kind_cluster: bool, + + /// Name of the kind cluster created if `--kind-cluster` is specified + #[clap( + long, + default_value = "stackable-data-platform", + requires = "kind-cluster" + )] + kind_cluster_name: String, }, /// Uninstall a operator #[clap(alias("un"))] @@ -63,8 +69,9 @@ impl CliCommandOperator { CliCommandOperator::Install { operators, kind_cluster, + kind_cluster_name, } => { - kind::handle_cli_arguments(kind_cluster); + kind::handle_cli_arguments(*kind_cluster, kind_cluster_name); for operator in operators { operator.install(); } diff --git a/src/release.rs b/src/release.rs index 924349a1..6b925507 100644 --- a/src/release.rs +++ b/src/release.rs @@ -40,13 +40,19 @@ pub enum CliCommandRelease { #[clap(required = true)] release: String, - /// If this argument is specified a local kubernetes cluster for testing purposes is created. + /// If specified a local kubernetes cluster consisting of 4 nodes for testing purposes will be created. /// Kind is a tool to spin up a local kubernetes cluster running on docker on your machine. - /// This scripts creates such a cluster consisting of 4 nodes to test the Stackable Data Platform. - /// The default cluster name is `stackable-data-platform` which can be overwritten by specifying the cluster name after `--kind-cluster` - /// You need to have `docker` and `kind` installed. Have a look at the README at on how to install them + /// You need to have `docker` and `kind` installed. Have a look at the README at on how to install them. #[clap(short, long)] - kind_cluster: Option>, + kind_cluster: bool, + + /// Name of the kind cluster created if `--kind-cluster` is specified + #[clap( + long, + default_value = "stackable-data-platform", + requires = "kind-cluster" + )] + kind_cluster_name: String, }, /// Uninstall a release #[clap(alias("un"))] @@ -65,8 +71,9 @@ impl CliCommandRelease { CliCommandRelease::Install { release, kind_cluster, + kind_cluster_name, } => { - kind::handle_cli_arguments(kind_cluster); + kind::handle_cli_arguments(*kind_cluster, kind_cluster_name); install_release(release); } CliCommandRelease::Uninstall { release } => uninstall_release(release),