-
Notifications
You must be signed in to change notification settings - Fork 9
k8s:optional and k8s:required should be lowercase #77
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
k8s:optional and k8s:required should be lowercase #77
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JoelSpeed The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
/lgtm
One thing to think about, especially as it related to codegen -- where should we check for different classes of "error"?
-
Some constructions can cause code-generation to fail completely, producing code which is syntactically invalid. For those cases, I think we want to fail as obviously as possible, so tools like validation-gen will explicitly check them and fail. E.g. we know pointer-to-slice is not something we use, so no effort has been put into making it work. Best to fail with "pointers to slices are not supported". Should we add things like that to lint, too?
-
Finding +k8s:format on anything other than a string will generate Go code which is syntactically valid but does not compile. Validation-gen hard fails with an error message. Should we add things like that to lint, too?
For other cases it won't fail codegen, even if it doesn't make any sense. A couple different examples:
3a) Being tagged optional AND required will generate valid Go code, but it's still nonsense. It's not universally easy to cross-check tags, because each validator is self-contained, but tags like optional and required come from the same unit. Should validation-gen fail-hard or let it go and get caught by lint?
3b) Finding +k8s:required on a pointer will generate valid code (in fact we have test cases for it) but it's probably wrong. It's not nonsense, but I think we would be best to say "not supported". Should validation-gen fail-hard or let it go and get caught by lint?
Thoughts?
I view linters as necessary, but not sufficient generally. Linters are quick, can be integrated into IDEs, and IMO provide an early feedback. Where generation is generally something done later, and takes longer. With that as my baseline, my view on this is that yes, "pointers to slices" and "k8s:format" should also be covered in lint, to give an early warning, but the generation would be a backstop. I figure pointers to slices is also likely not great in the CRD world, so adding that rule to KAL extends the usefulness of this knowledge. For the format validation, there's a kubebuilder equivalent and I had intended to check that one in KAL already, so checking the k8s version which appears to have the same semantics (must be on string) should be easy.
These second two are harder. For me this comes down to, if it works, someone is probably using it already. I suspect, with these as linter rules, we offer the advice, but it can be ignored. If this is a hard fail in validation-gen, then anyone doing this already has no get out of jail free card, right? |
These got uppercased through a hallucination this morning (I thought I'd checked against the existing implementation in validation-gen).
Thanks to @liggitt and @thockin for noticing