diff --git a/Cargo.lock b/Cargo.lock index 8dd637189..2e5a50ed1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3279,9 +3279,6 @@ dependencies = [ name = "stackable-versioned" version = "0.4.1" dependencies = [ - "kube", - "snafu 0.8.5", - "stackable-shared", "stackable-versioned-macros", ] @@ -3306,7 +3303,6 @@ dependencies = [ "serde_json", "serde_yaml", "snafu 0.8.5", - "stackable-shared", "stackable-versioned", "syn 2.0.89", "trybuild", diff --git a/crates/stackable-versioned-macros/Cargo.toml b/crates/stackable-versioned-macros/Cargo.toml index 8f547ae16..b85d45627 100644 --- a/crates/stackable-versioned-macros/Cargo.toml +++ b/crates/stackable-versioned-macros/Cargo.toml @@ -19,17 +19,16 @@ development = ["k8s-openapi", "schemars", "serde_yaml", "stackable-versioned"] # cargo-udeps throws an error stating that these dependencies are unused. They are all marked as # optional, which trips up cargo-udeps for whatever reason... -normal = ["k8s-openapi", "kube", "stackable-shared"] +normal = ["k8s-openapi", "kube"] [lib] proc-macro = true [features] full = ["k8s"] -k8s = ["dep:kube", "dep:k8s-openapi", "dep:stackable-shared"] +k8s = ["dep:kube", "dep:k8s-openapi"] [dependencies] -stackable-shared = { path = "../stackable-shared", optional = true } k8s-version = { path = "../k8s-version", features = ["darling"] } convert_case.workspace = true diff --git a/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@basic.rs.snap b/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@basic.rs.snap index 5ab28ccec..83bab4878 100644 --- a/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@basic.rs.snap +++ b/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@basic.rs.snap @@ -129,49 +129,4 @@ impl Foo { &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

( - 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, - }) - } } diff --git a/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@crate_overrides.rs.snap b/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@crate_overrides.rs.snap index 84203198e..2999586ad 100644 --- a/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@crate_overrides.rs.snap +++ b/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@crate_overrides.rs.snap @@ -132,49 +132,4 @@ impl Foo { &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

( - 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, - }) - } } diff --git a/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@module.rs.snap b/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@module.rs.snap index 4052cbf18..d01dbc544 100644 --- a/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@module.rs.snap +++ b/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@module.rs.snap @@ -246,51 +246,6 @@ impl Foo { &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

( - 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, - }) - } } #[automatically_derived] pub(crate) enum Bar { @@ -329,49 +284,4 @@ impl Bar { &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

( - 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, - }) - } } diff --git a/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@module_preserve.rs.snap b/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@module_preserve.rs.snap index 7a2aede1b..601a8a0a9 100644 --- a/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@module_preserve.rs.snap +++ b/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@module_preserve.rs.snap @@ -234,51 +234,6 @@ pub(crate) mod versioned { &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

( - 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, - }) - } } pub enum Bar { V1Alpha1, @@ -314,50 +269,5 @@ pub(crate) mod versioned { &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

( - 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, - }) - } } } diff --git a/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@renamed_kind.rs.snap b/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@renamed_kind.rs.snap index c2c826c45..fbda4713a 100644 --- a/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@renamed_kind.rs.snap +++ b/crates/stackable-versioned-macros/fixtures/snapshots/stackable_versioned_macros__test__k8s_snapshots@renamed_kind.rs.snap @@ -129,49 +129,4 @@ impl FooBar { &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

( - 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, - }) - } } diff --git a/crates/stackable-versioned-macros/src/codegen/container/struct.rs b/crates/stackable-versioned-macros/src/codegen/container/struct.rs index 68d9e54de..5d3038f7c 100644 --- a/crates/stackable-versioned-macros/src/codegen/container/struct.rs +++ b/crates/stackable-versioned-macros/src/codegen/container/struct.rs @@ -348,9 +348,6 @@ impl Struct { let k8s_openapi_path = &*kubernetes_options.crates.k8s_openapi; let kube_core_path = &*kubernetes_options.crates.kube_core; - // 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 #vis enum #enum_ident { @@ -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

(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, - }) - } } }) } diff --git a/crates/stackable-versioned/CHANGELOG.md b/crates/stackable-versioned/CHANGELOG.md index f27368dbc..dc5c4f29d 100644 --- a/crates/stackable-versioned/CHANGELOG.md +++ b/crates/stackable-versioned/CHANGELOG.md @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file. ### Removed +- BREAKING: Remove {write,print}_merged_crd functions ([#924]). - BREAKING: Remove the `CustomResource` derive ([#914]). ### Changed @@ -39,6 +40,7 @@ All notable changes to this project will be documented in this file. [#920]: https://github.com/stackabletech/operator-rs/pull/920 [#922]: https://github.com/stackabletech/operator-rs/pull/922 [#923]: https://github.com/stackabletech/operator-rs/pull/923 +[#924]: https://github.com/stackabletech/operator-rs/pull/924 [#925]: https://github.com/stackabletech/operator-rs/pull/925 ## [0.4.1] - 2024-10-23 diff --git a/crates/stackable-versioned/Cargo.toml b/crates/stackable-versioned/Cargo.toml index 5d60e8c1a..94247f174 100644 --- a/crates/stackable-versioned/Cargo.toml +++ b/crates/stackable-versioned/Cargo.toml @@ -14,14 +14,7 @@ all-features = true full = ["k8s"] k8s = [ "stackable-versioned-macros/k8s", # Forward the k8s feature to the underlying macro crate - "dep:stackable-shared", - "dep:snafu", - "dep:kube", ] [dependencies] stackable-versioned-macros = { path = "../stackable-versioned-macros" } -stackable-shared = { path = "../stackable-shared", optional = true } - -kube = { workspace = true, optional = true } -snafu = { workspace = true, optional = true } diff --git a/crates/stackable-versioned/src/lib.rs b/crates/stackable-versioned/src/lib.rs index 6352ed304..8c0c399b1 100644 --- a/crates/stackable-versioned/src/lib.rs +++ b/crates/stackable-versioned/src/lib.rs @@ -15,18 +15,6 @@ // Re-export macro pub use stackable_versioned_macros::*; -#[cfg(feature = "k8s")] -#[derive(Debug, snafu::Snafu)] -pub enum Error { - #[snafu(display("failed to merge CRDs"))] - MergeCrd { source: kube::core::crd::MergeError }, - - #[snafu(display("failed to serialize YAML"))] - SerializeYaml { - source: stackable_shared::yaml::Error, - }, -} - // Unused for now, might get picked up again in the future. #[doc(hidden)] pub trait AsVersionStr {