Skip to content

Commit

Permalink
Rename fields to include "path" for accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
rmweir committed Sep 6, 2023
1 parent 2be98fc commit 98ff38a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pkg/codegen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
func main() {
controllergen.Run(args.Options{
ImportPackage: "github.com/rancher/wrangler/v2/pkg/generated",
OutputPackage: "github.com/rancher/wrangler/pkg/generated",
OutputPath: "github.com/rancher/wrangler/pkg/generated",
Boilerplate: "scripts/boilerplate.go.txt",
Groups: map[string]args.Group{
v1.GroupName: {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller-gen/args/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

type CustomArgs struct {
Package string
OutputPath string
ImportPackage string
TypesByGroup map[schema.GroupVersion][]*types.Name
Options Options
Expand All @@ -15,7 +15,7 @@ type CustomArgs struct {

type Options struct {
ImportPackage string
OutputPackage string
OutputPath string
Groups map[string]Group
Boilerplate string
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller-gen/generators/client_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (cg *ClientGenerator) typesGroupVersionPackage(name *types.Name, gv schema.
}

func (cg *ClientGenerator) groupPackage(group string, generatorArgs *args.GeneratorArgs, customArgs *args2.CustomArgs) generator.Package {
packagePath := filepath.Join(customArgs.Package, "controllers", groupPackageName(group, customArgs.Options.Groups[group].OutputControllerPackageName))
packagePath := filepath.Join(customArgs.OutputPath, "controllers", groupPackageName(group, customArgs.Options.Groups[group].OutputControllerPackageName))
return Package(generatorArgs, packagePath, func(context *generator.Context) []generator.Generator {
return []generator.Generator{
FactoryGo(group, generatorArgs, customArgs),
Expand All @@ -124,7 +124,7 @@ func (cg *ClientGenerator) groupPackage(group string, generatorArgs *args.Genera
}

func (cg *ClientGenerator) groupVersionPackage(gv schema.GroupVersion, generatorArgs *args.GeneratorArgs, customArgs *args2.CustomArgs) generator.Package {
packagePath := filepath.Join(customArgs.Package, "controllers", groupPackageName(gv.Group, customArgs.Options.Groups[gv.Group].OutputControllerPackageName), gv.Version)
packagePath := filepath.Join(customArgs.OutputPath, "controllers", groupPackageName(gv.Group, customArgs.Options.Groups[gv.Group].OutputControllerPackageName), gv.Version)

return Package(generatorArgs, packagePath, func(context *generator.Context) []generator.Generator {
generators := []generator.Generator{
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller-gen/generators/group_interface_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (f *interfaceGo) Imports(context *generator.Context) []string {
}
pkg := f.customArgs.ImportPackage
if pkg == "" {
pkg = f.customArgs.Package
pkg = f.customArgs.OutputPath
}
packages = append(packages, fmt.Sprintf("%s \"%s/controllers/%s/%s\"", gv.Version, pkg,
groupPackageName(gv.Group, f.customArgs.Options.Groups[gv.Group].OutputControllerPackageName), gv.Version))
Expand Down
14 changes: 7 additions & 7 deletions pkg/controller-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func Run(opts cgargs.Options) {
ImportPackage: opts.ImportPackage,
Options: opts,
TypesByGroup: map[schema.GroupVersion][]*types.Name{},
Package: opts.OutputPackage,
OutputPath: opts.OutputPath,
}
genericArgs := args.Default().WithoutDefaultFlagParsing()
genericArgs.CustomArgs = customArgs
Expand Down Expand Up @@ -129,7 +129,7 @@ func copyGoPathToModules(customArgs *cgargs.CustomArgs) error {
}
}

pkg := sourcePackagePath(customArgs, customArgs.Package)
pkg := sourcePackagePath(customArgs, customArgs.OutputPath)
pathsToCopy[pkg] = true

for pkg := range pathsToCopy {
Expand Down Expand Up @@ -209,7 +209,7 @@ func generateClientset(groups map[string]bool, customArgs *cgargs.CustomArgs) er
args, clientSetArgs := csargs.NewDefaults()
clientSetArgs.ClientsetName = "versioned"
args.OutputBase = customArgs.OutputBase
args.OutputPackagePath = filepath.Join(customArgs.Package, "clientset")
args.OutputPackagePath = filepath.Join(customArgs.OutputPath, "clientset")
args.GoHeaderFilePath = customArgs.Options.Boilerplate

var order []schema.GroupVersion
Expand Down Expand Up @@ -309,10 +309,10 @@ func generateInformers(groups map[string]bool, customArgs *cgargs.CustomArgs) er
}

args, clientSetArgs := infargs.NewDefaults()
clientSetArgs.VersionedClientSetPackage = filepath.Join(customArgs.Package, "clientset/versioned")
clientSetArgs.ListersPackage = filepath.Join(customArgs.Package, "listers")
clientSetArgs.VersionedClientSetPackage = filepath.Join(customArgs.OutputPath, "clientset/versioned")
clientSetArgs.ListersPackage = filepath.Join(customArgs.OutputPath, "listers")
args.OutputBase = customArgs.OutputBase
args.OutputPackagePath = filepath.Join(customArgs.Package, "informers")
args.OutputPackagePath = filepath.Join(customArgs.OutputPath, "informers")
args.GoHeaderFilePath = customArgs.Options.Boilerplate

for gv, names := range customArgs.TypesByGroup {
Expand All @@ -334,7 +334,7 @@ func generateListers(groups map[string]bool, customArgs *cgargs.CustomArgs) erro

args, _ := lsargs.NewDefaults()
args.OutputBase = customArgs.OutputBase
args.OutputPackagePath = filepath.Join(customArgs.Package, "listers")
args.OutputPackagePath = filepath.Join(customArgs.OutputPath, "listers")
args.GoHeaderFilePath = customArgs.Options.Boilerplate

for gv, names := range customArgs.TypesByGroup {
Expand Down

0 comments on commit 98ff38a

Please sign in to comment.