Skip to content

Commit 7e233b1

Browse files
committed
test: Update basic Kubernetes snapshot test
1 parent 56d5ce2 commit 7e233b1

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed
Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/stackable-versioned-macros/src/codegen/container/struct.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ impl Struct {
302302
let automatically_derived = is_nested.not().then(|| quote! {#[automatically_derived]});
303303

304304
// TODO (@Techassi): Use proper visibility instead of hard-coding 'pub'
305+
// TODO (@Techassi): Move the YAML printing code into 'stackable-versioned' so that we don't
306+
// have any cross-dependencies and the macro can be used on it's own (K8s features of course
307+
// still need kube and friends).
305308
Some(quote! {
306309
#automatically_derived
307310
pub enum #enum_ident {
@@ -325,6 +328,45 @@ impl Struct {
325328
) -> ::std::result::Result<::k8s_openapi::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition, ::kube::core::crd::MergeError> {
326329
::kube::core::crd::merge_crds(vec![#(#fn_calls),*], &stored_apiversion.to_string())
327330
}
331+
332+
/// Generates and writes a merged CRD which contains all versions defined using the `#[versioned()]`
333+
/// macro to a file located at `path`.
334+
pub fn write_merged_crd<P>(path: P, stored_apiversion: Self, operator_version: &str) -> Result<(), ::stackable_versioned::Error>
335+
where P: AsRef<::std::path::Path>
336+
{
337+
use ::stackable_shared::yaml::{YamlSchema, SerializeOptions};
338+
339+
let merged_crd = Self::merged_crd(stored_apiversion).map_err(|err| ::stackable_versioned::Error::MergeCrd {
340+
source: err,
341+
})?;
342+
343+
YamlSchema::write_yaml_schema(
344+
&merged_crd,
345+
path,
346+
operator_version,
347+
SerializeOptions::default()
348+
).map_err(|err| ::stackable_versioned::Error::SerializeYaml {
349+
source: err,
350+
})
351+
}
352+
353+
/// Generates and writes a merged CRD which contains all versions defined using the `#[versioned()]`
354+
/// macro to stdout.
355+
pub fn print_merged_crd(stored_apiversion: Self, operator_version: &str) -> Result<(), ::stackable_versioned::Error> {
356+
use ::stackable_shared::yaml::{YamlSchema, SerializeOptions};
357+
358+
let merged_crd = Self::merged_crd(stored_apiversion).map_err(|err| ::stackable_versioned::Error::MergeCrd {
359+
source: err,
360+
})?;
361+
362+
YamlSchema::print_yaml_schema(
363+
&merged_crd,
364+
operator_version,
365+
SerializeOptions::default()
366+
).map_err(|err| ::stackable_versioned::Error::SerializeYaml {
367+
source: err,
368+
})
369+
}
328370
}
329371
})
330372
}

0 commit comments

Comments
 (0)