Skip to content

Better top-level CRD descriptions #7

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

Open
fhennig opened this issue Nov 29, 2023 · 2 comments
Open

Better top-level CRD descriptions #7

fhennig opened this issue Nov 29, 2023 · 2 comments

Comments

@fhennig
Copy link
Contributor

fhennig commented Nov 29, 2023

We need to patch it in kube-rs to be able to edit this property.

diff --git a/kube-derive/src/custom_resource.rs b/kube-derive/src/custom_resource.rs
index 177abe7d..a02160b1 100644
--- a/kube-derive/src/custom_resource.rs
+++ b/kube-derive/src/custom_resource.rs
@@ -10,6 +10,7 @@ struct KubeAttrs {
     group: String,
     version: String,
     kind: String,
+    description: Option<String>,
     #[darling(rename = "root")]
     kind_struct: Option<String>,
     /// lowercase plural of kind (inferred if omitted)
@@ -145,6 +146,7 @@ pub(crate) fn derive(input: proc_macro2::TokenStream) -> proc_macro2::TokenStrea
         kind,
         kind_struct,
         version,
+        description,
         namespaced,
         derives,
         schema: schema_mode,
@@ -239,7 +241,8 @@ pub(crate) fn derive(input: proc_macro2::TokenStream) -> proc_macro2::TokenStrea
         derive_paths.push(syn::parse_quote! { #schemars::JsonSchema });
     }
 
-    let docstr = format!(" Auto-generated derived type for {ident} via `CustomResource`");
+    let docstr = description
+        .unwrap_or_else(|| format!(" Auto-generated derived type for {ident} via `CustomResource`"));
     let quoted_serde = Literal::string(&serde.to_token_stream().to_string());
     let root_obj = quote! {
         #[doc = #docstr]
@fhennig
Copy link
Contributor Author

fhennig commented Nov 30, 2023

@sbernauer kindly made an upstream PR: kube-rs/kube#1359

@fhennig
Copy link
Contributor Author

fhennig commented Jan 2, 2024

Update: The new kube-rs release includes our feature now! 🥳

We could make the top level crds nicer now, but it's not a priority for now I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant