Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.

Commit 5830a17

Browse files
committed
Split kind arguments into separate options to improve usablity (#7)
For #5
1 parent 4cfc25b commit 5830a17

File tree

3 files changed

+29
-20
lines changed

3 files changed

+29
-20
lines changed

src/kind.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
use crate::helpers;
22
use log::{info, warn};
33

4-
const DEFAULT_KIND_CLUSTER_NAME: &str = "stackable-data-platform";
5-
64
const KIND_CLUSTER_DEFINITION: &str = r#"
75
kind: Cluster
86
apiVersion: kind.x-k8s.io/v1alpha4
@@ -31,15 +29,12 @@ nodes:
3129
node-labels: node=3
3230
"#;
3331

34-
pub fn handle_cli_arguments(kind_cluster: &Option<Option<String>>) {
35-
if let Some(kind_cluster) = kind_cluster {
32+
pub fn handle_cli_arguments(kind_cluster: bool, kind_cluster_name: &str) {
33+
if kind_cluster {
3634
helpers::ensure_program_installed("docker");
3735
helpers::ensure_program_installed("kind");
3836

39-
match kind_cluster {
40-
Some(kind_cluster_nane) => create_cluster_if_not_exists(kind_cluster_nane),
41-
None => create_cluster_if_not_exists(DEFAULT_KIND_CLUSTER_NAME),
42-
}
37+
create_cluster_if_not_exists(kind_cluster_name);
4338
}
4439
}
4540

src/operator.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ pub enum CliCommandOperator {
3131
#[clap(multiple_occurrences(true), required = true)]
3232
operators: Vec<Operator>,
3333

34-
/// If this argument is specified a local kubernetes cluster for testing purposes is created.
34+
/// If specified a local kubernetes cluster consisting of 4 nodes for testing purposes will be created.
3535
/// Kind is a tool to spin up a local kubernetes cluster running on docker on your machine.
36-
/// This scripts creates such a cluster consisting of 4 nodes to test the Stackable Data Platform.
37-
/// The default cluster name is `stackable-data-platform` which can be overwritten by specifying the cluster name after `--kind-cluster`
38-
/// You need to have `docker` and `kind` installed. Have a look at the README at <https://github.com/stackabletech/stackablectl> on how to install them
36+
/// You need to have `docker` and `kind` installed. Have a look at the README at <https://github.com/stackabletech/stackablectl> on how to install them.
3937
#[clap(short, long)]
40-
kind_cluster: Option<Option<String>>,
38+
kind_cluster: bool,
39+
40+
/// Name of the kind cluster created if `--kind-cluster` is specified
41+
#[clap(
42+
long,
43+
default_value = "stackable-data-platform",
44+
requires = "kind-cluster"
45+
)]
46+
kind_cluster_name: String,
4147
},
4248
/// Uninstall a operator
4349
#[clap(alias("un"))]
@@ -63,8 +69,9 @@ impl CliCommandOperator {
6369
CliCommandOperator::Install {
6470
operators,
6571
kind_cluster,
72+
kind_cluster_name,
6673
} => {
67-
kind::handle_cli_arguments(kind_cluster);
74+
kind::handle_cli_arguments(*kind_cluster, kind_cluster_name);
6875
for operator in operators {
6976
operator.install();
7077
}

src/release.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@ pub enum CliCommandRelease {
4040
#[clap(required = true)]
4141
release: String,
4242

43-
/// If this argument is specified a local kubernetes cluster for testing purposes is created.
43+
/// If specified a local kubernetes cluster consisting of 4 nodes for testing purposes will be created.
4444
/// Kind is a tool to spin up a local kubernetes cluster running on docker on your machine.
45-
/// This scripts creates such a cluster consisting of 4 nodes to test the Stackable Data Platform.
46-
/// The default cluster name is `stackable-data-platform` which can be overwritten by specifying the cluster name after `--kind-cluster`
47-
/// You need to have `docker` and `kind` installed. Have a look at the README at <https://github.com/stackabletech/stackablectl> on how to install them
45+
/// You need to have `docker` and `kind` installed. Have a look at the README at <https://github.com/stackabletech/stackablectl> on how to install them.
4846
#[clap(short, long)]
49-
kind_cluster: Option<Option<String>>,
47+
kind_cluster: bool,
48+
49+
/// Name of the kind cluster created if `--kind-cluster` is specified
50+
#[clap(
51+
long,
52+
default_value = "stackable-data-platform",
53+
requires = "kind-cluster"
54+
)]
55+
kind_cluster_name: String,
5056
},
5157
/// Uninstall a release
5258
#[clap(alias("un"))]
@@ -65,8 +71,9 @@ impl CliCommandRelease {
6571
CliCommandRelease::Install {
6672
release,
6773
kind_cluster,
74+
kind_cluster_name,
6875
} => {
69-
kind::handle_cli_arguments(kind_cluster);
76+
kind::handle_cli_arguments(*kind_cluster, kind_cluster_name);
7077
install_release(release);
7178
}
7279
CliCommandRelease::Uninstall { release } => uninstall_release(release),

0 commit comments

Comments
 (0)