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

add support for CRD annotations and labels in kube-derive #1631

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

verokarhu
Copy link
Contributor

@verokarhu verokarhu commented Nov 8, 2024

This PR adds support for setting annotations and labels on kube-derive generated CRDs.

Motivation

Writing Cluster API providers requires setting specific labels on the CRD: https://cluster-api.sigs.k8s.io/developer/providers/contracts#api-version-labels

Solution

New annotation and label fields are added to kube-derive which can take a tuple of two strings as an argument.

Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 88.46154% with 3 lines in your changes missing coverage. Please review.

Project coverage is 75.3%. Comparing base (b0538cb) to head (7d0f590).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
kube-derive/src/custom_resource.rs 88.5% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #1631     +/-   ##
=======================================
+ Coverage   75.3%   75.3%   +0.1%     
=======================================
  Files         82      82             
  Lines       7346    7371     +25     
=======================================
+ Hits        5528    5550     +22     
- Misses      1818    1821      +3     
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 82.3% <88.5%> (+0.9%) ⬆️

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.

Hey, thanks for this. I think the general setup is sensible, but have one improvement request for the attribute API, which i think can be nicer.

(Also if you want, when we get it done well, feel free to also do annotation support).

kube-derive/src/lib.rs Outdated Show resolved Hide resolved
@clux clux added the changelog-add changelog added category for prs label Nov 8, 2024
@verokarhu verokarhu changed the title add support for CRD labels in kube-derive add support for CRD annotations and labels in kube-derive Nov 12, 2024
@verokarhu
Copy link
Contributor Author

I rewrote the solution so the values are now passed as a two-string tuple. Also added the annotation support.

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. tests and doc look much clearer now. thanks for taking the time to do this.

kube-derive/src/custom_resource.rs Show resolved Hide resolved
@clux clux added this to the 0.97.0 milestone Nov 13, 2024
@clux clux merged commit 8b5230f into kube-rs:main Nov 13, 2024
17 checks passed
@verokarhu verokarhu deleted the add-crd-labels branch November 13, 2024 15:48
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