Skip to content
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

feat: Add deprecated argument to derive macro #1697

Merged
merged 4 commits into from
Feb 19, 2025

Conversation

Techassi
Copy link
Contributor

Motivation

Currently it is not possible to set the deprecated and deprecationWarning of a particular CRD version using the derive macro.

See the official Kubernetes docs.

Solution

This PR adds one new argument to the derive macro to set one or both properties.

#[derive(CustomResource)]
#[kube(
    group = "example.org",
    version = "v1",
    kind = "Foo",
    deprecated
)]
struct MyCrdSpec {}

// Also set the deprecationWarning

#[derive(CustomResource)]
#[kube(
    group = "example.org",
    version = "v1",
    kind = "Foo",
    deprecated = "my warning"
)]
struct MyCrdSpec {}

Copy link

codecov bot commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 75.9%. Comparing base (c191439) to head (c323b67).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
kube-derive/src/custom_resource.rs 83.4% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1697     +/-   ##
=======================================
+ Coverage   75.9%   75.9%   +0.1%     
=======================================
  Files         84      84             
  Lines       7679    7685      +6     
=======================================
+ Hits        5822    5827      +5     
- Misses      1857    1858      +1     
Files with missing lines Coverage Δ
kube-derive/src/lib.rs 0.0% <ø> (ø)
kube-derive/tests/crd_schema_test.rs 96.9% <ø> (ø)
kube-derive/src/custom_resource.rs 84.1% <83.4%> (-<0.1%) ⬇️

@Techassi
Copy link
Contributor Author

The single missing line is a bummer. I thought this is covered by the doc test. Seems like codecov isn't considering doc tests when calculating coverage.

Let me know if there is a way to test the single missing line.

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

very nice! quick nit on docs

@clux clux added the changelog-add changelog added category for prs label Feb 19, 2025
@clux clux added this to the 0.99.0 milestone Feb 19, 2025
Co-authored-by: Eirik A <[email protected]>
Signed-off-by: Techassi <[email protected]>
Copy link
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 great. Will merge at green. Thank you!

@Techassi
Copy link
Contributor Author

Lovely, thank you for the quick review :)

@clux clux enabled auto-merge (squash) February 19, 2025 15:12
@clux clux merged commit 8876639 into kube-rs:main Feb 19, 2025
16 checks passed
@Techassi Techassi deleted the feat/derive-deprecated-arg branch February 19, 2025 15:20
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.

2 participants