-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Disambiguate duplicate Member
names
#206
Conversation
…nt case Signed-off-by: clux <[email protected]>
Signed-off-by: clux <[email protected]>
Signed-off-by: clux <[email protected]>
Signed-off-by: clux <[email protected]>
Signed-off-by: clux <[email protected]>
Signed-off-by: clux <[email protected]>
Signed-off-by: clux <[email protected]>
Signed-off-by: clux <[email protected]>
Member
names
Signed-off-by: Sebastian Hoß <[email protected]>
I like this a lot & it completely removes the need for my home grown solution (I have used yq to remove duplicate fields before passing the modified YAML to kopium). Running this against all CRDs in kube-custom-resources-rs yields a single warning though: The |
Signed-off-by: clux <[email protected]>
thanks @sebhoss , have added a smarter suffixing var to deal with the differences between struct and enum members now! |
also nice to see all that manual override code go away 😄 |
yeah this solution here is a lot better since it retains all enums/fields so people can actually use all possible values (even though they are deprecated upstream). Great stuff - thanks a lot! |
Signed-off-by: Sebastian Hoß <[email protected]>
Signed-off-by: Sebastian Hoß <[email protected]>
This adds a safer name mutation strategy in
output.rs
, by checking to see if a pascal/snake rename would generate a duplicate name, and then suffixing the name if it does to keep it rust compatible.This is to fix certain pathological cases like #165.
This solution does not drop information, and always manages to include everything in the struct (even if we don't know which one will eventually go away, like the case with relabeling actions).
Annotated Example
Using the
PodMonitor
CRD with the clashing relabeling actions, this is what we now produce on the the struct by default (minus my explaining comments about where the member name came from):Caveats
Maybe in the future if the OpenAPI spec can include deprecated attrs, we can remove this logic.
(This PR was originally trying to deduplicate members by name, but this ended up picking the wrong names, leaving the good ones unreachable by chance.)