Skip to content

Commit b48779e

Browse files
authored
feat!: Add cli::CommonOptions struct (#1083)
* feat!: Add CommonStackableCliArgs struct * fix docs * typo * Rename to CommonOptions * fix docs
1 parent ce8b52b commit b48779e

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

crates/stackable-operator/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- Add a `cli::CommonOptions` struct, which can be used for non-operator Stackable tools ([#1083]).
10+
11+
### Changed
12+
13+
- BREAKING: The `telemetry` and `cluster_info` fields of `ProductOperatorRun` have moved below the `common` field ([#1083]).
14+
15+
[#1083]: https://github.com/stackabletech/operator-rs/pull/1083
16+
717
## [0.95.1] - 2025-08-21
818

919
### Fixed

crates/stackable-operator/src/cli.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub enum Command<Run: Args = ProductOperatorRun> {
163163
/// Can be embedded into an extended argument set:
164164
///
165165
/// ```rust
166-
/// # use stackable_operator::cli::{Command, OperatorEnvironmentOptions, ProductOperatorRun, ProductConfigPath};
166+
/// # use stackable_operator::cli::{Command, CommonOptions, OperatorEnvironmentOptions, ProductOperatorRun, ProductConfigPath};
167167
/// # use stackable_operator::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOptions};
168168
/// # use stackable_telemetry::tracing::TelemetryOptions;
169169
/// use clap::Parser;
@@ -195,13 +195,15 @@ pub enum Command<Run: Args = ProductOperatorRun> {
195195
/// assert_eq!(opts, Command::Run(Run {
196196
/// name: "foo".to_string(),
197197
/// common: ProductOperatorRun {
198+
/// common: CommonOptions {
199+
/// telemetry: TelemetryOptions::default(),
200+
/// cluster_info: KubernetesClusterInfoOptions {
201+
/// kubernetes_cluster_domain: None,
202+
/// kubernetes_node_name: "baz".to_string(),
203+
/// },
204+
/// },
198205
/// product_config: ProductConfigPath::from("bar".as_ref()),
199206
/// watch_namespace: WatchNamespace::One("foobar".to_string()),
200-
/// telemetry: TelemetryOptions::default(),
201-
/// cluster_info: KubernetesClusterInfoOptions {
202-
/// kubernetes_cluster_domain: None,
203-
/// kubernetes_node_name: "baz".to_string(),
204-
/// },
205207
/// operator_environment: OperatorEnvironmentOptions {
206208
/// operator_namespace: "stackable-operators".to_string(),
207209
/// operator_service_name: "foo-operator".to_string(),
@@ -230,17 +232,28 @@ pub enum Command<Run: Args = ProductOperatorRun> {
230232
#[derive(clap::Parser, Debug, PartialEq, Eq)]
231233
#[command(long_about = "")]
232234
pub struct ProductOperatorRun {
235+
#[command(flatten)]
236+
pub common: CommonOptions,
237+
238+
#[command(flatten)]
239+
pub operator_environment: OperatorEnvironmentOptions,
240+
233241
/// Provides the path to a product-config file
234242
#[arg(long, short = 'p', value_name = "FILE", default_value = "", env)]
235243
pub product_config: ProductConfigPath,
236244

237245
/// Provides a specific namespace to watch (instead of watching all namespaces)
238246
#[arg(long, env, default_value = "")]
239247
pub watch_namespace: WatchNamespace,
248+
}
240249

241-
#[command(flatten)]
242-
pub operator_environment: OperatorEnvironmentOptions,
243-
250+
/// All the CLI arguments that all (or at least most) Stackable applications use.
251+
///
252+
/// [`ProductOperatorRun`] is intended for operators, but it has fields that are not needed for
253+
/// utilities such as `user-info-fetcher` or `opa-bundle-builder`. So this struct offers a limited
254+
/// set, that should be shared across all Stackable tools running on Kubernetes.
255+
#[derive(clap::Parser, Debug, PartialEq, Eq)]
256+
pub struct CommonOptions {
244257
#[command(flatten)]
245258
pub telemetry: TelemetryOptions,
246259

0 commit comments

Comments
 (0)