diff --git a/cmd/libs/go2idl/client-gen/args/args.go b/cmd/libs/go2idl/client-gen/args/args.go index 24608af4975..81530fb3fe6 100644 --- a/cmd/libs/go2idl/client-gen/args/args.go +++ b/cmd/libs/go2idl/client-gen/args/args.go @@ -39,6 +39,8 @@ type Args struct { // ClientsetOutputPath is the path the clientset will be generated at. It's // populated from command-line arguments. ClientsetOutputPath string + // ClientsetAPIPath is the default API path for generated clients. + ClientsetAPIPath string // ClientsetOnly determines if we should generate the clients for groups and // types along with the clientset. It's populated from command-line // arguments. diff --git a/cmd/libs/go2idl/client-gen/generators/client_generator.go b/cmd/libs/go2idl/client-gen/generators/client_generator.go index c25389cbade..b5e17db28ed 100644 --- a/cmd/libs/go2idl/client-gen/generators/client_generator.go +++ b/cmd/libs/go2idl/client-gen/generators/client_generator.go @@ -62,7 +62,7 @@ func generatedBy(customArgs clientgenargs.Args) string { return fmt.Sprintf("\n// This package is generated by client-gen with the default arguments.\n\n") } -func packageForGroup(gv unversioned.GroupVersion, typeList []*types.Type, packageBasePath string, srcTreePath string, inputPath string, boilerplate []byte, generatedBy string) generator.Package { +func packageForGroup(gv unversioned.GroupVersion, typeList []*types.Type, packageBasePath string, apiPath string, srcTreePath string, inputPath string, boilerplate []byte, generatedBy string) generator.Package { outputPackagePath := filepath.Join(packageBasePath, gv.Group, gv.Version) return &generator.DefaultPackage{ PackageName: gv.Version, @@ -102,6 +102,7 @@ func packageForGroup(gv unversioned.GroupVersion, typeList []*types.Type, packag inputPacakge: inputPath, group: gv.Group, version: gv.Version, + apiPath: apiPath, types: typeList, imports: generator.NewImportTracker(), }) @@ -217,7 +218,7 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat for _, gv := range customArgs.GroupVersions { types := gvToTypes[gv] inputPath := customArgs.GroupVersionToInputPath[gv] - packageList = append(packageList, packageForGroup(normalization.GroupVersion(gv), orderer.OrderTypes(types), typedClientBasePath, arguments.OutputBase, inputPath, boilerplate, generatedBy)) + packageList = append(packageList, packageForGroup(normalization.GroupVersion(gv), orderer.OrderTypes(types), typedClientBasePath, customArgs.ClientsetAPIPath, arguments.OutputBase, inputPath, boilerplate, generatedBy)) if customArgs.FakeClient { packageList = append(packageList, fake.PackageForGroup(normalization.GroupVersion(gv), orderer.OrderTypes(types), typedClientBasePath, arguments.OutputBase, inputPath, boilerplate, generatedBy)) } diff --git a/cmd/libs/go2idl/client-gen/generators/generator_for_group.go b/cmd/libs/go2idl/client-gen/generators/generator_for_group.go index d0cf237b690..4539c44c29b 100644 --- a/cmd/libs/go2idl/client-gen/generators/generator_for_group.go +++ b/cmd/libs/go2idl/client-gen/generators/generator_for_group.go @@ -31,6 +31,7 @@ type genGroup struct { outputPackage string group string version string + apiPath string // types in this group types []*types.Type imports namer.ImportTracker @@ -62,6 +63,9 @@ func (g *genGroup) GenerateType(c *generator.Context, t *types.Type, w io.Writer const pkgAPI = "k8s.io/kubernetes/pkg/api" const pkgSerializer = "k8s.io/kubernetes/pkg/runtime/serializer" apiPath := func(group string) string { + if len(g.apiPath) > 0 { + return `"` + g.apiPath + `"` + } if group == "core" { return `"/api"` } diff --git a/cmd/libs/go2idl/client-gen/main.go b/cmd/libs/go2idl/client-gen/main.go index 3cf9f931a66..d7b29725fa7 100644 --- a/cmd/libs/go2idl/client-gen/main.go +++ b/cmd/libs/go2idl/client-gen/main.go @@ -49,6 +49,7 @@ var ( includedTypesOverrides = flag.StringSlice("included-types-overrides", []string{}, "list of group/version/type for which client should be generated. By default, client is generated for all types which have genclient=true in types.go. This overrides that. For each groupVersion in this list, only the types mentioned here will be included. The default check of genclient=true will be used for other group versions.") basePath = flag.String("input-base", "k8s.io/kubernetes/pkg/apis", "base path to look for the api group. Default to \"k8s.io/kubernetes/pkg/apis\"") clientsetName = flag.StringP("clientset-name", "n", "internalclientset", "the name of the generated clientset package.") + clientsetAPIPath = flag.StringP("clientset-api-path", "", "", "the value of default API path.") clientsetPath = flag.String("clientset-path", "k8s.io/kubernetes/pkg/client/clientset_generated/", "the generated clientset will be output to /. Default to \"k8s.io/kubernetes/pkg/client/clientset_generated/\"") clientsetOnly = flag.Bool("clientset-only", false, "when set, client-gen only generates the clientset shell, without generating the individual typed clients") fakeClient = flag.Bool("fake-clientset", true, "when set, client-gen will generate the fake clientset that can be used in tests") @@ -177,13 +178,14 @@ func main() { if err != nil { glog.Fatalf("Unexpected error: %v", err) } - glog.Infof("going to generate clientset from these input paths: %v", inputPath) + glog.V(3).Infof("going to generate clientset from these input paths: %v", inputPath) arguments.InputDirs = append(inputPath, dependencies...) arguments.CustomArgs = clientgenargs.Args{ GroupVersions: groupVersions, GroupVersionToInputPath: gvToPath, ClientsetName: *clientsetName, + ClientsetAPIPath: *clientsetAPIPath, ClientsetOutputPath: *clientsetPath, ClientsetOnly: *clientsetOnly, FakeClient: *fakeClient, @@ -191,7 +193,7 @@ func main() { IncludedTypesOverrides: includedTypesOverrides, } - glog.Infof("==arguments: %v\n", arguments) + glog.V(3).Infof("==arguments: %v\n", arguments) } if err := arguments.Execute( diff --git a/hack/verify-flags/known-flags.txt b/hack/verify-flags/known-flags.txt index ddecfe82ba1..19214c9bbd4 100644 --- a/hack/verify-flags/known-flags.txt +++ b/hack/verify-flags/known-flags.txt @@ -65,6 +65,7 @@ cleanup-iptables client-ca-file client-certificate client-key +clientset-api-path clientset-name clientset-only clientset-path