I am playing around with writing a CRD for kubernetes, and am having trouble getting the code-generator to work. In particular, generating deepcopy functions is failing for a particular struct, which has reference to a batch.JobTemplateSpec
. Commenting out that line fixes my issue.
I've already tried various imports and registering the JobTemplateSpec
in register.go
, but that doesn't seem to be the solution.
In particular, the struct looks something like this:
type TestSpec struct {
Selector *metav1.LabelSelector `json:"selector,omitempty"`
//Commenting out the JobTemplate fixes my problem
JobTemplate batch.JobTemplateSpec `json:"jobTemplate,omitempty"`
}
What I end up getting is this error from the codegen script:
Generating client codes...
Generating deepcopy funcs
F0411 18:54:09.409084 251 deepcopy.go:885] Hit an unsupported type invalid type for invalid type, from test/pkg/apis/test/v1.TestSpec
and the rest of code gen fails.
I experienced this issue trying to replicate the steps in https://blog.openshift.com/kubernetes-deep-dive-code-generation-customresources/ and found that I needed to change directory to avoid this issue.
If I was at the root of my Go workspace, e.g. $GOPATH/src
, I got the error you received. But if I changed to the project directory, e.g. $GOPATH/src/github.com/openshift-evangelist/crd-code-generation
, the issue went away.