Skip to content
Merged
Show file tree
Hide file tree
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
47 changes: 47 additions & 0 deletions influxdb3/src/commands/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ pub enum SubCommand {
/// List tokens
Tokens(ShowTokensConfig),

/// List plugins
Plugins(PluginsConfig),

/// Display system table data.
System(SystemConfig),
}
Expand Down Expand Up @@ -50,6 +53,30 @@ pub struct ShowTokensConfig {
ca_cert: Option<PathBuf>,
}

#[derive(Debug, Parser)]
pub struct PluginsConfig {
/// 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"
)]
host_url: Url,

/// The token for authentication with the InfluxDB 3 Core server
#[clap(long = "token", env = "INFLUXDB3_AUTH_TOKEN", hide_env_values = true)]
auth_token: Option<Secret<String>>,

/// The format in which to output the list of plugins
#[clap(value_enum, long = "format", default_value = "pretty")]
output_format: Format,

/// An optional arg to use a custom ca for useful for testing with self signed certs
#[clap(long = "tls-ca", env = "INFLUXDB3_TLS_CA")]
ca_cert: Option<PathBuf>,
}

#[derive(Debug, Parser)]
pub struct DatabaseConfig {
/// The host URL of the running InfluxDB 3 Core server
Expand Down Expand Up @@ -102,6 +129,26 @@ pub(crate) async fn command(config: Config) -> Result<(), Box<dyn Error>> {

println!("{}", std::str::from_utf8(&resp_bytes)?);
}
SubCommand::Plugins(PluginsConfig {
host_url,
auth_token,
output_format,
ca_cert,
}) => {
let mut client = influxdb3_client::Client::new(host_url, ca_cert)?;

if let Some(t) = auth_token {
client = client.with_auth_token(t.expose_secret());
}

let resp_bytes = client
.api_v3_query_sql("_internal", "SELECT * FROM system.plugin_files")
.format(output_format.into())
.send()
.await?;

println!("{}", std::str::from_utf8(&resp_bytes)?);
}
SubCommand::System(cfg) => system::command(cfg).await?,
SubCommand::Tokens(show_tokens_config) => {
let mut client = influxdb3_client::Client::new(
Expand Down
37 changes: 37 additions & 0 deletions influxdb3/tests/cli/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,43 @@ impl ShowDatabasesQuery<'_> {
}
}

// Builder for the 'show plugins' command
#[derive(Debug)]
pub struct ShowPluginsQuery<'a> {
server: &'a TestServer,
format: Option<String>,
}

impl TestServer {
pub fn show_plugins(&self) -> ShowPluginsQuery<'_> {
ShowPluginsQuery {
server: self,
format: None,
}
}
}

impl ShowPluginsQuery<'_> {
pub fn with_format(mut self, format: impl Into<String>) -> Self {
self.format = Some(format.into());
self
}

pub fn run(self) -> Result<String> {
let mut args = Vec::new();

if let Some(format) = self.format.as_ref() {
args.push("--format");
args.push(format);
}

args.push("--tls-ca");
args.push("../testing-certs/rootCA.pem");

self.server.run(vec!["show", "plugins"], &args)
}
}

// Builder for the 'delete database' command
#[derive(Debug)]
pub struct DeleteDatabaseQuery<'a> {
Expand Down
Loading