Skip to content

Commit

Permalink
chore(stackable-versioned): Remove {write,print}_merged_crd function
Browse files Browse the repository at this point in the history
The dependency on stackable-shared can cause some conflicts in
projects which use stackable-versioned. This also de-couples
Stackable specific code from the versioning macro, which we want
to be usable outside of Stackable as well.

Consumers can still generate the merged CRD and then use functions
from the stackable_shared::CustomResourceExt trait to print or
write the YAML.
  • Loading branch information
Techassi committed Nov 29, 2024
1 parent 2512a17 commit a388863
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions crates/stackable-versioned-macros/src/codegen/container/struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,6 @@ impl Struct {
let kube_core_path = &*kubernetes_options.crates.kube_core;

// TODO (@Techassi): Use proper visibility instead of hard-coding 'pub'
// TODO (@Techassi): Move the YAML printing code into 'stackable-versioned' so that we don't
// have any cross-dependencies and the macro can be used on it's own (K8s features of course
// still need kube and friends).
Some(quote! {
#automatically_derived
pub enum #enum_ident {
Expand All @@ -374,45 +371,6 @@ impl Struct {
) -> ::std::result::Result<#k8s_openapi_path::apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition, #kube_core_path::crd::MergeError> {
#kube_core_path::crd::merge_crds(vec![#(#fn_calls),*], &stored_apiversion.to_string())
}

/// Generates and writes a merged CRD which contains all versions defined using the `#[versioned()]`
/// macro to a file located at `path`.
pub fn write_merged_crd<P>(path: P, stored_apiversion: Self, operator_version: &str) -> Result<(), ::stackable_versioned::Error>
where P: AsRef<::std::path::Path>
{
use ::stackable_shared::yaml::{YamlSchema, SerializeOptions};

let merged_crd = Self::merged_crd(stored_apiversion).map_err(|err| ::stackable_versioned::Error::MergeCrd {
source: err,
})?;

YamlSchema::write_yaml_schema(
&merged_crd,
path,
operator_version,
SerializeOptions::default()
).map_err(|err| ::stackable_versioned::Error::SerializeYaml {
source: err,
})
}

/// Generates and writes a merged CRD which contains all versions defined using the `#[versioned()]`
/// macro to stdout.
pub fn print_merged_crd(stored_apiversion: Self, operator_version: &str) -> Result<(), ::stackable_versioned::Error> {
use ::stackable_shared::yaml::{YamlSchema, SerializeOptions};

let merged_crd = Self::merged_crd(stored_apiversion).map_err(|err| ::stackable_versioned::Error::MergeCrd {
source: err,
})?;

YamlSchema::print_yaml_schema(
&merged_crd,
operator_version,
SerializeOptions::default()
).map_err(|err| ::stackable_versioned::Error::SerializeYaml {
source: err,
})
}
}
})
}
Expand Down

0 comments on commit a388863

Please sign in to comment.