Skip to content

[WIP] Update to schemars 1.0 #1780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Danil-Grigorev
Copy link
Member

@Danil-Grigorev Danil-Grigorev commented Jun 25, 2025

Motivation

Manually update schemars to 1.0 to support future changes.

Solution

Re-implement some of the breaking changes to allow existing CRD parsing logic to be preserved, as they rely on structured schema instead of serde_json::Value.

Signed-off-by: Danil-Grigorev <[email protected]>
Signed-off-by: Danil-Grigorev <[email protected]>
/// A JSON Schema object.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema)]
#[serde(rename_all = "camelCase", default)]
pub struct SchemaObject {
Copy link
Member

@clux clux Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably many of these types here were lifted from schemars 0.8?
Are they necessary for us or is it mostly an api convenience?

Secondly, are they necessary to stay here as pub? They don't seem used in the examples. EDIT: tried out; you can basically remove pub from all of them except the original StructuralSchemaRewriter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed those pub keywords. It is needed to preserve logic unchanged, it works well, and edge cases where it fails are related (sourced) to the schemars changes regarding updates to serde(flatten) handling. I can expand on the issue later if needed.

These structures come from v0.8 tag in schemars, although I can also remove dangling parts which are not currently used if the size of added definitions matters. Simply having them in place makes implementing overrides easier, then operating on raw serde_json::Value, and I suspect rewriting current logic to the upstream suggested migration guide would still require implementing similar structures there and then.

Copy link

codecov bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 81.96721% with 11 lines in your changes missing coverage. Please review.

Project coverage is 76.5%. Comparing base (3366a61) to head (1c46714).

Files with missing lines Patch % Lines
kube-core/src/duration.rs 0.0% 4 Missing ⚠️
kube-core/src/schema.rs 81.9% 4 Missing ⚠️
kube-core/src/cel.rs 89.7% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1780     +/-   ##
=======================================
+ Coverage   76.5%   76.5%   +0.1%     
=======================================
  Files         84      84             
  Lines       7896    7915     +19     
=======================================
+ Hits        6038    6054     +16     
- Misses      1858    1861      +3     
Files with missing lines Coverage Δ
kube-derive/src/cel_schema.rs 94.0% <100.0%> (+0.3%) ⬆️
kube-derive/src/custom_resource.rs 84.2% <ø> (ø)
kube-core/src/cel.rs 63.5% <89.7%> (+0.5%) ⬆️
kube-core/src/duration.rs 60.5% <0.0%> (ø)
kube-core/src/schema.rs 87.7% <81.9%> (-2.5%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@clux clux added this to the next-major milestone Jun 27, 2025
@clux clux added the changelog-change changelog change category for prs label Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-change changelog change category for prs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants