include the client-gen arguments in the generated files

This commit is contained in:
Chao Xu 2016-03-13 16:26:26 -07:00
parent c0d3a0acce
commit d83175571d
3 changed files with 18 additions and 0 deletions

View File

@ -41,4 +41,6 @@ type Args struct {
ClientsetOnly bool
// FakeClient determines if client-gen generates the fake clients.
FakeClient bool
// CmdArgs is the command line arguments supplied when the client-gen is called.
CmdArgs string
}

View File

@ -18,6 +18,7 @@ limitations under the License.
package generators
import (
"fmt"
"os"
"path/filepath"
"strings"
@ -153,6 +154,11 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
glog.Fatalf("cannot convert arguments.CustomArgs to clientgenargs.Args")
}
if len(customArgs.CmdArgs) != 0 {
boilerplate = append(boilerplate, []byte(fmt.Sprintf("\n// This file is generated by client-gen with arguments: %s\n\n", customArgs.CmdArgs))...)
} else {
boilerplate = append(boilerplate, []byte(fmt.Sprintf("\n// This file is generated by client-gen with the default arguments.\n\n"))...)
}
gvToTypes := map[unversioned.GroupVersion][]*types.Type{}
for gv, inputDir := range customArgs.GroupVersionToInputPath {
p := context.Universe.Package(inputDir)

View File

@ -74,6 +74,14 @@ func parseInputVersions() (paths []string, groupVersions []unversioned.GroupVers
func main() {
arguments := args.Default()
flag.Parse()
var cmdArgs string
flag.VisitAll(func(f *flag.Flag) {
if !f.Changed {
return
}
cmdArgs = cmdArgs + fmt.Sprintf("--%s=%s ", f.Name, f.Value)
})
dependencies := []string{
"k8s.io/kubernetes/pkg/fields",
"k8s.io/kubernetes/pkg/labels",
@ -97,6 +105,7 @@ func main() {
"k8s.io/kubernetes/cmd/libs/go2idl/client-gen/testoutput/clientset_generated/",
false,
false,
cmdArgs,
}
} else {
inputPath, groupVersions, gvToPath, err := parseInputVersions()
@ -119,6 +128,7 @@ func main() {
*clientsetPath,
*clientsetOnly,
*fakeClient,
cmdArgs,
}
}