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
Setting PreserverUnknownFields marker on both type and field generates an invalid schema #688
Comments
Looks definitely weird, but I don't know what the expected behavior of controller-gen is if markers are set twice. In ClusterAPI we use It seems logical to deduplicate when the field and struct markers are identical. I assume in general the behavior is to just use both the markers from the struct and from the field when generating the schema? (so currently it works in general if there are no duplicate markers?) |
I'm not very familiar with the code but it looks weird to me too. From what I understand, every struct is first processed separately, then root types are flattened to produce the CRD schema by walking the struct definitions. TBH I don't see a good reason to not merge |
Let's see what @alvaroaleman and/or @akutz think. I'm just more like an occasional contributor and user :). |
Until then I created a WIP PR with the changes I did locally #689 (hopefully it will help the discussion around the issue and the eventual fix) |
When setting the
kubebuilder:pruning:PreserveUnknownFields
on a struct and a field using that struct, the generated schema is not valid.For example:
Will generate the following schema:
The problematic part being:
From what I observed, this happens when flattening the schema.
I managed to fix the bug by adding a case for
XPreserveUnknownFields
here to prevent hoisting:controller-tools/pkg/crd/flatten.go
Lines 105 to 156 in f89071a
While this fixed the bug, I'm not too sure about the fix itself.
I can open a PR but would like to confirm it's a bug first and eventually if the fix I tried makes sense.
cc @akutz @sbueringer (per Alvaro's recommendation).
The text was updated successfully, but these errors were encountered: