Skip to content
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

+kubebuilder:validation:Optional is used on types which is not supported by kubebuilder #5061

Closed
1 task
pmalek opened this issue Nov 2, 2023 · 0 comments · Fixed by #5103
Closed
1 task
Assignees
Labels
area/CRD Changes in existing CRDs or introduction of new ones bug Something isn't working
Milestone

Comments

@pmalek
Copy link
Member

pmalek commented Nov 2, 2023

Problem statement

KIC's usage of kubebuilder core marker: +kubebuilder:validation:Optional seems to be inccorect, due to the placement of those markers.

https://book.kubebuilder.io/reference/markers/crd-validation.html mentions that +kubebuilder:validation:Optional can be used on fields and packages whereas we use that (somewhat) on types (e.g.

)

This causes the code marker to be interpreted as imposing the validation on package level, which is undesired.

Another consequence of this is that fields in types under that package will have their Go tags understood differently: with +kubebuilder:validation:Optional, field that have json:"name" tag, will still be marked as optional in the resulting CRD.

Related Kubernetes slack thread: https://kubernetes.slack.com/archives/CAR30FCJZ/p1698841271046759

Proposed solution

Go through +kubebuilder:validation:Optional code markers in CRD types and validate if those should be relocated.

Acceptance criteria

  • KIC is free of the invalid uses of +kubebuilder:validation:Optional described above (perhaps there are more ways to use it incorrectly, but the scope is just this)
@pmalek pmalek added the area/CRD Changes in existing CRDs or introduction of new ones label Nov 2, 2023
@pmalek pmalek added this to the KIC v3.1.0 milestone Nov 2, 2023
@mflendrich mflendrich added the bug Something isn't working label Nov 6, 2023
@randmonkey randmonkey self-assigned this Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/CRD Changes in existing CRDs or introduction of new ones bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants