Skip to content

Commit 7b13023

Browse files
committed
feat(stackable-versioned): Add ApplyResource trait
1 parent 65d8016 commit 7b13023

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

crates/stackable-versioned/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ all-features = true
1414
full = ["k8s", "flux-converter"]
1515
k8s = [
1616
"stackable-versioned-macros/k8s", # Forward the k8s feature to the underlying macro crate
17+
"dep:kube",
18+
"dep:k8s-openapi",
1719
]
1820
flux-converter = [
1921
"k8s",
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use k8s_openapi::Resource;
2+
use kube::Client;
3+
use serde::Serialize;
4+
5+
/// Given a [kube::Client], apply a resource to the server.
6+
///
7+
/// This is esspecially useful when you have custom requirements for deploying
8+
/// CRDs to clusters which already have a definition.
9+
///
10+
/// For example, you want to prevent stable versions (v1) from having any
11+
/// change.
12+
pub trait ApplyResource: Resource + Serialize {
13+
type Error;
14+
15+
/// Apply a resource to a cluster
16+
fn apply(&self, kube_client: Client) -> Result<(), Self::Error>;
17+
}

crates/stackable-versioned/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ pub use stackable_versioned_macros::*;
1818
#[cfg(feature = "flux-converter")]
1919
mod flux_converter;
2020

21+
#[cfg(feature = "k8s")]
22+
mod apply_resource;
23+
2124
#[cfg(feature = "flux-converter")]
2225
pub use flux_converter::ConversionError;
2326

0 commit comments

Comments
 (0)