Skip to content

Commit

Permalink
fix(bolt): require --all flag when not using filters for cluster comm…
Browse files Browse the repository at this point in the history
…ands (#1162)

<!-- Please make sure there is an issue that this PR is correlated to. -->
Fixes RVTEE-598
## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
MasterPtato committed Oct 9, 2024
1 parent f4737bb commit b140971
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions lib/bolt/cli/src/commands/cluster/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ pub enum SubCommand {
datacenter: Option<String>,
#[clap(long)]
ip: Option<String>,
/// Confirms that you want to execute this command on all servers
#[clap(long)]
all: bool,
},
/// Destroy servers in a cluster
Destroy {
Expand All @@ -49,6 +52,9 @@ pub enum SubCommand {
datacenter: Option<String>,
#[clap(long)]
ip: Option<String>,
/// Confirms that you want to execute this command on all servers
#[clap(long)]
all: bool,
},
/// Lists lost servers in a cluster
ListLost {
Expand Down Expand Up @@ -77,6 +83,9 @@ pub enum SubCommand {
datacenter: Option<String>,
#[clap(long)]
ip: Option<String>,
/// Confirms that you want to execute this command on all lost servers
#[clap(long)]
all: bool,
},
/// SSH in to a server in the cluster
Ssh {
Expand All @@ -91,6 +100,9 @@ pub enum SubCommand {
datacenter: Option<String>,
#[clap(long)]
ip: Option<String>,
/// Confirms that you want to execute this command on all servers
#[clap(long)]
all: bool,

#[clap(long, short = 'c')]
command: Option<String>,
Expand Down Expand Up @@ -142,7 +154,16 @@ impl SubCommand {
pool,
datacenter,
ip,
all,
} => {
if server_id.is_none()
&& pool.is_none()
&& datacenter.is_none()
&& ip.is_none() && !all
{
bail!("must use --all if command has no filters");
}

let cloud_config = ctx.openapi_config_cloud().await?;

// Look up cluster
Expand Down Expand Up @@ -173,7 +194,16 @@ impl SubCommand {
pool,
datacenter,
ip,
all,
} => {
if server_id.is_none()
&& pool.is_none()
&& datacenter.is_none()
&& ip.is_none() && !all
{
bail!("must use --all if command has no filters");
}

let cloud_config = ctx.openapi_config_cloud().await?;

// Look up cluster
Expand Down Expand Up @@ -240,7 +270,16 @@ impl SubCommand {
pool,
datacenter,
ip,
all,
} => {
if server_id.is_none()
&& pool.is_none()
&& datacenter.is_none()
&& ip.is_none() && !all
{
bail!("must use --all if command has no filters");
}

let cloud_config = ctx.openapi_config_cloud().await?;

// Look up cluster
Expand Down Expand Up @@ -272,7 +311,16 @@ impl SubCommand {
pool,
datacenter,
ip,
all,
} => {
if server_id.is_none()
&& pool.is_none()
&& datacenter.is_none()
&& ip.is_none() && !all
{
bail!("must use --all if command has no filters");
}

let cloud_config = ctx.openapi_config_cloud().await?;

// Look up cluster
Expand Down

0 comments on commit b140971

Please sign in to comment.