Skip to content

Commit 8fd3c3f

Browse files
committed
wip(stackable-versioned): impl ApplyResource for CustomResourceDefinition
NOTE: Just added comments to describe the next steps. NOTE: We will need to move to async, since the kube api and discovery is async.
1 parent 7b13023 commit 8fd3c3f

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use std::convert::Infallible;
2+
3+
use k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition;
4+
5+
use crate::apply_resource::ApplyResource;
6+
7+
impl ApplyResource for CustomResourceDefinition {
8+
type Error = Infallible;
9+
10+
fn apply(&self, _kube_client: kube::Client) -> Result<(), Self::Error> {
11+
// 1. Using the kube::Client, check if the CRD already exists.
12+
// If it does not exist, then simple apply.
13+
//
14+
// 2. If the CRD already exists, then get it, and check...
15+
// - spec.conversion (this is likely to change, which is fine)
16+
// - spec.group (this should probably never change)
17+
// - spec.names (it is ok to add names, probably not great to remove them)
18+
// - spec.preserve_unknown_fields (is this ok to change?)
19+
// - spec.scope (this should probably never change)
20+
//
21+
// 3. For spec.versions, where "A" is the sert of versions applied to the server,
22+
// and "B" is the set of versions to be applied...
23+
// - A - B: These versions are candidates for removal
24+
// - B - A: These versions can be safely appended
25+
// - A ∩ B: These versions are likely to change in the following ways:
26+
// - New fields added (safe for vXalphaY, vXbetaY, and vX)
27+
// - Fields changed (can happen in vXalphaY, vXbetaY, but shouldn't in vX)
28+
// - Fields removed (can happen in vXalphaY, vXbetaY, but shouldn't in vX)
29+
//
30+
// Complete the rest of the owl...
31+
Ok(())
32+
}
33+
}

crates/stackable-versioned/src/flux_converter/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use snafu::Snafu;
99

1010
use crate::ParseResourceVersionError;
1111

12+
mod apply_crd;
13+
1214
#[cfg(test)]
1315
mod tests;
1416

0 commit comments

Comments
 (0)