From c91f0b3ca125b4fae2a6e8c56822ba1214e4a78d Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Thu, 10 Jul 2025 11:05:01 +0200 Subject: [PATCH 1/8] feat!: Re-export stackable-certs and stackable-webhook crates --- Cargo.lock | 9 +++++++-- crates/stackable-certs/Cargo.toml | 2 +- crates/stackable-certs/src/ca/consts.rs | 2 +- crates/stackable-certs/src/ca/mod.rs | 10 +++++----- crates/stackable-operator/CHANGELOG.md | 13 +++++++++++++ crates/stackable-operator/Cargo.toml | 17 +++++++++++------ .../stackable-operator/src/builder/pod/mod.rs | 2 +- .../src/builder/pod/volume.rs | 2 +- crates/stackable-operator/src/commons/cache.rs | 3 +-- crates/stackable-operator/src/commons/mod.rs | 1 - crates/stackable-operator/src/config/merge.rs | 3 +-- .../stackable-operator/src/crd/git_sync/mod.rs | 3 ++- .../src/crd/git_sync/v1alpha1_impl.rs | 2 +- crates/stackable-operator/src/lib.rs | 5 ++++- crates/stackable-shared/Cargo.toml | 5 +++++ crates/stackable-shared/src/commons/mod.rs | 1 + .../src/commons/secret.rs | 0 crates/stackable-shared/src/lib.rs | 2 ++ .../src/time/duration.rs | 0 .../src/time/mod.rs | 1 - .../src/time/serde_impl.rs | 0 .../src/time/time_impl.rs | 0 crates/stackable-webhook/Cargo.toml | 1 - crates/xtask/src/crd/dummy.rs | 4 ++-- 24 files changed, 59 insertions(+), 29 deletions(-) create mode 100644 crates/stackable-shared/src/commons/mod.rs rename crates/{stackable-operator => stackable-shared}/src/commons/secret.rs (100%) rename crates/{stackable-operator => stackable-shared}/src/time/duration.rs (100%) rename crates/{stackable-operator => stackable-shared}/src/time/mod.rs (73%) rename crates/{stackable-operator => stackable-shared}/src/time/serde_impl.rs (100%) rename crates/{stackable-operator => stackable-shared}/src/time/time_impl.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 8e909feef..683a87235 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2960,7 +2960,7 @@ dependencies = [ "sha2", "signature", "snafu 0.8.6", - "stackable-operator", + "stackable-shared", "tokio", "tokio-rustls", "tracing", @@ -2994,10 +2994,12 @@ dependencies = [ "serde_json", "serde_yaml", "snafu 0.8.6", + "stackable-certs", "stackable-operator-derive", "stackable-shared", "stackable-telemetry", "stackable-versioned", + "stackable-webhook", "strum", "tempfile", "time", @@ -3025,10 +3027,14 @@ version = "0.0.1" dependencies = [ "k8s-openapi", "kube", + "rstest", + "schemars", "semver", "serde", "serde_yaml", "snafu 0.8.6", + "strum", + "time", ] [[package]] @@ -3113,7 +3119,6 @@ dependencies = [ "serde_json", "snafu 0.8.6", "stackable-certs", - "stackable-operator", "stackable-telemetry", "tokio", "tokio-rustls", diff --git a/crates/stackable-certs/Cargo.toml b/crates/stackable-certs/Cargo.toml index 86654d365..421a5e952 100644 --- a/crates/stackable-certs/Cargo.toml +++ b/crates/stackable-certs/Cargo.toml @@ -11,7 +11,7 @@ default = [] rustls = ["dep:tokio-rustls"] [dependencies] -stackable-operator = { path = "../stackable-operator" } +stackable-shared = { path = "../stackable-shared" } const-oid.workspace = true ecdsa.workspace = true diff --git a/crates/stackable-certs/src/ca/consts.rs b/crates/stackable-certs/src/ca/consts.rs index 125a63a05..d4f2ddcad 100644 --- a/crates/stackable-certs/src/ca/consts.rs +++ b/crates/stackable-certs/src/ca/consts.rs @@ -1,4 +1,4 @@ -use stackable_operator::time::Duration; +use stackable_shared::time::Duration; /// The default CA validity time span of one hour (3600 seconds). pub const DEFAULT_CA_VALIDITY: Duration = Duration::from_hours_unchecked(1); diff --git a/crates/stackable-certs/src/ca/mod.rs b/crates/stackable-certs/src/ca/mod.rs index d04da34ef..64db2eef9 100644 --- a/crates/stackable-certs/src/ca/mod.rs +++ b/crates/stackable-certs/src/ca/mod.rs @@ -4,9 +4,9 @@ use std::{fmt::Debug, str::FromStr}; use const_oid::db::rfc5280::{ID_KP_CLIENT_AUTH, ID_KP_SERVER_AUTH}; use k8s_openapi::api::core::v1::Secret; -use kube::runtime::reflector::ObjectRef; +use kube::{Api, Client, runtime::reflector::ObjectRef}; use snafu::{OptionExt, ResultExt, Snafu}; -use stackable_operator::{client::Client, commons::secret::SecretReference, time::Duration}; +use stackable_shared::{commons::secret::SecretReference, time::Duration}; use tracing::{debug, instrument}; use x509_cert::{ Certificate, @@ -454,15 +454,15 @@ where /// Create a [`CertificateAuthority`] from a Kubernetes [`SecretReference`]. #[instrument( name = "create_certificate_authority_from_k8s_secret_ref", - skip(secret_ref, client) + skip(client) )] pub async fn from_secret_ref( secret_ref: &SecretReference, key_certificate: &str, key_private_key: &str, - client: &Client, + client: Client, ) -> Result> { - let secret_api = client.get_api::(&secret_ref.namespace); + let secret_api = Api::namespaced(client, &secret_ref.namespace); let secret = secret_api .get(&secret_ref.name) .await diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index a8d66b5ee..7ec9cca3e 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +- Re-export `stackable-certs` and `stackable-webhook` crates ([#XXXX]). + +### Changed + +- BREAKING: Some modules have been moved into the `stackable-shared` crate, so that they can also be + used in `stackable-certs` and `stackable-webhook` ([#XXXX]): + - The module `stackable_operator::time` has moved to `stackable_operator::shared::time` + - The module `stackable_operator::commons::secret` has moved to `stackable_operator::shared::commons::secret` + +[#XXXX]: https://github.com/stackabletech/operator-rs/pull/XXXX + ## [0.94.0] - 2025-07-10 ### Added diff --git a/crates/stackable-operator/Cargo.toml b/crates/stackable-operator/Cargo.toml index 15b7bd78a..05115d022 100644 --- a/crates/stackable-operator/Cargo.toml +++ b/crates/stackable-operator/Cargo.toml @@ -8,17 +8,22 @@ edition.workspace = true repository.workspace = true [features] -full = ["time", "telemetry", "versioned"] -default = ["telemetry", "versioned"] +full = ["certs", "telemetry", "time", "versioned", "webhook"] +default = ["telemetry", "time", "versioned"] + +certs = ["dep:stackable-certs"] +telemetry = ["dep:stackable-telemetry"] time = ["dep:time"] -telemetry = [] -versioned = [] +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" } -stackable-telemetry = { path = "../stackable-telemetry", features = ["clap"] } -stackable-versioned = { path = "../stackable-versioned" } +stackable-telemetry = { path = "../stackable-telemetry", optional = true, features = ["clap"] } +stackable-versioned = { path = "../stackable-versioned", optional = true } +stackable-webhook = { path = "../stackable-webhook", optional = true } chrono.workspace = true clap.workspace = true diff --git a/crates/stackable-operator/src/builder/pod/mod.rs b/crates/stackable-operator/src/builder/pod/mod.rs index 7cb46f185..ba4c426c5 100644 --- a/crates/stackable-operator/src/builder/pod/mod.rs +++ b/crates/stackable-operator/src/builder/pod/mod.rs @@ -10,6 +10,7 @@ use k8s_openapi::{ apimachinery::pkg::{api::resource::Quantity, apis::meta::v1::ObjectMeta}, }; use snafu::{OptionExt, ResultExt, Snafu}; +use stackable_shared::time::Duration; use crate::{ builder::{ @@ -25,7 +26,6 @@ use crate::{ }, }, kvp::Labels, - time::Duration, }; pub mod container; diff --git a/crates/stackable-operator/src/builder/pod/volume.rs b/crates/stackable-operator/src/builder/pod/volume.rs index d27b54aa6..0175a11d4 100644 --- a/crates/stackable-operator/src/builder/pod/volume.rs +++ b/crates/stackable-operator/src/builder/pod/volume.rs @@ -9,12 +9,12 @@ use k8s_openapi::{ apimachinery::pkg::api::resource::Quantity, }; use snafu::{ResultExt, Snafu}; +use stackable_shared::time::Duration; use tracing::warn; use crate::{ builder::meta::ObjectMetaBuilder, kvp::{Annotation, AnnotationError, Annotations, LabelError, Labels}, - time::Duration, }; /// A builder to build [`Volume`] objects. May only contain one `volume_source` diff --git a/crates/stackable-operator/src/commons/cache.rs b/crates/stackable-operator/src/commons/cache.rs index 72ec8bf23..ada2ede83 100644 --- a/crates/stackable-operator/src/commons/cache.rs +++ b/crates/stackable-operator/src/commons/cache.rs @@ -3,8 +3,7 @@ use std::marker::PhantomData; use educe::Educe; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; - -use crate::time::Duration; +use stackable_shared::time::Duration; /// [`TtlCache`] with sensible defaults for a user information cache pub type UserInformationCache = TtlCache; diff --git a/crates/stackable-operator/src/commons/mod.rs b/crates/stackable-operator/src/commons/mod.rs index 21a778f83..89e71fc2f 100644 --- a/crates/stackable-operator/src/commons/mod.rs +++ b/crates/stackable-operator/src/commons/mod.rs @@ -9,6 +9,5 @@ pub mod pdb; pub mod product_image_selection; pub mod rbac; pub mod resources; -pub mod secret; pub mod secret_class; pub mod tls_verification; diff --git a/crates/stackable-operator/src/config/merge.rs b/crates/stackable-operator/src/config/merge.rs index be1c137ef..8a5172e28 100644 --- a/crates/stackable-operator/src/config/merge.rs +++ b/crates/stackable-operator/src/config/merge.rs @@ -11,8 +11,7 @@ use k8s_openapi::{ apimachinery::pkg::{api::resource::Quantity, apis::meta::v1::LabelSelector}, }; pub use stackable_operator_derive::Merge; - -use crate::time::Duration; +use stackable_shared::time::Duration; /// A type that can be merged with itself /// diff --git a/crates/stackable-operator/src/crd/git_sync/mod.rs b/crates/stackable-operator/src/crd/git_sync/mod.rs index bc63e2a13..92e9eab52 100644 --- a/crates/stackable-operator/src/crd/git_sync/mod.rs +++ b/crates/stackable-operator/src/crd/git_sync/mod.rs @@ -4,9 +4,10 @@ use std::{collections::BTreeMap, path::PathBuf}; use schemars::{self, JsonSchema}; use serde::{Deserialize, Serialize}; +use stackable_shared::time::Duration; use url::Url; -use crate::{time::Duration, versioned::versioned}; +use crate::versioned::versioned; mod v1alpha1_impl; diff --git a/crates/stackable-operator/src/crd/git_sync/v1alpha1_impl.rs b/crates/stackable-operator/src/crd/git_sync/v1alpha1_impl.rs index 8193123ec..22c1fc3ec 100644 --- a/crates/stackable-operator/src/crd/git_sync/v1alpha1_impl.rs +++ b/crates/stackable-operator/src/crd/git_sync/v1alpha1_impl.rs @@ -4,6 +4,7 @@ use k8s_openapi::api::core::v1::{ Container, EmptyDirVolumeSource, EnvVar, EnvVarSource, SecretKeySelector, Volume, VolumeMount, }; use snafu::{ResultExt, Snafu}; +use stackable_shared::time::Duration; use strum::{EnumDiscriminants, IntoStaticStr}; use crate::{ @@ -17,7 +18,6 @@ use crate::{ framework::capture_shell_output, spec::{ContainerLogConfig, ContainerLogConfigChoice}, }, - time::Duration, utils::COMMON_BASH_TRAP_FUNCTIONS, }; diff --git a/crates/stackable-operator/src/lib.rs b/crates/stackable-operator/src/lib.rs index f0ccc5991..99f7436b0 100644 --- a/crates/stackable-operator/src/lib.rs +++ b/crates/stackable-operator/src/lib.rs @@ -26,7 +26,6 @@ pub mod product_config_utils; pub mod product_logging; pub mod role_utils; pub mod status; -pub mod time; pub mod utils; pub mod validation; @@ -37,9 +36,13 @@ pub use schemars; // Internal re-exports // TODO (@Techassi): Ideally we would want webhook and certs exported here as // well, but that would require some restructuring of crates. +#[cfg(feature = "certs")] +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-shared/Cargo.toml b/crates/stackable-shared/Cargo.toml index 906b4ec72..886444713 100644 --- a/crates/stackable-shared/Cargo.toml +++ b/crates/stackable-shared/Cargo.toml @@ -7,11 +7,16 @@ edition.workspace = true repository.workspace = true [dependencies] +k8s-openapi.workspace = true kube.workspace = true +schemars.workspace = true semver.workspace = true serde.workspace = true serde_yaml.workspace = true snafu.workspace = true +strum.workspace = true +time.workspace = true [dev-dependencies] k8s-openapi.workspace = true +rstest.workspace = true diff --git a/crates/stackable-shared/src/commons/mod.rs b/crates/stackable-shared/src/commons/mod.rs new file mode 100644 index 000000000..73b12dbbd --- /dev/null +++ b/crates/stackable-shared/src/commons/mod.rs @@ -0,0 +1 @@ +pub mod secret; diff --git a/crates/stackable-operator/src/commons/secret.rs b/crates/stackable-shared/src/commons/secret.rs similarity index 100% rename from crates/stackable-operator/src/commons/secret.rs rename to crates/stackable-shared/src/commons/secret.rs diff --git a/crates/stackable-shared/src/lib.rs b/crates/stackable-shared/src/lib.rs index ea8e41a91..b1ae62ee6 100644 --- a/crates/stackable-shared/src/lib.rs +++ b/crates/stackable-shared/src/lib.rs @@ -1,5 +1,7 @@ //! This crate contains various shared helpers and utilities used across other crates in this //! workspace. +pub mod commons; pub mod crd; +pub mod time; pub mod yaml; diff --git a/crates/stackable-operator/src/time/duration.rs b/crates/stackable-shared/src/time/duration.rs similarity index 100% rename from crates/stackable-operator/src/time/duration.rs rename to crates/stackable-shared/src/time/duration.rs diff --git a/crates/stackable-operator/src/time/mod.rs b/crates/stackable-shared/src/time/mod.rs similarity index 73% rename from crates/stackable-operator/src/time/mod.rs rename to crates/stackable-shared/src/time/mod.rs index 9bd1940b5..24838ab27 100644 --- a/crates/stackable-operator/src/time/mod.rs +++ b/crates/stackable-shared/src/time/mod.rs @@ -1,7 +1,6 @@ mod duration; mod serde_impl; -#[cfg(feature = "time")] mod time_impl; pub use duration::*; diff --git a/crates/stackable-operator/src/time/serde_impl.rs b/crates/stackable-shared/src/time/serde_impl.rs similarity index 100% rename from crates/stackable-operator/src/time/serde_impl.rs rename to crates/stackable-shared/src/time/serde_impl.rs diff --git a/crates/stackable-operator/src/time/time_impl.rs b/crates/stackable-shared/src/time/time_impl.rs similarity index 100% rename from crates/stackable-operator/src/time/time_impl.rs rename to crates/stackable-shared/src/time/time_impl.rs diff --git a/crates/stackable-webhook/Cargo.toml b/crates/stackable-webhook/Cargo.toml index 398a8a3f0..09edd0647 100644 --- a/crates/stackable-webhook/Cargo.toml +++ b/crates/stackable-webhook/Cargo.toml @@ -9,7 +9,6 @@ repository.workspace = true [dependencies] stackable-certs = { path = "../stackable-certs", features = ["rustls"] } stackable-telemetry = { path = "../stackable-telemetry" } -stackable-operator = { path = "../stackable-operator" } axum.workspace = true futures-util.workspace = true diff --git a/crates/xtask/src/crd/dummy.rs b/crates/xtask/src/crd/dummy.rs index 3f0652e80..f68dde8b1 100644 --- a/crates/xtask/src/crd/dummy.rs +++ b/crates/xtask/src/crd/dummy.rs @@ -4,7 +4,7 @@ use stackable_operator::{ config::fragment::Fragment, kube::CustomResource, role_utils::Role, - schemars::{self, JsonSchema}, + schemars::JsonSchema, status::condition::ClusterCondition, versioned::versioned, }; @@ -44,7 +44,7 @@ pub mod versioned { pdb_config: stackable_operator::commons::pdb::PdbConfig, product_image: stackable_operator::commons::product_image_selection::ProductImage, secret_class_volume: stackable_operator::commons::secret_class::SecretClassVolume, - secret_reference: stackable_operator::commons::secret::SecretReference, + secret_reference: stackable_operator::shared::commons::secret::SecretReference, tls_client_details: stackable_operator::commons::tls_verification::TlsClientDetails, // Already versioned From 338fcd9e0c02e44ca3ca0e1bc2777a237f03cc8d Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Thu, 10 Jul 2025 11:08:23 +0200 Subject: [PATCH 2/8] changelog --- crates/stackable-operator/CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index 7ec9cca3e..04687cfb8 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -6,16 +6,16 @@ All notable changes to this project will be documented in this file. ### Added -- Re-export `stackable-certs` and `stackable-webhook` crates ([#XXXX]). +- Re-export `stackable-certs` and `stackable-webhook` crates ([#1074]). ### Changed - BREAKING: Some modules have been moved into the `stackable-shared` crate, so that they can also be - used in `stackable-certs` and `stackable-webhook` ([#XXXX]): + used in `stackable-certs` and `stackable-webhook` ([#1074]): - The module `stackable_operator::time` has moved to `stackable_operator::shared::time` - The module `stackable_operator::commons::secret` has moved to `stackable_operator::shared::commons::secret` -[#XXXX]: https://github.com/stackabletech/operator-rs/pull/XXXX +[#1074]: https://github.com/stackabletech/operator-rs/pull/1074 ## [0.94.0] - 2025-07-10 From 4a8f1ef1f8be98762d2e424a4fd15aba8da1b19b Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 20 Aug 2025 09:40:02 +0200 Subject: [PATCH 3/8] fix tests --- Cargo.lock | 1 + crates/stackable-operator/src/builder/pod/probe.rs | 5 ++--- crates/stackable-webhook/Cargo.toml | 1 + crates/stackable-webhook/src/servers/conversion.rs | 2 +- crates/stackable-webhook/src/tls/mod.rs | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5634dc4f4..97488b091 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3129,6 +3129,7 @@ dependencies = [ "serde_json", "snafu 0.8.6", "stackable-certs", + "stackable-shared", "stackable-telemetry", "tokio", "tokio-rustls", diff --git a/crates/stackable-operator/src/builder/pod/probe.rs b/crates/stackable-operator/src/builder/pod/probe.rs index 7278dfaa2..cf569b55c 100644 --- a/crates/stackable-operator/src/builder/pod/probe.rs +++ b/crates/stackable-operator/src/builder/pod/probe.rs @@ -9,7 +9,7 @@ //! ``` //! use stackable_operator::{ //! builder::pod::probe::ProbeBuilder, -//! time::Duration, +//! shared::time::Duration, //! }; //! # use k8s_openapi::api::core::v1::HTTPGetAction; //! # use k8s_openapi::apimachinery::pkg::util::intstr::IntOrString; @@ -36,8 +36,7 @@ use k8s_openapi::{ apimachinery::pkg::util::intstr::IntOrString, }; use snafu::{ResultExt, Snafu, ensure}; - -use crate::time::Duration; +use stackable_shared::time::Duration; #[derive(Debug, Snafu)] pub enum Error { diff --git a/crates/stackable-webhook/Cargo.toml b/crates/stackable-webhook/Cargo.toml index 383f39d64..afcdbeaee 100644 --- a/crates/stackable-webhook/Cargo.toml +++ b/crates/stackable-webhook/Cargo.toml @@ -8,6 +8,7 @@ repository.workspace = true [dependencies] stackable-certs = { path = "../stackable-certs", features = ["rustls"] } +stackable-shared = { path = "../stackable-shared" } stackable-telemetry = { path = "../stackable-telemetry" } arc-swap.workspace = true diff --git a/crates/stackable-webhook/src/servers/conversion.rs b/crates/stackable-webhook/src/servers/conversion.rs index 5d8af83d9..ed6b63579 100644 --- a/crates/stackable-webhook/src/servers/conversion.rs +++ b/crates/stackable-webhook/src/servers/conversion.rs @@ -52,7 +52,7 @@ pub enum ConversionWebhookError { #[snafu(display("failed to update CRD {crd_name:?}"))] UpdateCrd { - source: stackable_operator::kube::Error, + source: kube::Error, crd_name: String, }, } diff --git a/crates/stackable-webhook/src/tls/mod.rs b/crates/stackable-webhook/src/tls/mod.rs index 861c0ba21..a796e8b38 100644 --- a/crates/stackable-webhook/src/tls/mod.rs +++ b/crates/stackable-webhook/src/tls/mod.rs @@ -12,7 +12,7 @@ use hyper_util::rt::{TokioExecutor, TokioIo}; use opentelemetry::trace::{FutureExt, SpanKind}; use opentelemetry_semantic_conventions as semconv; use snafu::{ResultExt, Snafu}; -use stackable_operator::time::Duration; +use stackable_shared::time::Duration; use tokio::{ net::{TcpListener, TcpStream}, sync::mpsc, From ab74e87ad532da825dab94c861f1bca138475aac Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 20 Aug 2025 10:39:50 +0200 Subject: [PATCH 4/8] fix rustdoc --- Cargo.lock | 1 + crates/stackable-webhook/Cargo.toml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 97488b091..8aaf5b98a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3129,6 +3129,7 @@ dependencies = [ "serde_json", "snafu 0.8.6", "stackable-certs", + "stackable-operator", "stackable-shared", "stackable-telemetry", "tokio", diff --git a/crates/stackable-webhook/Cargo.toml b/crates/stackable-webhook/Cargo.toml index afcdbeaee..c03a000a1 100644 --- a/crates/stackable-webhook/Cargo.toml +++ b/crates/stackable-webhook/Cargo.toml @@ -32,4 +32,7 @@ tracing-opentelemetry.workspace = true x509-cert.workspace = true [dev-dependencies] +# Only needed for doc tests / examples +stackable-operator = { path = "../stackable-operator" } + clap.workspace = true From 36c63b30b03304fd3805de65bac5106fd55a9ddb Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 20 Aug 2025 13:59:27 +0200 Subject: [PATCH 5/8] Remove commons mod. Add time feature --- Cargo.lock | 1 - crates/stackable-certs/src/ca/mod.rs | 2 +- crates/stackable-operator/CHANGELOG.md | 2 +- crates/stackable-operator/Cargo.toml | 6 ++---- crates/stackable-shared/Cargo.toml | 8 +++++++- crates/stackable-shared/src/commons/mod.rs | 1 - crates/stackable-shared/src/lib.rs | 3 ++- crates/stackable-shared/src/{commons => }/secret.rs | 0 crates/xtask/src/crd/dummy.rs | 2 +- 9 files changed, 14 insertions(+), 11 deletions(-) delete mode 100644 crates/stackable-shared/src/commons/mod.rs rename crates/stackable-shared/src/{commons => }/secret.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 8aaf5b98a..45c40b022 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3008,7 +3008,6 @@ dependencies = [ "stackable-webhook", "strum", "tempfile", - "time", "tokio", "tracing", "tracing-appender", diff --git a/crates/stackable-certs/src/ca/mod.rs b/crates/stackable-certs/src/ca/mod.rs index f5697a3a2..79f0c5b3c 100644 --- a/crates/stackable-certs/src/ca/mod.rs +++ b/crates/stackable-certs/src/ca/mod.rs @@ -6,7 +6,7 @@ use const_oid::db::rfc5280::{ID_KP_CLIENT_AUTH, ID_KP_SERVER_AUTH}; use k8s_openapi::api::core::v1::Secret; use kube::{Api, Client, runtime::reflector::ObjectRef}; use snafu::{OptionExt, ResultExt, Snafu}; -use stackable_shared::{commons::secret::SecretReference, time::Duration}; +use stackable_shared::{secret::SecretReference, time::Duration}; use tracing::{debug, instrument}; use x509_cert::{ Certificate, diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index 9475e7b43..3135f7d17 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -21,7 +21,7 @@ All notable changes to this project will be documented in this file. - BREAKING: Some modules have been moved into the `stackable-shared` crate, so that they can also be used in `stackable-certs` and `stackable-webhook` ([#1074]): - The module `stackable_operator::time` has moved to `stackable_operator::shared::time` - - The module `stackable_operator::commons::secret` has moved to `stackable_operator::shared::commons::secret` + - The module `stackable_operator::commons::secret` has moved to `stackable_operator::shared::secret` ### Fixed diff --git a/crates/stackable-operator/Cargo.toml b/crates/stackable-operator/Cargo.toml index 05115d022..e6b41b296 100644 --- a/crates/stackable-operator/Cargo.toml +++ b/crates/stackable-operator/Cargo.toml @@ -8,12 +8,11 @@ edition.workspace = true repository.workspace = true [features] -full = ["certs", "telemetry", "time", "versioned", "webhook"] -default = ["telemetry", "time", "versioned"] +full = ["certs", "telemetry", "versioned", "webhook"] +default = ["telemetry", "versioned"] certs = ["dep:stackable-certs"] telemetry = ["dep:stackable-telemetry"] -time = ["dep:time"] versioned = ["dep:stackable-versioned"] webhook = ["dep:stackable-webhook"] @@ -47,7 +46,6 @@ serde_yaml.workspace = true serde.workspace = true snafu.workspace = true strum.workspace = true -time = { workspace = true, optional = true } tokio.workspace = true tracing.workspace = true tracing-appender.workspace = true diff --git a/crates/stackable-shared/Cargo.toml b/crates/stackable-shared/Cargo.toml index 886444713..df6ee6ad4 100644 --- a/crates/stackable-shared/Cargo.toml +++ b/crates/stackable-shared/Cargo.toml @@ -6,6 +6,12 @@ license.workspace = true edition.workspace = true repository.workspace = true +[features] +full = ["time"] +default = ["time"] + +time = ["dep:time"] + [dependencies] k8s-openapi.workspace = true kube.workspace = true @@ -15,7 +21,7 @@ serde.workspace = true serde_yaml.workspace = true snafu.workspace = true strum.workspace = true -time.workspace = true +time = { workspace = true, optional = true } [dev-dependencies] k8s-openapi.workspace = true diff --git a/crates/stackable-shared/src/commons/mod.rs b/crates/stackable-shared/src/commons/mod.rs deleted file mode 100644 index 73b12dbbd..000000000 --- a/crates/stackable-shared/src/commons/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub mod secret; diff --git a/crates/stackable-shared/src/lib.rs b/crates/stackable-shared/src/lib.rs index b1ae62ee6..394932002 100644 --- a/crates/stackable-shared/src/lib.rs +++ b/crates/stackable-shared/src/lib.rs @@ -1,7 +1,8 @@ //! This crate contains various shared helpers and utilities used across other crates in this //! workspace. -pub mod commons; pub mod crd; +pub mod secret; +#[cfg(feature = "time")] pub mod time; pub mod yaml; diff --git a/crates/stackable-shared/src/commons/secret.rs b/crates/stackable-shared/src/secret.rs similarity index 100% rename from crates/stackable-shared/src/commons/secret.rs rename to crates/stackable-shared/src/secret.rs diff --git a/crates/xtask/src/crd/dummy.rs b/crates/xtask/src/crd/dummy.rs index f68dde8b1..8df402de7 100644 --- a/crates/xtask/src/crd/dummy.rs +++ b/crates/xtask/src/crd/dummy.rs @@ -44,7 +44,7 @@ pub mod versioned { pdb_config: stackable_operator::commons::pdb::PdbConfig, product_image: stackable_operator::commons::product_image_selection::ProductImage, secret_class_volume: stackable_operator::commons::secret_class::SecretClassVolume, - secret_reference: stackable_operator::shared::commons::secret::SecretReference, + secret_reference: stackable_operator::shared::secret::SecretReference, tls_client_details: stackable_operator::commons::tls_verification::TlsClientDetails, // Already versioned From f8105ef379920be95c33618c987f3226d174b29f Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 20 Aug 2025 14:51:09 +0200 Subject: [PATCH 6/8] Add time feature to stackable-operator as well --- crates/stackable-operator/Cargo.toml | 3 ++- crates/stackable-shared/src/lib.rs | 2 +- crates/stackable-shared/src/time/mod.rs | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/stackable-operator/Cargo.toml b/crates/stackable-operator/Cargo.toml index e6b41b296..70c753a68 100644 --- a/crates/stackable-operator/Cargo.toml +++ b/crates/stackable-operator/Cargo.toml @@ -8,11 +8,12 @@ edition.workspace = true repository.workspace = true [features] -full = ["certs", "telemetry", "versioned", "webhook"] +full = ["certs", "telemetry", "versioned", "time", "webhook"] default = ["telemetry", "versioned"] certs = ["dep:stackable-certs"] telemetry = ["dep:stackable-telemetry"] +time = ["stackable-shared/time"] versioned = ["dep:stackable-versioned"] webhook = ["dep:stackable-webhook"] diff --git a/crates/stackable-shared/src/lib.rs b/crates/stackable-shared/src/lib.rs index 394932002..2f9b8ae93 100644 --- a/crates/stackable-shared/src/lib.rs +++ b/crates/stackable-shared/src/lib.rs @@ -3,6 +3,6 @@ pub mod crd; pub mod secret; -#[cfg(feature = "time")] + pub mod time; pub mod yaml; diff --git a/crates/stackable-shared/src/time/mod.rs b/crates/stackable-shared/src/time/mod.rs index 24838ab27..9bd1940b5 100644 --- a/crates/stackable-shared/src/time/mod.rs +++ b/crates/stackable-shared/src/time/mod.rs @@ -1,6 +1,7 @@ mod duration; mod serde_impl; +#[cfg(feature = "time")] mod time_impl; pub use duration::*; From f97e4b11c8751a3c57d50da48688bbc1229a0ef6 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 20 Aug 2025 16:32:14 +0200 Subject: [PATCH 7/8] Silence cargo udeps --- crates/stackable-webhook/Cargo.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/stackable-webhook/Cargo.toml b/crates/stackable-webhook/Cargo.toml index c03a000a1..21b876d47 100644 --- a/crates/stackable-webhook/Cargo.toml +++ b/crates/stackable-webhook/Cargo.toml @@ -32,7 +32,11 @@ tracing-opentelemetry.workspace = true x509-cert.workspace = true [dev-dependencies] -# Only needed for doc tests / examples +# Only needed for doc tests stackable-operator = { path = "../stackable-operator" } clap.workspace = true + +# Only needed for tests, this is a false positive of "cargo udeps" +[package.metadata.cargo-udeps.ignore] +development = ["stackable-operator"] From 2a07b20ed5703fdafa0462ca2114176bc3c8ce12 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Wed, 20 Aug 2025 16:33:52 +0200 Subject: [PATCH 8/8] Fix rustdocs --- crates/stackable-operator/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/stackable-operator/src/lib.rs b/crates/stackable-operator/src/lib.rs index 99f7436b0..2ad7e67ab 100644 --- a/crates/stackable-operator/src/lib.rs +++ b/crates/stackable-operator/src/lib.rs @@ -2,7 +2,7 @@ //! //! - `default` enables a default set of features which most operators need. //! - `full` enables all available features. -//! - `time` enables interoperability between [`time::Duration`] and the `time` crate. +//! - `time` enables interoperability between [`shared::time::Duration`] and the `time` crate. //! - `telemetry` enables various helpers for emitting telemetry data. //! - `versioned` enables the macro for CRD versioning.