Skip to content
Open
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
96 changes: 96 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,30 @@ repos:
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-doc-no-default-features
name: cargo-doc-no-default-features
language: system
entry: cargo doc --no-default-features --document-private-items
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-doc-all-features
name: cargo-doc-all-features
language: system
entry: cargo doc --all-features --document-private-items
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test
name: cargo-test
language: system
entry: cargo test --workspace
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-no-default-features
name: cargo-test-no-default-features
language: system
Expand All @@ -71,6 +95,78 @@ repos:
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-k8s-version-no-default-features
name: cargo-test-k8s-version-no-default-features
language: system
entry: cargo test --no-default-features --package k8s-version
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-certs-no-default-features
name: cargo-test-stackable-certs-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-certs
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-operator-no-default-features
name: cargo-test-stackable-operator-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-operator
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-operator-derive-no-default-features
name: cargo-test-stackable-operator-derive-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-operator-derive
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-shared-no-default-features
name: cargo-test-stackable-shared-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-shared
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-telemetry-no-default-features
name: cargo-test-stackable-telemetry-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-telemetry
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-versioned-no-default-features
name: cargo-test-stackable-versioned-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-versioned
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-versioned-macros-no-default-features
name: cargo-test-stackable-versioned-macros-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-versioned-macros
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-test-stackable-webhook-no-default-features
name: cargo-test-stackable-webhook-no-default-features
language: system
entry: cargo test --no-default-features --package stackable-webhook
stages: [pre-commit, pre-merge-commit]
pass_filenames: false
files: \.rs$|Cargo\.(toml|lock)

- id: cargo-rustfmt
name: cargo-rustfmt
language: system
Expand Down
12 changes: 4 additions & 8 deletions crates/stackable-operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,18 @@ edition.workspace = true
repository.workspace = true

[features]
full = ["certs", "telemetry", "versioned", "time", "webhook", "clap"]
default = ["telemetry", "versioned", "clap"]
full = ["certs", "time", "webhook"]

clap = []
certs = ["dep:stackable-certs"]
telemetry = ["dep:stackable-telemetry"]
time = ["stackable-shared/time"]
versioned = ["dep:stackable-versioned"]
webhook = ["dep:stackable-webhook"]

[dependencies]
stackable-certs = { path = "../stackable-certs", optional = true }
stackable-operator-derive = { path = "../stackable-operator-derive" }
stackable-shared = { path = "../stackable-shared", features = ["time", "jiff"] }
stackable-telemetry = { path = "../stackable-telemetry", optional = true, features = ["clap"] }
stackable-versioned = { path = "../stackable-versioned", optional = true }
stackable-shared = { path = "../stackable-shared", features = ["jiff"] }
stackable-telemetry = { path = "../stackable-telemetry", features = ["clap"] }
stackable-versioned = { path = "../stackable-versioned" }
stackable-webhook = { path = "../stackable-webhook", optional = true }

clap.workspace = true
Expand Down
18 changes: 8 additions & 10 deletions crates/stackable-operator/src/eos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,34 @@ use tracing::{Level, instrument};
///
/// Additionally, this struct can be used as operator CLI arguments. This functionality is only
/// available if the feature `clap` is enabled.
#[cfg_attr(feature = "clap", derive(clap::Args))]
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, clap::Args)]
pub struct EndOfSupportOptions {
/// The end-of-support check mode. Currently, only "offline" is supported.
#[cfg_attr(feature = "clap", arg(
#[arg(
long = "eos-check-mode",
env = "EOS_CHECK_MODE",
default_value_t = EndOfSupportCheckMode::default(),
value_enum
))]
)]
pub check_mode: EndOfSupportCheckMode,

/// The interval in which the end-of-support check should run.
#[cfg_attr(feature = "clap", arg(
#[arg(
long = "eos-interval",
env = "EOS_INTERVAL",
default_value_t = Self::default_interval()
))]
)]
pub interval: Duration,

/// If the end-of-support check should be disabled entirely.
#[cfg_attr(feature = "clap", arg(long = "eos-disabled", env = "EOS_DISABLED"))]
#[arg(long = "eos-disabled", env = "EOS_DISABLED")]
pub disabled: bool,

/// The support duration (how long the operator should be considered supported after
/// it's built-date).
///
/// This field is currently not exposed as a CLI argument or environment variable.
#[cfg_attr(feature = "clap", arg(skip = Self::default_support_duration()))]
#[arg(skip = Self::default_support_duration())]
pub support_duration: Duration,
}

Expand All @@ -55,8 +54,7 @@ impl EndOfSupportOptions {
}
}

#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[derive(Clone, Debug, Default, PartialEq, Eq, clap::ValueEnum)]
pub enum EndOfSupportCheckMode {
#[default]
Offline,
Expand Down
2 changes: 0 additions & 2 deletions crates/stackable-operator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ pub use schemars;
pub use stackable_certs as certs;
pub use stackable_shared as shared;
pub use stackable_shared::{crd::CustomResourceExt, yaml::YamlSchema};
#[cfg(feature = "telemetry")]
pub use stackable_telemetry as telemetry;
#[cfg(feature = "versioned")]
pub use stackable_versioned as versioned;
#[cfg(feature = "webhook")]
pub use stackable_webhook as webhook;
11 changes: 4 additions & 7 deletions crates/stackable-operator/src/utils/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,21 @@ pub struct KubernetesClusterInfo {
pub cluster_domain: DomainName,
}

#[cfg_attr(
feature = "clap",
derive(clap::Parser),
command(next_help_heading = "Cluster Options")
)]
#[derive(clap::Parser)]
#[command(next_help_heading = "Cluster Options")]
#[derive(Debug, PartialEq, Eq)]
pub struct KubernetesClusterInfoOptions {
/// Kubernetes cluster domain, usually this is `cluster.local`.
// We are not using a default value here, as we query the cluster if it is not specified.
#[cfg_attr(feature = "clap", arg(long, env))]
#[arg(long, env)]
pub kubernetes_cluster_domain: Option<DomainName>,

/// Name of the Kubernetes Node that the operator is running on.
///
/// Note that when running the operator on Kubernetes we recommend to use the
/// [downward API](https://kubernetes.io/docs/concepts/workloads/pods/downward-api/)
/// to let Kubernetes project the namespace as the `KUBERNETES_NODE_NAME` env variable.
#[cfg_attr(feature = "clap", arg(long, env))]
#[arg(long, env)]
pub kubernetes_node_name: String,
}

Expand Down
6 changes: 2 additions & 4 deletions crates/stackable-telemetry/src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

use std::{ops::Not, path::PathBuf};

#[cfg_attr(feature = "clap", cfg(doc))]
use clap;
use opentelemetry::trace::TracerProvider;
use opentelemetry_appender_tracing::layer::OpenTelemetryTracingBridge;
use opentelemetry_otlp::{ExporterBuildError, LogExporter, SpanExporter};
Expand Down Expand Up @@ -125,7 +123,7 @@ pub enum Error {
/// ```
///
/// Also see the documentation for [`TelemetryOptions`] which details how it can be used as CLI
/// arguments via [`clap`]. Additionally see [this section](#environment-variables-and-cli-arguments)
/// arguments via `clap`. Additionally see [this section](#environment-variables-and-cli-arguments)
/// in the docs for a full list of environment variables and CLI arguments used by the pre-configured
/// instance.
///
Expand All @@ -148,7 +146,7 @@ pub enum Error {
///
/// #[tokio::main]
/// async fn main() -> Result<(), Error> {
/// // This can come from a Clap argument for example. The enabled builder
/// // This can come from a `clap` argument for example. The enabled builder
/// // function below allows enabling/disabling certain subscribers during
/// // runtime.
/// let otlp_log_flag = false;
Expand Down
Loading