diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 64aeef5ad..ef0194f91 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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 diff --git a/crates/stackable-operator/Cargo.toml b/crates/stackable-operator/Cargo.toml index 4c2181b7e..c10ed0655 100644 --- a/crates/stackable-operator/Cargo.toml +++ b/crates/stackable-operator/Cargo.toml @@ -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 diff --git a/crates/stackable-operator/src/eos/mod.rs b/crates/stackable-operator/src/eos/mod.rs index 7e732c175..2dc5d94e1 100644 --- a/crates/stackable-operator/src/eos/mod.rs +++ b/crates/stackable-operator/src/eos/mod.rs @@ -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, } @@ -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, diff --git a/crates/stackable-operator/src/lib.rs b/crates/stackable-operator/src/lib.rs index c73e72143..003da36ba 100644 --- a/crates/stackable-operator/src/lib.rs +++ b/crates/stackable-operator/src/lib.rs @@ -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; diff --git a/crates/stackable-operator/src/utils/cluster_info.rs b/crates/stackable-operator/src/utils/cluster_info.rs index a7d7a813f..fdd3c2b71 100644 --- a/crates/stackable-operator/src/utils/cluster_info.rs +++ b/crates/stackable-operator/src/utils/cluster_info.rs @@ -15,16 +15,13 @@ 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, /// Name of the Kubernetes Node that the operator is running on. @@ -32,7 +29,7 @@ pub struct KubernetesClusterInfoOptions { /// 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, } diff --git a/crates/stackable-telemetry/src/tracing/mod.rs b/crates/stackable-telemetry/src/tracing/mod.rs index 4262c1f46..c50f3285a 100644 --- a/crates/stackable-telemetry/src/tracing/mod.rs +++ b/crates/stackable-telemetry/src/tracing/mod.rs @@ -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}; @@ -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. /// @@ -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;