Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bolt): require --all flag when not using filters for cluster commands #1162

Closed
Changes from all 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
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
Loading