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

[Merged by Bors] - Split kind arguments into separate options to improve usablity #7

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/kind.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -31,15 +29,12 @@ nodes:
node-labels: node=3
"#;

pub fn handle_cli_arguments(kind_cluster: &Option<Option<String>>) {
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);
}
}

Expand Down
15 changes: 9 additions & 6 deletions src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ pub enum CliCommandOperator {
#[clap(multiple_occurrences(true), required = true)]
operators: Vec<Operator>,

/// 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 <https://github.com/stackabletech/stackablectl> on how to install them
/// 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.
#[clap(short, long)]
kind_cluster: Option<Option<String>>,
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"))]
Expand All @@ -63,8 +65,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();
}
Expand Down
15 changes: 9 additions & 6 deletions src/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ 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 <https://github.com/stackabletech/stackablectl> on how to install them
/// 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.
#[clap(short, long)]
kind_cluster: Option<Option<String>>,
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"))]
Expand All @@ -65,8 +67,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),
Expand Down