Skip to content

Commit e3465de

Browse files
committed
Add crds feature
1 parent 72af181 commit e3465de

5 files changed

Lines changed: 17 additions & 6 deletions

File tree

crates/stackable-operator/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ edition.workspace = true
88
repository.workspace = true
99

1010
[features]
11+
default = ["crds"]
1112
full = ["certs", "time", "webhook", "kube-ws"]
1213

14+
crds = ["dep:stackable-versioned"]
1315
certs = ["dep:stackable-certs"]
1416
time = ["stackable-shared/time"]
1517
webhook = ["dep:stackable-webhook"]
@@ -20,7 +22,7 @@ stackable-certs = { path = "../stackable-certs", optional = true }
2022
stackable-operator-derive = { path = "../stackable-operator-derive" }
2123
stackable-shared = { path = "../stackable-shared", features = ["jiff"] }
2224
stackable-telemetry = { path = "../stackable-telemetry", features = ["clap"] }
23-
stackable-versioned = { path = "../stackable-versioned" }
25+
stackable-versioned = { path = "../stackable-versioned", optional = true }
2426
stackable-webhook = { path = "../stackable-webhook", optional = true }
2527

2628
clap.workspace = true

crates/stackable-operator/src/cluster_resources.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use crate::{
3636
ResourceRequirementsExt, ResourceRequirementsType,
3737
},
3838
},
39-
crd::listener,
4039
deep_merger::{self, ObjectOverrides},
4140
kvp::{
4241
Label, LabelError, Labels,
@@ -221,7 +220,8 @@ impl ClusterResource for Service {}
221220
impl ClusterResource for ServiceAccount {}
222221
impl ClusterResource for RoleBinding {}
223222
impl ClusterResource for PodDisruptionBudget {}
224-
impl ClusterResource for listener::v1alpha1::Listener {}
223+
#[cfg(feature = "crds")]
224+
impl ClusterResource for crate::crd::listener::v1alpha1::Listener {}
225225

226226
impl ClusterResource for Job {
227227
fn pod_spec(&self) -> Option<&PodSpec> {
@@ -670,6 +670,13 @@ impl<'a> ClusterResources<'a> {
670670
///
671671
/// * `client` - The client which is used to access Kubernetes
672672
pub async fn delete_orphaned_resources(self, client: &Client) -> Result<()> {
673+
// We can only delete Listeners in case the "crds" feature is enabled, otherwise it's a NOP.
674+
#[cfg(feature = "crds")]
675+
let delete_listeners = self
676+
.delete_orphaned_resources_of_kind::<crate::crd::listener::v1alpha1::Listener>(client);
677+
#[cfg(not(feature = "crds"))]
678+
let delete_listeners = async { Ok(()) };
679+
673680
tokio::try_join!(
674681
self.delete_orphaned_resources_of_kind::<Service>(client),
675682
self.delete_orphaned_resources_of_kind::<StatefulSet>(client),
@@ -680,7 +687,7 @@ impl<'a> ClusterResources<'a> {
680687
self.delete_orphaned_resources_of_kind::<ServiceAccount>(client),
681688
self.delete_orphaned_resources_of_kind::<RoleBinding>(client),
682689
self.delete_orphaned_resources_of_kind::<PodDisruptionBudget>(client),
683-
self.delete_orphaned_resources_of_kind::<listener::v1alpha1::Listener>(client),
690+
delete_listeners
684691
)?;
685692

686693
Ok(())

crates/stackable-operator/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub mod commons;
1414
pub mod config;
1515
pub mod constants;
1616
pub mod cpu;
17+
#[cfg(feature = "crds")]
1718
pub mod crd;
1819
pub mod deep_merger;
1920
pub mod eos;
@@ -43,6 +44,7 @@ pub use stackable_certs as certs;
4344
pub use stackable_shared as shared;
4445
pub use stackable_shared::{crd::CustomResourceExt, yaml::YamlSchema};
4546
pub use stackable_telemetry as telemetry;
47+
#[cfg(feature = "crds")]
4648
pub use stackable_versioned as versioned;
4749
#[cfg(feature = "webhook")]
4850
pub use stackable_webhook as webhook;

crates/stackable-webhook/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ x509-cert.workspace = true
3535

3636
[dev-dependencies]
3737
# Only needed for doc tests
38-
stackable-operator = { path = "../stackable-operator" }
38+
stackable-operator = { path = "../stackable-operator", features = ["crds"] }
3939
clap.workspace = true
4040

4141
[lints]

crates/xtask/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ edition = "2024"
44
publish = false
55

66
[dependencies]
7-
stackable-operator = { path = "../stackable-operator" }
7+
stackable-operator = { path = "../stackable-operator", features = ["crds"] }
88

99
clap.workspace = true
1010
paste.workspace = true

0 commit comments

Comments
 (0)