-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add OpenAPI required tag for all required types #6397
Comments
A quick test of what adding It fails the apidiff test though so the risk of this happening accidentally is extremely low IMO. |
I don't have strong opinions on using this tag, but IMO it seems to be something we can defer to the next API bump. From a quick test adding TL;DR; following our current standard we are slightly less explicit in the code, but we are already ok in generated CRDs. |
My vote, to avoid potential surprises later is that we should be explicit on all fields and have either Being explicit means should mean that we prevent surprises later should anything change in the logic of the generation (unlikely) or if a user accidentally, or deliberately, adds a package level optional tag (which would change the defaults). |
I think it's hard to accidentally add the optional marker on the package level and miss it in reviews as a lot of CRDs change / or the verify job fails. But I think it would be still nice to be explicit so that on every single field there is an explicit decision to make a field optional or required. My only concern is if it's sustainable to enforce via manual reviews that every single field has an optional or required marker. It's easier to ensure nobody adds the package-level optional (as the impact is really obvious). So overall I'm in favor of making it explicit, but it would be nice to add a linter as follow-up to enforce this automatically on all fields. P.S. nit: I think we're talking about markers, tags in Go are something else. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/lifecycle frozen |
This issue has not been updated in over 1 year, and should be re-triaged. You can:
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/ /remove-triage accepted |
/triage accepted |
/priority important-longterm |
In our API types we currently conceive 'Required' as meaning not optional.
Our optional types have the following definition:
Currently with Kubernetes this is enough as fields not marked optional are required in CRDs.
We could be explicit with Optional vs Required in our API definitions by explicitly setting Required on the OpenAPI specs. This would make our API more explicit and holistic on the OpenAPI level.
It could add safety:
But complicate our UX:
See the original discussion at: #6383 (comment)
@fabriziopandini @enxebre @JoelSpeed @sbueringer
/kind feature
/area api
The text was updated successfully, but these errors were encountered: