code-generator
code-generator copied to clipboard
--with-applyconfig creates import loop for some groupName values
Using sample-controller as a reproducer, add --with-apply-config to https://github.com/kubernetes/sample-controller/blob/f53405abe7423d4addcbf2c4495604f02d6ef85f/hack/update-codegen.sh#L32-L36
Then changing groupName, for example to samplecontroller2.k8s.io, and running update-codegen will result in the following import from pkg/generated/applyconfiguration/samplecontroller/v1alpha1/foo.go
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
v1alpha1 "k8s.io/sample-controller/pkg/generated/applyconfiguration/samplecontroller/v1alpha1"
)
where the last line imports the same package it is a part of. Using --apply-config without group name change works fine.
Similar examples in the repo use simple structs like https://github.com/kubernetes/code-generator/blob/75dbfb954ff33ef26dc084b28f63d1ac478fc0f6/examples/HyphenGroup/apis/example/v1/types.go#L45-L47 that don't create applyconfiguration files and are imported directly from e.g. k8s.io/code-generator/examples/HyphenGroup/apis/example/v1
So what is the expected behaviour here? Am I missing some tricky flags maybe?