Skip to content

feat!: Re-export stackable-certs and stackable-webhook crates #1074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 21, 2025
Merged
10 changes: 8 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/stackable-certs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-certs/src/ca/consts.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use stackable_operator::time::Duration;
use stackable_shared::time::Duration;

/// The default CA validity time span
pub const DEFAULT_CA_VALIDITY: Duration = Duration::from_hours_unchecked(1);
Expand Down
10 changes: 5 additions & 5 deletions crates/stackable-certs/src/ca/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{secret::SecretReference, time::Duration};
use tracing::{debug, instrument};
use x509_cert::{
Certificate,
Expand Down Expand Up @@ -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<Self, SecretError<S::Error>> {
let secret_api = client.get_api::<Secret>(&secret_ref.namespace);
let secret_api = Api::namespaced(client, &secret_ref.namespace);
let secret = secret_api
.get(&secret_ref.name)
.await
Expand Down
7 changes: 7 additions & 0 deletions crates/stackable-operator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@ All notable changes to this project will be documented in this file.
### Added

- Add `ProbeBuilder` to build Kubernetes container probes ([#1078]).
- Re-export `stackable-certs` and `stackable-webhook` crates ([#1074]).
- BREAKING: Add two new required CLI arguments: `--operator-namespace` and `--operator-service-name`.
These two values are used to construct the service name in the CRD conversion webhook ([#1066]).
- Re-export `stackable-certs` and `stackable-webhook` crates ([#1074]).

### Changed

- BREAKING: The `ResolvedProductImage` field `app_version_label` was renamed to `app_version_label_value` to match changes to its type ([#1076]).
- BREAKING: Rename two fields of the `ProductOperatorRun` struct for consistency and clarity ([#1066]):
- `telemetry_arguments` -> `telemetry`
- `cluster_info_opts` -> `cluster_info`
- 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::secret`

### Fixed

- BREAKING: Fix bug where `ResolvedProductImage::app_version_label` could not be used as a label value because it can contain invalid characters.
This is the case when referencing custom images via a `@sha256:...` hash. As such, the `product_image_selection::resolve` function is now fallible ([#1076]).

[#1066]: https://github.com/stackabletech/operator-rs/pull/1066
[#1074]: https://github.com/stackabletech/operator-rs/pull/1074
[#1076]: https://github.com/stackabletech/operator-rs/pull/1076
[#1078]: https://github.com/stackabletech/operator-rs/pull/1078

Expand Down
18 changes: 11 additions & 7 deletions crates/stackable-operator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ edition.workspace = true
repository.workspace = true

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

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" }
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
Expand All @@ -42,7 +47,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
Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-operator/src/builder/pod/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -25,7 +26,6 @@ use crate::{
},
},
kvp::Labels,
time::Duration,
};

pub mod container;
Expand Down
5 changes: 2 additions & 3 deletions crates/stackable-operator/src/builder/pod/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-operator/src/builder/pod/volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
3 changes: 1 addition & 2 deletions crates/stackable-operator/src/commons/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserInformationCacheDefaults>;
Expand Down
1 change: 0 additions & 1 deletion crates/stackable-operator/src/commons/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 1 addition & 2 deletions crates/stackable-operator/src/config/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
3 changes: 2 additions & 1 deletion crates/stackable-operator/src/crd/git_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -17,7 +18,6 @@ use crate::{
framework::capture_shell_output,
spec::{ContainerLogConfig, ContainerLogConfigChoice},
},
time::Duration,
utils::COMMON_BASH_TRAP_FUNCTIONS,
};

Expand Down
7 changes: 5 additions & 2 deletions crates/stackable-operator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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;

Expand All @@ -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;
11 changes: 11 additions & 0 deletions crates/stackable-shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@ 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
schemars.workspace = true
semver.workspace = true
serde.workspace = true
serde_yaml.workspace = true
snafu.workspace = true
strum.workspace = true
time = { workspace = true, optional = true }

[dev-dependencies]
k8s-openapi.workspace = true
rstest.workspace = true
3 changes: 3 additions & 0 deletions crates/stackable-shared/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
//! workspace.

pub mod crd;
pub mod secret;

pub mod time;
pub mod yaml;
9 changes: 8 additions & 1 deletion crates/stackable-webhook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ repository.workspace = true

[dependencies]
stackable-certs = { path = "../stackable-certs", features = ["rustls"] }
stackable-shared = { path = "../stackable-shared" }
stackable-telemetry = { path = "../stackable-telemetry" }
stackable-operator = { path = "../stackable-operator" }

arc-swap.workspace = true
axum.workspace = true
Expand All @@ -32,4 +32,11 @@ tracing-opentelemetry.workspace = true
x509-cert.workspace = true

[dev-dependencies]
# 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"]
2 changes: 1 addition & 1 deletion crates/stackable-webhook/src/servers/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
Expand Down
2 changes: 1 addition & 1 deletion crates/stackable-webhook/src/tls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/xtask/src/crd/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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::secret::SecretReference,
tls_client_details: stackable_operator::commons::tls_verification::TlsClientDetails,

// Already versioned
Expand Down
Loading