@@ -302,6 +302,9 @@ impl Struct {
302
302
let automatically_derived = is_nested. not ( ) . then ( || quote ! { #[ automatically_derived] } ) ;
303
303
304
304
// 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).
305
308
Some ( quote ! {
306
309
#automatically_derived
307
310
pub enum #enum_ident {
@@ -325,6 +328,45 @@ impl Struct {
325
328
) -> :: std:: result:: Result <:: k8s_openapi:: apiextensions_apiserver:: pkg:: apis:: apiextensions:: v1:: CustomResourceDefinition , :: kube:: core:: crd:: MergeError > {
326
329
:: kube:: core:: crd:: merge_crds( vec![ #( #fn_calls) , * ] , & stored_apiversion. to_string( ) )
327
330
}
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
+ }
328
370
}
329
371
} )
330
372
}
0 commit comments