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
How to enum poorly documented #1071
Comments
/remove-kind bug |
Err... that's a bug /kind bug |
/good-first-issue on the docs help wanted on the cancelling out bug. I'm guessing that our allof resolution logic has a bug. Start by adding a unit test ( |
@DirectXMan12: Please ensure the request meets the requirements listed here. If this request no longer meets these requirements, the label can be removed In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign @camilamacedo86 |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/assign @djzager |
Looking into the doc portion of this issue it appears that this is already laid out in Generating CRDs. Specifically, the section concerning validation shows the correct way to do this (shortened for simplicity): type ToySpec struct {
...
Alias Alias `json:"alias,omitempty"`
Rank Rank `json:"rank"`
}
// +kubebuilder:validation:Enum=Lion;Wolf;Dragon
type Alias string |
Maybe this hsould be an issue against https://github.com/kubernetes-sigs/controller-tools ? I don't see anything in kubebuilder related to that, but searching for @DirectXMan12 what do you think? |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There are quite a few ways a user might try to make an enum. Only one or two ways are "right".
Suggested Fix:
All the ways
The Right Way
The documentation example for CronJob does an enum like this:
This works right, in that the OpenAPI
enum=
validation is generated in the CRD.However, a reasonable user might also try to do many other ways, only some of which work right.
Alternative One
kubebuilder comment on the field in the Object.
Works right
Alternative Two
kubebuilder comment on the field in the Object and on the EnumType.
Does not work. They seem to cancel out
Alternative Three
No kubebuilder comment.
does not work
User might assume that when you use the Go idiom for an enum that the OpenAPI is inferred. It isn't.
Alternative Four
Kubebuilder comment and no Go enum idiom
works but no static checking in go
/kind documentation
The text was updated successfully, but these errors were encountered: