-
Notifications
You must be signed in to change notification settings - Fork 422
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
Empty "Items" object for array in generated v1 CRD is invalid #477
Comments
I meet the same problem, it seems that it doesn't work well for recursive struct definition. When I apply generated crd to k8s, it prints out The CustomResourceDefinition "daemonsets.kube-manager.karrier.io" is invalid: spec.validation.openAPIV3Schema.properties[spec].properties[updateStrategy].properties[priorityStrategy].properties[orderPriority].items.properties[orderPriority].items.type: Required value: must not be empty for specified array items And my struct is recursive list as well: type PriorityStrategy struct {
OrderPriority []OrderPriorityItem `json:"orderPriority,omitempty"`
}
type OrderPriorityItem struct {
Selector metav1.LabelSelector `json:"selector,omitempty"`
OrderPriority []OrderPriorityItem `json:"orderPriority,omitempty"`
} generated crd is : priorityStrategy:
properties:
orderPriority:
items:
properties:
orderPriority:
items: {}
type: array
selector: |
Ah. This... could be a clearer error message. There's no way to have a CRD with recursive types right now, because that would require references, and SIG API Machinery has thus far been reluctant to support references in CRDs. Specifically, |
I'm going to close this out and file a bug for erroring on recursive types. Feel free to comment there if you have more input |
Thanks @DirectXMan12! 🙂 |
We've got a CRD generated by
controller-gen
that gets an empty Items object for a list/array in the yaml output. Given that this is a v1 CRD, this results in the CRD not being applicable to a cluster (k8s 1.16+ at least, it seems). It doesn't seem possible to add any markers to influence this, so I'm currently working around it by changing it after generation to havetype: object
.Also, I'm not sure if it's related (might be why
items
is empty?), is that this type is recursive: aRoute
instance can have aRoutes
field, which is a[]Route
.Here's the type definition that the offending CRD is generated from, and here's how it's generated.
This might be related to the discussion in #342 where @sttts and @DirectXMan12 talk about possibly having
:items:
markers, but I'm not sure. Maybe at a minimum it should by default be able to add the requiredtype: object
for this case (without needing a marker)?The text was updated successfully, but these errors were encountered: