Skip to content

Commit 97520d9

Browse files
generators: allow configuring output directory
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
1 parent 8c922cc commit 97520d9

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

hack/update-codegen.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ ${KUBE_INFORMER_GEN} \
7070

7171
# Generate cluster-aware clients, informers and listers using generated single-cluster code
7272
./../bin/code-generator \
73-
"client:name=versioned,outputPackagePath=acme.corp/pkg/kcpexisting,apiPackagePath=acme.corp/pkg/apis,singleClusterClientPackagePath=acme.corp/pkg/generated/clientset/versioned,singleClusterApplyConfigurationsPackagePath=acme.corp/pkg/generated/applyconfigurations,headerFile=./../hack/boilerplate/boilerplate.go.txt" \
73+
"client:name=versioned,outputPackagePath=acme.corp/pkg/kcpexisting/clients,apiPackagePath=acme.corp/pkg/apis,singleClusterClientPackagePath=acme.corp/pkg/generated/clientset/versioned,singleClusterApplyConfigurationsPackagePath=acme.corp/pkg/generated/applyconfigurations,headerFile=./../hack/boilerplate/boilerplate.go.txt" \
7474
"lister:apiPackagePath=acme.corp/pkg/apis,singleClusterListerPackagePath=acme.corp/pkg/generated/listers,headerFile=./../hack/boilerplate/boilerplate.go.txt" \
75-
"informer:outputPackagePath=acme.corp/pkg/kcpexisting,apiPackagePath=acme.corp/pkg/apis,singleClusterListerPackagePath=acme.corp/pkg/generated/listers,singleClusterInformerPackagePath=acme.corp/pkg/generated/informers/externalversions,headerFile=./../hack/boilerplate/boilerplate.go.txt" \
75+
"informer:outputPackagePath=acme.corp/pkg/kcpexisting/clients,apiPackagePath=acme.corp/pkg/apis,singleClusterListerPackagePath=acme.corp/pkg/generated/listers,singleClusterInformerPackagePath=acme.corp/pkg/generated/informers/externalversions,headerFile=./../hack/boilerplate/boilerplate.go.txt" \
7676
"paths=./pkg/apis/..." \
77-
"output:dir=./pkg/kcpexisting"
77+
"output:dir=./pkg/kcpexisting/clients"
7878

7979
# Generate cluster-aware clients, informers and listers assuming no single-cluster listers or informers
8080
./../bin/code-generator \
81-
"client:name=versioned,outputPackagePath=acme.corp/pkg/kcp,apiPackagePath=acme.corp/pkg/apis,singleClusterClientPackagePath=acme.corp/pkg/generated/clientset/versioned,singleClusterApplyConfigurationsPackagePath=acme.corp/pkg/generated/applyconfigurations,headerFile=./../hack/boilerplate/boilerplate.go.txt" \
81+
"client:name=versioned,outputPackagePath=acme.corp/pkg/kcp/clients,apiPackagePath=acme.corp/pkg/apis,singleClusterClientPackagePath=acme.corp/pkg/generated/clientset/versioned,singleClusterApplyConfigurationsPackagePath=acme.corp/pkg/generated/applyconfigurations,headerFile=./../hack/boilerplate/boilerplate.go.txt" \
8282
"lister:apiPackagePath=acme.corp/pkg/apis,headerFile=./../hack/boilerplate/boilerplate.go.txt" \
83-
"informer:outputPackagePath=acme.corp/pkg/kcp,apiPackagePath=acme.corp/pkg/apis,headerFile=./../hack/boilerplate/boilerplate.go.txt" \
83+
"informer:outputPackagePath=acme.corp/pkg/kcp/clients,apiPackagePath=acme.corp/pkg/apis,headerFile=./../hack/boilerplate/boilerplate.go.txt" \
8484
"paths=./pkg/apis/..." \
85-
"output:dir=./pkg/kcp"
85+
"output:dir=./pkg/kcp/clients"
8686

8787
popd

pkg/generators/clientgen/clientgen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
9595

9696
groupInfo := toGroupVersionInfos(groupVersionKinds)
9797

98-
clientsetDir := filepath.Join("clients", "clientset", "versioned")
98+
clientsetDir := filepath.Join("clientset", "versioned")
9999
clientsetFile := filepath.Join(clientsetDir, "clientset.go")
100100
logger := klog.Background().WithValues("clientset", g.Name)
101101
logger.WithValues("path", clientsetFile).Info("generating clientset")

pkg/generators/informergen/informergen.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type Generator struct {
4040
Year string `marker:",optional"`
4141

4242
// OutputPackagePath is the root directory under which this tool will output files.
43-
// e.g. "github.com/kcp-dev/client-go"
43+
// e.g. "github.com/kcp-dev/client-go/clients"
4444
OutputPackagePath string `marker:""`
4545

4646
// APIPackagePath is the root directory under which API types exist.
@@ -102,10 +102,10 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
102102
return onlyGroups[i].Group.PackageName() < onlyGroups[j].Group.PackageName()
103103
})
104104

105-
clientsetDir := filepath.Join("clients", "clientset", "versioned")
106-
listersDir := filepath.Join("clients", "listers")
105+
clientsetDir := filepath.Join("clientset", "versioned")
106+
listersDir := "listers"
107107

108-
informersDir := filepath.Join("clients", "informers")
108+
informersDir := "informers"
109109
factoryPath := filepath.Join(informersDir, "factory.go")
110110
logger.WithValues("path", factoryPath).Info("generating informer factory")
111111
if err := util.WriteGeneratedCode(ctx, headerText, &informergen.Factory{

pkg/generators/listergen/listergen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
8686
for version, kinds := range versions {
8787
groupInfo := toGroupVersionInfo(group, version)
8888
for _, kind := range kinds {
89-
listerDir := filepath.Join("clients", "listers", group.PackageName(), version.PackageName())
89+
listerDir := filepath.Join("listers", group.PackageName(), version.PackageName())
9090
outputFile := filepath.Join(listerDir, strings.ToLower(kind.String())+".go")
9191
logger := klog.Background().WithValues(
9292
"group", group.String(),

0 commit comments

Comments
 (0)