When attempting to generate a CRD for an object with a field of type any
, a panic happens.
Example file to reproduce:
// +kubebuilder:object:generate=true
// +groupName=example.com
package v1beta2
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +kubebuilder:object:root=true
type MyKind struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:",inline"`
Spec MyKindSpec `json:"spec"`
}
type MyKindSpec struct {
Foo any `json:"foo"`
}
Gives:
panic: interface conversion: *types.Interface is not interface { Obj() *types.TypeName }: missing method Obj
I'm expecting a soft error and not a crash. For example when defining a field with type map[string]any
, an error is logged but a best-effort CRD is still generated:
/path/to/file.go:LINE:COL: not a supported map value type: *ast.InterfaceType