+kubebuilder:validation:Optional
is used on types which is not supported by kubebuilder
#5061
Milestone
+kubebuilder:validation:Optional
is used on types which is not supported by kubebuilder
#5061
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.kubernetes-ingress-controller/pkg/apis/configuration/v1/kongclusterplugin_types.go
Line 32 in 964f9d2
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 havejson:"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
+kubebuilder:validation:Optional
described above (perhaps there are more ways to use it incorrectly, but the scope is just this)The text was updated successfully, but these errors were encountered: