Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ All notable changes to this project will be documented in this file.

- BREAKING: `get_recommended_labels` and `with_recommended_labels` now takes a struct of named arguments ([#501]).
- Bump opentelemetry crates ([#502]).
- Bump clap to 4.0 ([#503]).

[#501]: https://github.com/stackabletech/operator-rs/pull/501
[#502]: https://github.com/stackabletech/operator-rs/pull/502
[#503]: https://github.com/stackabletech/operator-rs/pull/503

## [0.26.1] - 2022-11-08

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository = "https://github.com/stackabletech/operator-rs"

[dependencies]
chrono = { version = "0.4.22", default-features = false }
clap = { version = "3.2.23", features = ["derive", "cargo", "env"] }
clap = { version = "4.0.22", features = ["derive", "cargo", "env"] }
const_format = "0.2.30"
either = "1.8.0"
futures = "0.3.25"
Expand Down
35 changes: 17 additions & 18 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
//! }
//!
//! #[derive(clap::Parser)]
//! #[clap(
//! #[command(
//! name = "Foobar Operator",
//! author,
//! version,
Expand All @@ -52,7 +52,7 @@
//! }
//!
//! # fn main() -> OperatorResult<()> {
//! let opts = Opts::from_args();
//! let opts = Opts::parse();
//!
//! match opts.command {
//! cli::Command::Crd => {
Expand All @@ -75,7 +75,7 @@
//! use stackable_operator::error::OperatorResult;
//!
//! #[derive(clap::Parser)]
//! #[clap(
//! #[command(
//! name = "Foobar Operator",
//! author,
//! version,
Expand All @@ -87,7 +87,7 @@
//! }
//!
//! # fn main() -> OperatorResult<()> {
//! let opts = Opts::from_args();
//! let opts = Opts::parse();
//!
//! match opts.command {
//! cli::Command::Crd => {
Expand Down Expand Up @@ -133,7 +133,7 @@ pub const AUTHOR: &str = "Stackable GmbH - info@stackable.de";
#[derive(clap::Parser, Debug, PartialEq, Eq)]
// The enum-level doccomment is intended for developers, not end users
// so supress it from being included in --help
#[clap(long_about = "")]
#[command(long_about = "")]
pub enum Command<Run: Args = ProductOperatorRun> {
/// Print CRD objects
Crd,
Expand Down Expand Up @@ -174,7 +174,7 @@ pub enum Command<Run: Args = ProductOperatorRun> {
/// # use stackable_operator::cli::{Command, ProductOperatorRun};
/// #[derive(clap::Parser, Debug, PartialEq, Eq)]
/// struct Run {
/// #[clap(long)]
/// #[arg(long)]
/// name: String,
/// }
/// use clap::Parser;
Expand All @@ -184,28 +184,21 @@ pub enum Command<Run: Args = ProductOperatorRun> {
/// }));
/// ```
#[derive(clap::Parser, Debug, PartialEq, Eq)]
#[clap(long_about = "")]
#[command(long_about = "")]
pub struct ProductOperatorRun {
/// Provides the path to a product-config file
#[clap(
long,
short = 'p',
value_name = "FILE",
default_value = "",
env,
parse(from_os_str)
)]
#[arg(long, short = 'p', value_name = "FILE", default_value = "", env)]
pub product_config: ProductConfigPath,
/// Provides a specific namespace to watch (instead of watching all namespaces)
#[clap(long, env, default_value = "", parse(from_str))]
#[arg(long, env, default_value = "")]
pub watch_namespace: WatchNamespace,
/// Tracing log collector system
#[clap(long, env, default_value_t, arg_enum)]
#[arg(long, env, default_value_t, value_enum)]
pub tracing_target: TracingTarget,
}

/// A path to a [`ProductConfigManager`] spec file
#[derive(Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct ProductConfigPath {
path: Option<PathBuf>,
}
Expand Down Expand Up @@ -274,6 +267,12 @@ mod tests {
const DEFAULT_FILE_PATH: &str = "default_file_path_properties.yaml";
const WATCH_NAMESPACE: &str = "WATCH_NAMESPACE";

#[test]
fn verify_cli() {
use clap::CommandFactory;
ProductOperatorRun::command().debug_assert()
}

#[rstest]
#[case(
Some(USER_PROVIDED_PATH),
Expand Down
2 changes: 1 addition & 1 deletion src/logging/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilte
pub mod controller;
mod k8s_events;

#[derive(Debug, Clone, clap::ArgEnum, PartialEq, Eq)]
#[derive(Debug, Clone, clap::ValueEnum, PartialEq, Eq)]
pub enum TracingTarget {
None,
Jaeger,
Expand Down