Skip to content

Add typed printcolumn argument to derive macro#1872

Merged
doxxx93 merged 4 commits into
kube-rs:mainfrom
cchndl:nicer-printcolumns
Feb 19, 2026
Merged

Add typed printcolumn argument to derive macro#1872
doxxx93 merged 4 commits into
kube-rs:mainfrom
cchndl:nicer-printcolumns

Conversation

@cchndl
Copy link
Copy Markdown
Contributor

@cchndl cchndl commented Dec 27, 2025

Motivation

The raw json for the additional print columns is not not very nice to read, especially compared to the nice definition for the scale sub-resource.

Solution

Introduce the same structure from change #1656 for the printcolumn argument. I basically just traced the steps of that change for this one.

    printcolumn(
        name = "Spec",
        type_ = "string",
        description = "name of foo",
        json_path = ".spec.name"
    ),

Tests are still missing, I just wanted to know first whether I should include both empty/present printcolumns and both the raw-json way and the new one introduced here.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 28, 2025

Codecov Report

❌ Patch coverage is 71.60494% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.2%. Comparing base (d7b8275) to head (003f668).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
kube-derive/src/custom_resource.rs 70.2% 23 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1872     +/-   ##
=======================================
- Coverage   76.3%   76.2%   -0.0%     
=======================================
  Files         88      89      +1     
  Lines       8408    8487     +79     
=======================================
+ Hits        6411    6465     +54     
- Misses      1997    2022     +25     
Files with missing lines Coverage Δ
kube-derive/src/lib.rs 0.0% <ø> (ø)
kube-derive/tests/crd_schema_test.rs 100.0% <ø> (ø)
kube-derive/tests/typed_subresource.rs 100.0% <100.0%> (ø)
kube-derive/src/custom_resource.rs 81.3% <70.2%> (-2.9%) ⬇️

... 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.

@clux
Copy link
Copy Markdown
Member

clux commented Jan 6, 2026

Hey there, thanks for this. It does indeed remind me of #1656 . Does it support the old syntax or is it a breaking change?

I'll try to summon @Techassi to get some opinions 🙏

@Techassi
Copy link
Copy Markdown
Contributor

Techassi commented Jan 6, 2026

I have been summoned, and I shall answer :)

I can take a look at the PR later and leave some comments if there is anything worth pointing out.

Copy link
Copy Markdown
Contributor

@Techassi Techassi left a comment

Choose a reason for hiding this comment

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

Nicely done! Nothing major, just a few small things.

I wanted to tackle this, but didn't get around to it. So it is nice to see that someone else picked this up on their own 👍

Comment thread kube-derive/src/custom_resource.rs Outdated
Comment thread examples/crd_derive.rs
Comment thread kube-derive/src/custom_resource.rs
Comment thread kube-derive/src/custom_resource.rs
Comment thread kube-derive/src/custom_resource.rs Outdated
Comment thread kube-derive/src/custom_resource.rs Outdated
Comment thread kube-derive/src/custom_resource.rs Outdated
Comment thread kube-derive/src/lib.rs
Comment thread kube-derive/src/lib.rs
Comment thread kube-derive/src/custom_resource.rs
@Techassi
Copy link
Copy Markdown
Contributor

Techassi commented Jan 6, 2026

Does it support the old syntax or is it a breaking change?

I can confirm this is non-breaking and still supports to old raw JSON syntax after doing the review.

@cchndl
Copy link
Copy Markdown
Contributor Author

cchndl commented Feb 1, 2026

Thanks for the quick feedback, sadly I was not able to come back to this earlier.
I updated the doc comments and tests according to @Techassi's recommendations and I added additional tests for checking that the raw json string and the new syntax are compatible in typed_subresources.rs, better names welcome :)

@Techassi
Copy link
Copy Markdown
Contributor

I've run through you recent changes - nicely done. Everything from my comments was addressed. Sadly I cannot resolve my own comments, but I left comments indicating that they are resolved. Feel free to mark them as resolved (whoever is able to do that).

I think the PR should then be ready to go.

@doxxx93
Copy link
Copy Markdown
Member

doxxx93 commented Feb 13, 2026

@cchndl Almost there! It looks like the only remaining issue is the DCO (Developer Certificate of Origin) sign-off.

Per the CONTRIBUTING.md, each commit needs to be signed off using the -s/--signoff flag on git commit to attest that you have the right to contribute the code.

You can fix this by amending your commits with:

git rebase HEAD~<number_of_commits> --signoff
git push --force-with-lease

@Techassi Thanks for the thorough review! Once the DCO check passes, I'll run the workflows.

@cchndl cchndl force-pushed the nicer-printcolumns branch from f9edc4b to e5eb7c4 Compare February 19, 2026 08:29
@cchndl
Copy link
Copy Markdown
Contributor Author

cchndl commented Feb 19, 2026

I think I made a mistake somewhere

Allows specifying custom printer columns in a structured way analogous
to scale in kube-rs#1656. Supplying a raw json string is still supported.

Signed-off-by: cchndl <[email protected]>
use the new syntax in tests, add a test to check that the raw json
produces the same output
Extended the doc comments as suggested by Techassi

Signed-off-by: cchndl <[email protected]>
@cchndl cchndl force-pushed the nicer-printcolumns branch from e5eb7c4 to b65097e Compare February 19, 2026 08:41
@cchndl
Copy link
Copy Markdown
Contributor Author

cchndl commented Feb 19, 2026

Sorry, I have not mixed merges and rebases until now, didn't know about --rebase-merges. But now at least it should be fine, even if I lost us the history of the pr...

@doxxx93
Copy link
Copy Markdown
Member

doxxx93 commented Feb 19, 2026

@cchndl run just fmt please!

Copy link
Copy Markdown
Member

@doxxx93 doxxx93 left a comment

Choose a reason for hiding this comment

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

Thanks! fyi: @clux as techassi told it's ready for merge!

@doxxx93 doxxx93 added the changelog-add changelog added category for prs label Feb 19, 2026
@doxxx93 doxxx93 enabled auto-merge (squash) February 19, 2026 09:31
@clux clux added this to the 3.1.0 milestone Feb 19, 2026
@doxxx93 doxxx93 merged commit 5c97036 into kube-rs:main Feb 19, 2026
16 checks passed
@cchndl
Copy link
Copy Markdown
Contributor Author

cchndl commented Feb 19, 2026

Thank you for your patience! I hope it will go smoother next time.

@doxxx93
Copy link
Copy Markdown
Member

doxxx93 commented Feb 19, 2026

Not at all! It's impressive that you tackled such a large task and saw it through to the end on your first contribution. Thank you for the great work!

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

Labels

changelog-add changelog added category for prs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants