kube-rs / kube

Rust Kubernetes client and controller runtime
https://kube.rs
Apache License 2.0
3.06k stars 320 forks source link

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

Closed verokarhu closed 2 weeks ago

verokarhu commented 3 weeks ago

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.

codecov[bot] commented 3 weeks ago

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 :warning:
Additional details and impacted files ```diff @@ 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](https://app.codecov.io/gh/kube-rs/kube/pull/1631?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kube-rs) | Coverage Δ | | |---|---|---| | [kube-derive/src/lib.rs](https://app.codecov.io/gh/kube-rs/kube/pull/1631?src=pr&el=tree&filepath=kube-derive%2Fsrc%2Flib.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kube-rs#diff-a3ViZS1kZXJpdmUvc3JjL2xpYi5ycw==) | `0.0% <ø> (ø)` | | | [kube-derive/tests/crd\_schema\_test.rs](https://app.codecov.io/gh/kube-rs/kube/pull/1631?src=pr&el=tree&filepath=kube-derive%2Ftests%2Fcrd_schema_test.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kube-rs#diff-a3ViZS1kZXJpdmUvdGVzdHMvY3JkX3NjaGVtYV90ZXN0LnJz) | `96.9% <ø> (ø)` | | | [kube-derive/src/custom\_resource.rs](https://app.codecov.io/gh/kube-rs/kube/pull/1631?src=pr&el=tree&filepath=kube-derive%2Fsrc%2Fcustom_resource.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=kube-rs#diff-a3ViZS1kZXJpdmUvc3JjL2N1c3RvbV9yZXNvdXJjZS5ycw==) | `82.3% <88.5%> (+0.9%)` | :arrow_up: |
verokarhu commented 2 weeks ago

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