Skip to content

Update to schemars 1.0#1780

Merged
clux merged 5 commits into
kube-rs:mainfrom
Danil-Grigorev:update-schemars-1.0
Jul 2, 2025
Merged

Update to schemars 1.0#1780
clux merged 5 commits into
kube-rs:mainfrom
Danil-Grigorev:update-schemars-1.0

Conversation

@Danil-Grigorev
Copy link
Copy Markdown
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]>
Comment thread Cargo.toml Outdated
Comment thread kube-core/src/schema.rs Outdated
/// A JSON Schema object.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Default, JsonSchema)]
#[serde(rename_all = "camelCase", default)]
pub struct SchemaObject {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah. Makes sense. As long as it's not part of our public API this is a good step forward either way. 👍

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 87.27273% with 7 lines in your changes missing coverage. Please review.

Project coverage is 76.6%. Comparing base (3366a61) to head (17426a5).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
kube-core/src/duration.rs 0.0% 4 Missing ⚠️
kube-core/src/cel.rs 89.7% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1780     +/-   ##
=======================================
+ Coverage   76.5%   76.6%   +0.1%     
=======================================
  Files         84      84             
  Lines       7896    7909     +13     
=======================================
+ Hits        6038    6052     +14     
+ Misses      1858    1857      -1     
Files with missing lines Coverage Δ
kube-core/src/schema.rs 91.6% <100.0%> (+1.5%) ⬆️
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%> (ø)
🚀 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
Comment thread Cargo.toml Outdated
Copy link
Copy Markdown
Member

@clux clux left a comment

Choose a reason for hiding this comment

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

Looks good to me in this state. Maybe a git pin is useful, but keen to get this in.
It should help unblock the edition update #1663, and make us more ready for the next k8s-openapi bump.

@Danil-Grigorev Danil-Grigorev changed the title [WIP] Update to schemars 1.0 Update to schemars 1.0 Jul 1, 2025
@clux clux mentioned this pull request Jul 1, 2025
@clux
Copy link
Copy Markdown
Member

clux commented Jul 1, 2025

actually possibly a legit failure now in 'test_crd_schema_matches_expected' panicked at kube-derive/tests/crd_enum_test.rs:60:5: after last refactor. triggered rerun now, but seems likely legit.

@clux clux merged commit da44dd0 into kube-rs:main Jul 2, 2025
16 of 17 checks passed
@clux clux mentioned this pull request Sep 7, 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