Skip to content

Conversation

@NickLarsenNZ
Copy link
Contributor

Fixes #1821

This updates the kube Schema hoisting since schemars Schema's have changed.

  • Add tests for a variety of enum use-cases:
    • Tagged vs Untagged
    • Unit vs Tuple vs Structural variants
    • With and without doc-comments (descriptions)
  • Rewrite the hoisting logic
    • This is annotated with dev-comments to help understand intend and to ease future schemars changes.

This also fixes other issues that appeared along the way:

  • Untagged enum variant doc-comments were being applied to field descriptions.
  • Additional null entry added to enums.

See also: stackabletech#1, where this work was originally done.


Motivation

Since kube 1.0.0, schemas became invalid when optional enums contained comments on the variants.

Solution

  • Break out the hoisting logic into separate modules with scoped tests.
    • Heavily document the steps to help developers with future schemars Schema generation changes.
  • Add tests to try and catch this in future.

Fixes kube Schema conversion since schemars Schema's have changed.

- Add tests for a variety of enum use-cases:
  - Tagged vs Untagged
  - Unit vs Tuple vs Structural variants
  - With and without doc-comments (descriptions)
- Rewrite the hoisting logic
  - This is annotated with dev-comments to help understand intend and to ease future schemars changes.

This also fixes other issues:
- Untagged enum variant doc-comments were being applied to field descriptions.
- Additional `null` entry added to enums.

---------

Co-authored-by: Nick Larsen <nick.larsen@stackable.tech>
Co-authored-by: Sebastian Bernauer <sebastian.bernauer@stackable.tech>
Co-authored-by: Techassi <git@techassi.dev>
Signed-off-by: Nick Larsen <nick.larsen@stackable.tech>
@codecov
Copy link

codecov bot commented Oct 29, 2025

Codecov Report

❌ Patch coverage is 96.65272% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.0%. Comparing base (7c63f56) to head (cfdfcd1).

Files with missing lines Patch % Lines
kube-core/src/schema/transform_any_of.rs 91.7% 3 Missing ⚠️
kube-core/src/schema/transform_one_of.rs 90.4% 3 Missing ⚠️
kube-core/src/schema/transform_properties.rs 97.4% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1839     +/-   ##
=======================================
+ Coverage   74.5%   75.0%   +0.6%     
=======================================
  Files         84      90      +6     
  Lines       7877    8050    +173     
=======================================
+ Hits        5867    6037    +170     
- Misses      2010    2013      +3     
Files with missing lines Coverage Δ
kube-core/src/schema/mod.rs 100.0% <100.0%> (ø)
...re/src/schema/transform_optional_enum_with_null.rs 100.0% <100.0%> (ø)
kube-derive/src/custom_resource.rs 83.9% <100.0%> (-<0.1%) ⬇️
kube-derive/tests/crd_complex_enum_tests.rs 100.0% <100.0%> (ø)
kube-derive/tests/crd_mixed_enum_test.rs 100.0% <100.0%> (ø)
kube-derive/tests/crd_schema_test.rs 100.0% <100.0%> (ø)
kube-derive/tests/crd_top_level_enum_test.rs 100.0% <ø> (ø)
kube-core/src/schema/transform_properties.rs 97.4% <97.4%> (ø)
kube-core/src/schema/transform_any_of.rs 91.7% <91.7%> (ø)
kube-core/src/schema/transform_one_of.rs 90.4% <90.4%> (ø)

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@NickLarsenNZ
Copy link
Contributor Author

I'm unsure what to do about the CI error:

error: rustc 1.86.0 is not supported by the following package:
  home@0.5.12 requires rustc 1.88

For me, I get home@0.5.9. Should I pin the dependency?

home = "0.5.4"

@sbernauer
Copy link
Contributor

Created #1840 to address the home CI failures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CRD generation for optional enums broke with kube 2.0.0

2 participants