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
  • Loading branch information
MasterPtato committed Sep 21, 2024
1 parent e85d5c0 commit 57612fe
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 @@ -141,7 +153,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 @@ -172,7 +193,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 @@ -239,7 +269,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 @@ -271,7 +310,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 57612fe

Please sign in to comment.