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 <[email protected]>
Co-authored-by: Sebastian Bernauer <[email protected]>
Co-authored-by: Techassi <[email protected]>
Signed-off-by: Nick Larsen <[email protected]>
@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.2%. Comparing base (b14f3d7) to head (221510e).

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.6%   75.2%   +0.6%     
=======================================
  Files         84      90      +6     
  Lines       7910    8083    +173     
=======================================
+ Hits        5900    6071    +171     
- Misses      2010    2012      +2     
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 2 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:
  [email protected] requires rustc 1.88

For me, I get [email protected]. Should I pin the dependency?

home = "0.5.4"

@sbernauer
Copy link
Contributor

Created #1840 to address the home CI failures

@Techassi
Copy link
Contributor

Techassi commented Nov 4, 2025

I've just synced this PR branch to include the CI fixes (done in #1840). This PR should now be ready for review.

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

3 participants