Skip to content

Commit be3a7a1

Browse files
committed
fix: Correctly skip merged_crd generation
This also adds a test to validate that the relevant code is not generated of the skip option is set.
1 parent 0e4a704 commit be3a7a1

File tree

3 files changed

+100
-2
lines changed

3 files changed

+100
-2
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#[versioned(
2+
version(name = "v1alpha1"),
3+
version(name = "v1beta1"),
4+
version(name = "v1"),
5+
k8s(
6+
group = "stackable.tech",
7+
singular = "foo",
8+
plural = "foos",
9+
namespaced,
10+
skip(merged_crd)
11+
)
12+
)]
13+
// ---
14+
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, schemars::JsonSchema)]
15+
pub struct FooSpec {
16+
#[versioned(
17+
added(since = "v1beta1"),
18+
changed(since = "v1", from_name = "bah", from_type = "u16")
19+
)]
20+
bar: usize,
21+
baz: bool,
22+
}

crates/stackable-versioned-macros/fixtures/snapshots/[email protected]

Lines changed: 76 additions & 0 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl Struct {
266266
version: &VersionDefinition,
267267
) -> Option<(IdentString, String, TokenStream)> {
268268
match &self.common.options.kubernetes_options {
269-
Some(_) => {
269+
Some(options) if !options.skip_merged_crd => {
270270
let enum_variant_ident = version.inner.as_variant_ident();
271271
let enum_variant_string = version.inner.to_string();
272272

@@ -280,7 +280,7 @@ impl Struct {
280280

281281
Some((enum_variant_ident, enum_variant_string, merge_crds_fn_call))
282282
}
283-
None => None,
283+
_ => None,
284284
}
285285
}
286286

0 commit comments

Comments
 (0)