-
Notifications
You must be signed in to change notification settings - Fork 462
Closed
Description
controller-gen will sometimes fail to create the CRD manifests when using a custom slice type, e.g. type Foos []Foo and the listType and listMapKey markers.
To reproduce this create a sample project with kubebuilder v2.3.1:
kubebuilder init --repo temp
kubebuilder create api --group ship --version v1beta1 --kind Frigate
and then add the following to the api/v1beta1/frigate_types.go file:
// FrigateStatus defines the observed state of Frigate
type FrigateStatus struct {
// +kubebuilder:validation:Type=array
// +optional
// +listType=map
// +listMapKey=type
Conditions Conditions `json:"conditions,omitempty"`
}
type Conditions []Condition
type Condition struct {
Type string `json:"type,omitemtpy"`
Status string `json:"status,omitempty"`
}Running make manifests will then on occasion yield the following errors:
/tmp/test/api/v1beta1/frigate_types.go:35:2: must apply listType to an array
/tmp/test/api/v1beta1/frigate_types.go:35:2: must apply listMapKey to an associative-list
If the +kubebuilder:validation:Type=array marker is above the type definition it fails consistently.
I have verified that this occurs with both v0.2.5 and v0.3.0.
The issue seem to come the fact that both listType and kubebuilder:validation:Type markers implement ApplyFirst to ensure they get applied before all other markers. But since applyMarkers loops over a map, the order is random.
piepmatz and zx8
Metadata
Metadata
Assignees
Labels
No labels