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

Add '--force' option to 'influxdb3 delete' subcommands #25942

Open
sanderson opened this issue Jan 30, 2025 · 2 comments
Open

Add '--force' option to 'influxdb3 delete' subcommands #25942

sanderson opened this issue Jan 30, 2025 · 2 comments
Labels

Comments

@sanderson
Copy link
Contributor

Use case:
When scripting commands, providing input into an interactive prompt is tedious. It would be better if we gave users the option to force deletes with a --force option.

Proposal:
Add a --force option to all the influxdb3 delete subcommands to skip the confirmation prompt and force the delete operation.

Current behaviour:
There isn't a way to confirm a resource deletion without interacting with the confirmation prompt.

Desired behaviour:
Support --force on delete operations so you don't have to confirm each delete operation through a command prompt.

@hiltontj hiltontj added the v3 label Jan 30, 2025
@sanderson sanderson changed the title Add '--force' option to 'influxdb3 delete` subcommands Add '--force' option to 'influxdb3 delete' subcommands Jan 30, 2025
@noobyogi0010
Copy link

Hey @sanderson
I would like to work on this task. I will try to get in a PR by this Sunday at midnight. Could you be kind enough to point me to the entry/starting point for this task?
Thank you!

@hiltontj
Copy link
Contributor

hiltontj commented Feb 4, 2025

@noobyogi0010 you can see where the prompt for confirmation is emitted for influxdb3 delete database here:

if confirmation.trim() != "yes" {
println!("Cannot delete database without confirmation");
} else {
client.api_v3_configure_db_delete(&database_name).await?;
println!("Database {:?} deleted successfully", &database_name);
}

The configuration for that command, i.e., where the --force option would be added, is here:

#[derive(Debug, clap::Args)]
pub struct DatabaseConfig {
/// The host URL of the running InfluxDB 3 Core server
#[clap(
short = 'H',
long = "host",
env = "INFLUXDB3_HOST_URL",
default_value = "http://127.0.0.1:8181"
)]
pub host_url: Url,
/// The token for authentication with the InfluxDB 3 Core server
#[clap(long = "token", env = "INFLUXDB3_AUTH_TOKEN")]
pub auth_token: Option<Secret<String>>,
/// The name of the database to be deleted
#[clap(env = "INFLUXDB3_DATABASE_NAME", required = true)]
pub database_name: String,
}

There is a similar prompt for delete table:

if confirmation.trim() != "yes" {
println!("Cannot delete table without confirmation");
} else {
client
.api_v3_configure_table_delete(&database_name, &table_name)
.await?;
println!(
"Table {:?}.{:?} deleted successfully",
&database_name, &table_name
);
}

And which is configured here:

#[derive(Debug, clap::Args)]
pub struct TableConfig {
#[clap(flatten)]
influxdb3_config: InfluxDb3Config,
#[clap(required = true)]
/// The name of the table to be deleted
table_name: String,
}

We have a test suite for verifying CLI commands, you can see a test for database deletion here:

async fn test_delete_database() {

Note, that uses run_with_confirmation; there is also a similar run method that would be useful for testing the changes needed here.

The expectation is that you add tests to that test suite to verify that your changes are working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants