-
-
Notifications
You must be signed in to change notification settings - Fork 331
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
Refactor kube-derive using darling #435
Conversation
a6a739d
to
55f0a7d
Compare
55f0a7d
to
0209892
Compare
status: Option<String>, | ||
#[darling(multiple, rename = "shortname")] | ||
shortnames: Vec<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oo, that's nice. Assume this is using rust-analyzer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using rust-analyzer, but "did you mean" is darling
's feature /~https://github.com/TedDriggs/darling/blob/d128844d71445bef93c6449612d16d6dc28625e8/core/src/error/kind.rs#L175
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it was more that RA sometimes has issues with certain derive macros for me. But if this works fine then that's great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful. kube-derive is basically business logic only now.
|
||
/// Values we can parse from #[kube(attrs)] | ||
#[derive(Debug, Default)] | ||
#[derive(Debug, Default, FromDeriveInput)] | ||
#[darling(attributes(kube))] | ||
struct KubeAttrs { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome. Gets rid of so much code, and darling seems pretty light on dependencies as well. Great clean-up.
kind ci is a false negative. I am happy to merge. |
I started looking into better tests (#179) and have some nice tests for failures using /~https://github.com/dtolnay/trybuild. I'll push it soon. |
@@ -0,0 +1,23 @@ | |||
error: Missing field `group` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shows errors from all the missing required attributes (not stopping at group
anymore)
@@ -0,0 +1,5 @@ | |||
error: Enums or Unions can not #[derive(CustomResource)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed the error message was missing ]
thanks to this test.
All green now 🎉 Please merge if the new tests looks good. |
I noticed a typo in a test file name... |
hah, was just about to hit the button |
1f59214
to
21d6754
Compare
// If you make a change, remove `tests/ui/*.stderr` and run `cargo test`. | ||
// Then copy the files that appear under `wip/` if it's what you expected. | ||
// Alternatively, run `TRYBUILD=overwrite cargo test`. | ||
// See /~https://github.com/dtolnay/trybuild |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect!
Same false negative, will try to fix that in #437. Happy to merge. |
Released in 0.51.0 :-) |
Make parsing macro inputs declarative with
darling
.See the diff (only the first commit that refactors) ignoring whitespace.