<p>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 <code>batch.JobTemplateSpec</code>. Commenting out that line fixes my issue.</p>

<p>I've already tried various imports and registering the <code>JobTemplateSpec</code> in <code>register.go</code>, but that doesn't seem to be the solution.</p>

<p>In particular, the struct looks something like this:</p>

<pre class="lang-golang prettyprint-override"><code>type TestSpec struct {

    Selector *metav1.LabelSelector `json:"selector,omitempty"`

    //Commenting out the JobTemplate fixes my problem
    JobTemplate batch.JobTemplateSpec `json:"jobTemplate,omitempty"`

}
</code></pre>

<p>What I end up getting is this error from the codegen script:</p>

<pre><code>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
</code></pre>

<p>and the rest of code gen fails.</p>

user3769061
<p>I experienced this issue trying to replicate the steps in <a href="https://blog.openshift.com/kubernetes-deep-dive-code-generation-customresources/" rel="nofollow noreferrer">https://blog.openshift.com/kubernetes-deep-dive-code-generation-customresources/</a> and found that I needed to change directory to avoid this issue.</p>

<p>If I was at the root of my Go workspace, e.g. <code>$GOPATH/src</code>, I got the error you received. But if I changed to the project directory, e.g. <code>$GOPATH/src/github.com/openshift-evangelist/crd-code-generation</code>, the issue went away.</p>
