From c91f0b3ca125b4fae2a6e8c56822ba1214e4a78d Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Thu, 10 Jul 2025 11:05:01 +0200 Subject: [PATCH 1/2] 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/2] 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