sync(k8s.io/gengo): 70ad626ed2d7a483d89d2c4c56364d60b48ee8fc

This commit is contained in:
Dr. Stefan Schimanski 2017-10-06 10:11:00 +02:00
parent 4f00d3a67d
commit e1b4613291
3 changed files with 55 additions and 29 deletions

20
Godeps/Godeps.json generated
View File

@ -3042,43 +3042,43 @@
},
{
"ImportPath": "k8s.io/gengo/args",
"Rev": "9e661e9308f078838e266cca1c673922088c0ea4"
"Rev": "70ad626ed2d7a483d89d2c4c56364d60b48ee8fc"
},
{
"ImportPath": "k8s.io/gengo/examples/deepcopy-gen/generators",
"Rev": "9e661e9308f078838e266cca1c673922088c0ea4"
"Rev": "70ad626ed2d7a483d89d2c4c56364d60b48ee8fc"
},
{
"ImportPath": "k8s.io/gengo/examples/defaulter-gen/generators",
"Rev": "9e661e9308f078838e266cca1c673922088c0ea4"
"Rev": "70ad626ed2d7a483d89d2c4c56364d60b48ee8fc"
},
{
"ImportPath": "k8s.io/gengo/examples/import-boss/generators",
"Rev": "9e661e9308f078838e266cca1c673922088c0ea4"
"Rev": "70ad626ed2d7a483d89d2c4c56364d60b48ee8fc"
},
{
"ImportPath": "k8s.io/gengo/examples/set-gen/generators",
"Rev": "9e661e9308f078838e266cca1c673922088c0ea4"
"Rev": "70ad626ed2d7a483d89d2c4c56364d60b48ee8fc"
},
{
"ImportPath": "k8s.io/gengo/examples/set-gen/sets",
"Rev": "9e661e9308f078838e266cca1c673922088c0ea4"
"Rev": "70ad626ed2d7a483d89d2c4c56364d60b48ee8fc"
},
{
"ImportPath": "k8s.io/gengo/generator",
"Rev": "9e661e9308f078838e266cca1c673922088c0ea4"
"Rev": "70ad626ed2d7a483d89d2c4c56364d60b48ee8fc"
},
{
"ImportPath": "k8s.io/gengo/namer",
"Rev": "9e661e9308f078838e266cca1c673922088c0ea4"
"Rev": "70ad626ed2d7a483d89d2c4c56364d60b48ee8fc"
},
{
"ImportPath": "k8s.io/gengo/parser",
"Rev": "9e661e9308f078838e266cca1c673922088c0ea4"
"Rev": "70ad626ed2d7a483d89d2c4c56364d60b48ee8fc"
},
{
"ImportPath": "k8s.io/gengo/types",
"Rev": "9e661e9308f078838e266cca1c673922088c0ea4"
"Rev": "70ad626ed2d7a483d89d2c4c56364d60b48ee8fc"
},
{
"ImportPath": "k8s.io/heapster/metrics/api/v1/types",

27
vendor/k8s.io/gengo/args/args.go generated vendored
View File

@ -39,13 +39,12 @@ import (
// Default returns a defaulted GeneratorArgs. You may change the defaults
// before calling AddFlags.
func Default() *GeneratorArgs {
generatorArgs := &GeneratorArgs{
OutputBase: DefaultSourceTree(),
GoHeaderFilePath: filepath.Join(DefaultSourceTree(), "k8s.io/gengo/boilerplate/boilerplate.go.txt"),
GeneratedBuildTag: "ignore_autogenerated",
return &GeneratorArgs{
OutputBase: DefaultSourceTree(),
GoHeaderFilePath: filepath.Join(DefaultSourceTree(), "k8s.io/gengo/boilerplate/boilerplate.go.txt"),
GeneratedBuildTag: "ignore_autogenerated",
defaultCommandLineFlags: true,
}
generatorArgs.AddFlags(pflag.CommandLine)
return generatorArgs
}
// GeneratorArgs has arguments that are passed to generators.
@ -76,6 +75,15 @@ type GeneratorArgs struct {
// Any custom arguments go here
CustomArgs interface{}
// Whether to use default command line flags
defaultCommandLineFlags bool
}
// WithoutDefaultFlagParsing disables implicit addition of command line flags and parsing.
func (g *GeneratorArgs) WithoutDefaultFlagParsing() *GeneratorArgs {
g.defaultCommandLineFlags = false
return g
}
func (g *GeneratorArgs) AddFlags(fs *pflag.FlagSet) {
@ -148,8 +156,11 @@ func DefaultSourceTree() string {
// If you don't need any non-default behavior, use as:
// args.Default().Execute(...)
func (g *GeneratorArgs) Execute(nameSystems namer.NameSystems, defaultSystem string, pkgs func(*generator.Context, *GeneratorArgs) generator.Packages) error {
pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
pflag.Parse()
if g.defaultCommandLineFlags {
g.AddFlags(pflag.CommandLine)
pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
pflag.Parse()
}
b, err := g.NewBuilder()
if err != nil {

37
vendor/k8s.io/gengo/parser/parse.go generated vendored
View File

@ -27,6 +27,7 @@ import (
"os"
"os/exec"
"path/filepath"
"sort"
"strings"
"github.com/golang/glog"
@ -425,13 +426,20 @@ func (b *Builder) typeCheckPackage(pkgPath importPathString) (*tc.Package, error
// FindPackages fetches a list of the user-imported packages.
// Note that you need to call b.FindTypes() first.
func (b *Builder) FindPackages() []string {
// Iterate packages in a predictable order.
pkgPaths := []string{}
for k := range b.typeCheckedPackages {
pkgPaths = append(pkgPaths, string(k))
}
sort.Strings(pkgPaths)
result := []string{}
for pkgPath := range b.typeCheckedPackages {
if b.userRequested[pkgPath] {
for _, pkgPath := range pkgPaths {
if b.userRequested[importPathString(pkgPath)] {
// Since walkType is recursive, all types that are in packages that
// were directly mentioned will be included. We don't need to
// include all types in all transitive packages, though.
result = append(result, string(pkgPath))
result = append(result, pkgPath)
}
}
return result
@ -440,16 +448,17 @@ func (b *Builder) FindPackages() []string {
// FindTypes finalizes the package imports, and searches through all the
// packages for types.
func (b *Builder) FindTypes() (types.Universe, error) {
u := types.Universe{}
// Take a snapshot of pkgs to iterate, since this will recursively mutate
// b.parsed.
keys := []importPathString{}
// b.parsed. Iterate in a predictable order.
pkgPaths := []string{}
for pkgPath := range b.parsed {
keys = append(keys, pkgPath)
pkgPaths = append(pkgPaths, string(pkgPath))
}
for _, pkgPath := range keys {
if err := b.findTypesIn(pkgPath, &u); err != nil {
sort.Strings(pkgPaths)
u := types.Universe{}
for _, pkgPath := range pkgPaths {
if err := b.findTypesIn(importPathString(pkgPath), &u); err != nil {
return nil, err
}
}
@ -526,7 +535,13 @@ func (b *Builder) findTypesIn(pkgPath importPathString, u *types.Universe) error
b.addVariable(*u, nil, tv)
}
}
for p := range b.importGraph[pkgPath] {
importedPkgs := []string{}
for k := range b.importGraph[pkgPath] {
importedPkgs = append(importedPkgs, string(k))
}
sort.Strings(importedPkgs)
for _, p := range importedPkgs {
u.AddImports(string(pkgPath), p)
}
return nil