-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Cleanup CLI flags for InfluxDB 3 Core
This makes quite a few major changes to our CLI and how users interact with it: 1. All commands are now in the form <verb> <noun> this was to make the commands consistent. We had last-cache as a noun, but serve as a verb in the top level. Given that we could only create or delete All noun based commands have been move under a create and delete command 2. --host short form is now -H not -h which is reassigned to -h/--help for shorter help text and is in line with what users would expect for a CLI 3. Only the needed items from clap_blocks have been moved into `influxdb3_clap_blocks` and any IOx specific references were changed to InfluxDB 3 specific ones 4. References to InfluxDB 3.0 OSS have been changed to InfluxDB 3 Core in our CLI tools 5. --dbname has been changed to --database to be consistent with --table in many commands. The short -d flag still remains. In the create/ delete command for the database however the name of the database is a positional arg e.g. `influxbd3 create database foo` rather than `influxdb3 database create --dbname foo` 6. --table has been removed from the delete/create command for tables and is now a positional arg much like database 7. clap_blocks was removed as dependency to avoid having IOx specific env vars 8. --cache-name is now an optional positional arg for last_cache and meta_cache 9. last-cache/meta-cache commands are now last_cache and meta_cache respectively Unfortunately we have quite a few options to run the software and I couldn't cut down on them, but at least with this commands and options will be more discoverable and we have full control over our CLI options now. Closes #25646
- Loading branch information
Showing
42 changed files
with
2,786 additions
and
1,357 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
use crate::commands::common::InfluxDb3Config; | ||
use influxdb3_client::Client; | ||
use secrecy::ExposeSecret; | ||
use std::error::Error; | ||
|
||
#[derive(Debug, clap::Parser)] | ||
pub struct Config { | ||
#[clap(subcommand)] | ||
cmd: SubCommand, | ||
} | ||
|
||
impl Config { | ||
fn get_client(&self) -> Result<Client, Box<dyn Error>> { | ||
let (host_url, auth_token) = match &self.cmd { | ||
SubCommand::Trigger(TriggerConfig { | ||
influxdb3_config: | ||
InfluxDb3Config { | ||
host_url, | ||
auth_token, | ||
.. | ||
}, | ||
.. | ||
}) => (host_url, auth_token), | ||
}; | ||
let mut client = Client::new(host_url.clone())?; | ||
if let Some(token) = &auth_token { | ||
client = client.with_auth_token(token.expose_secret()); | ||
} | ||
Ok(client) | ||
} | ||
} | ||
|
||
#[derive(Debug, clap::Subcommand)] | ||
enum SubCommand { | ||
/// Activate a trigger to enable plugin execution | ||
Trigger(TriggerConfig), | ||
} | ||
|
||
#[derive(Debug, clap::Parser)] | ||
struct TriggerConfig { | ||
#[clap(flatten)] | ||
influxdb3_config: InfluxDb3Config, | ||
|
||
/// Name of trigger to manage | ||
#[clap(required = true)] | ||
trigger_name: String, | ||
} | ||
|
||
pub async fn command(config: Config) -> Result<(), Box<dyn Error>> { | ||
let client = config.get_client()?; | ||
match config.cmd { | ||
SubCommand::Trigger(TriggerConfig { | ||
influxdb3_config: InfluxDb3Config { database_name, .. }, | ||
trigger_name, | ||
}) => { | ||
client | ||
.api_v3_configure_processing_engine_trigger_activate(database_name, &trigger_name) | ||
.await?; | ||
println!("Trigger {} activated successfully", trigger_name); | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.