You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If Go type of a CRD has a field that uses +listType or +listMapKey markers, but the field (struct member) is a typedef to a slice type, the field is not detected as an "array" field, and these markers cannot be applied to it.
controller-gen crd paths=./api/... [...]
[...]/status_types.go:35:2: must apply listType to an array, found
[...]/status_types.go:35:2: must apply listMapKey to an array, found
Details
This reproes in HEAD (as well as v0.14, v0.15).
If we do not use the declaration for the slice type (type Conditions []Condition) in the root object and instead use []Conditions as the struct member type, it works as expected.
I think this is happening probably because the tool uses AST parsing, and Conditions struct member doesn't appear like an array in this snippet, it calls structToSchema instead of arrayToSchema.
/kind bug
The text was updated successfully, but these errors were encountered:
In my opinion, let's keep the bug open. It seems like it would be possible to evaluate the parsed AST to resolve the specified type as a typedef (ast.Ident) and realize the underlying type is of an array type.
Summary
If Go type of a CRD has a field that uses
+listType
or+listMapKey
markers, but the field (struct member) is a typedef to a slice type, the field is not detected as an "array" field, and these markers cannot be applied to it.Example
Fails with error:
Details
This reproes in HEAD (as well as v0.14, v0.15).
If we do not use the declaration for the slice type (
type Conditions []Condition
) in the root object and instead use[]Conditions
as the struct member type, it works as expected.I think this is happening probably because the tool uses AST parsing, and
Conditions
struct member doesn't appear like an array in this snippet, it callsstructToSchema
instead ofarrayToSchema
./kind bug
The text was updated successfully, but these errors were encountered: