mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
update gengo godep
This commit is contained in:
parent
052cd6d30b
commit
a3f4a8bd52
20
Godeps/Godeps.json
generated
20
Godeps/Godeps.json
generated
@ -2860,43 +2860,43 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/gengo/args",
|
"ImportPath": "k8s.io/gengo/args",
|
||||||
"Rev": "4b7dfb7a2f42f66d9f5dfdf2c1557f409eac0869"
|
"Rev": "c79c13d131b0a8f42d05faa6491c12e94ccc6f30"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/gengo/examples/deepcopy-gen/generators",
|
"ImportPath": "k8s.io/gengo/examples/deepcopy-gen/generators",
|
||||||
"Rev": "4b7dfb7a2f42f66d9f5dfdf2c1557f409eac0869"
|
"Rev": "c79c13d131b0a8f42d05faa6491c12e94ccc6f30"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/gengo/examples/defaulter-gen/generators",
|
"ImportPath": "k8s.io/gengo/examples/defaulter-gen/generators",
|
||||||
"Rev": "4b7dfb7a2f42f66d9f5dfdf2c1557f409eac0869"
|
"Rev": "c79c13d131b0a8f42d05faa6491c12e94ccc6f30"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/gengo/examples/import-boss/generators",
|
"ImportPath": "k8s.io/gengo/examples/import-boss/generators",
|
||||||
"Rev": "4b7dfb7a2f42f66d9f5dfdf2c1557f409eac0869"
|
"Rev": "c79c13d131b0a8f42d05faa6491c12e94ccc6f30"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/gengo/examples/set-gen/generators",
|
"ImportPath": "k8s.io/gengo/examples/set-gen/generators",
|
||||||
"Rev": "4b7dfb7a2f42f66d9f5dfdf2c1557f409eac0869"
|
"Rev": "c79c13d131b0a8f42d05faa6491c12e94ccc6f30"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/gengo/examples/set-gen/sets",
|
"ImportPath": "k8s.io/gengo/examples/set-gen/sets",
|
||||||
"Rev": "4b7dfb7a2f42f66d9f5dfdf2c1557f409eac0869"
|
"Rev": "c79c13d131b0a8f42d05faa6491c12e94ccc6f30"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/gengo/generator",
|
"ImportPath": "k8s.io/gengo/generator",
|
||||||
"Rev": "4b7dfb7a2f42f66d9f5dfdf2c1557f409eac0869"
|
"Rev": "c79c13d131b0a8f42d05faa6491c12e94ccc6f30"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/gengo/namer",
|
"ImportPath": "k8s.io/gengo/namer",
|
||||||
"Rev": "4b7dfb7a2f42f66d9f5dfdf2c1557f409eac0869"
|
"Rev": "c79c13d131b0a8f42d05faa6491c12e94ccc6f30"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/gengo/parser",
|
"ImportPath": "k8s.io/gengo/parser",
|
||||||
"Rev": "4b7dfb7a2f42f66d9f5dfdf2c1557f409eac0869"
|
"Rev": "c79c13d131b0a8f42d05faa6491c12e94ccc6f30"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/gengo/types",
|
"ImportPath": "k8s.io/gengo/types",
|
||||||
"Rev": "4b7dfb7a2f42f66d9f5dfdf2c1557f409eac0869"
|
"Rev": "c79c13d131b0a8f42d05faa6491c12e94ccc6f30"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/heapster/metrics/api/v1/types",
|
"ImportPath": "k8s.io/heapster/metrics/api/v1/types",
|
||||||
|
1
vendor/k8s.io/gengo/examples/deepcopy-gen/generators/deepcopy.go
generated
vendored
1
vendor/k8s.io/gengo/examples/deepcopy-gen/generators/deepcopy.go
generated
vendored
@ -196,7 +196,6 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
|||||||
expandedPath := strings.TrimPrefix(pkg.SourcePath, arguments.OutputBase)
|
expandedPath := strings.TrimPrefix(pkg.SourcePath, arguments.OutputBase)
|
||||||
if strings.Contains(expandedPath, "/vendor/") {
|
if strings.Contains(expandedPath, "/vendor/") {
|
||||||
path = expandedPath
|
path = expandedPath
|
||||||
glog.V(3).Infof(" %s", path)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
packages = append(packages,
|
packages = append(packages,
|
||||||
|
65
vendor/k8s.io/gengo/examples/defaulter-gen/generators/defaulter.go
generated
vendored
65
vendor/k8s.io/gengo/examples/defaulter-gen/generators/defaulter.go
generated
vendored
@ -38,13 +38,18 @@ type CustomArgs struct {
|
|||||||
ExtraPeerDirs []string // Always consider these as last-ditch possibilities for conversions.
|
ExtraPeerDirs []string // Always consider these as last-ditch possibilities for conversions.
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the comment tag that carries parameters for defaulter generation.
|
// These are the comment tags that carry parameters for defaulter generation.
|
||||||
const tagName = "k8s:defaulter-gen"
|
const tagName = "k8s:defaulter-gen"
|
||||||
|
const intputTagName = "k8s:defaulter-gen-input"
|
||||||
|
|
||||||
func extractTag(comments []string) []string {
|
func extractTag(comments []string) []string {
|
||||||
return types.ExtractCommentTags("+", comments)[tagName]
|
return types.ExtractCommentTags("+", comments)[tagName]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func extractInputTag(comments []string) []string {
|
||||||
|
return types.ExtractCommentTags("+", comments)[intputTagName]
|
||||||
|
}
|
||||||
|
|
||||||
func checkTag(comments []string, require ...string) bool {
|
func checkTag(comments []string, require ...string) bool {
|
||||||
values := types.ExtractCommentTags("+", comments)[tagName]
|
values := types.ExtractCommentTags("+", comments)[tagName]
|
||||||
if len(require) == 0 {
|
if len(require) == 0 {
|
||||||
@ -220,6 +225,11 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
|||||||
// If the input had no Go files, for example.
|
// If the input had no Go files, for example.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// typesPkg is where the types that needs defaulter are defined.
|
||||||
|
// Sometimes it is different from pkg. For example, kubernetes core/v1
|
||||||
|
// types are defined in vendor/k8s.io/api/core/v1, while pkg is at
|
||||||
|
// pkg/api/v1.
|
||||||
|
typesPkg := pkg
|
||||||
|
|
||||||
// Add defaulting functions.
|
// Add defaulting functions.
|
||||||
getManualDefaultingFunctions(context, pkg, existingDefaulters)
|
getManualDefaultingFunctions(context, pkg, existingDefaulters)
|
||||||
@ -271,8 +281,24 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the types are not in the same package where the defaulter functions to be generated
|
||||||
|
inputTags := extractInputTag(pkg.Comments)
|
||||||
|
if len(inputTags) > 1 {
|
||||||
|
panic(fmt.Sprintf("there could only be one input tag, got %#v", inputTags))
|
||||||
|
}
|
||||||
|
if len(inputTags) == 1 {
|
||||||
|
var err error
|
||||||
|
typesPkg, err = context.AddDirectory(filepath.Join(pkg.Path, inputTags[0]))
|
||||||
|
if err != nil {
|
||||||
|
glog.Fatalf("cannot import package %s", inputTags[0])
|
||||||
|
}
|
||||||
|
// update context.Order to the latest context.Universe
|
||||||
|
orderer := namer.Orderer{Namer: namer.NewPublicNamer(1)}
|
||||||
|
context.Order = orderer.OrderUniverse(context.Universe)
|
||||||
|
}
|
||||||
|
|
||||||
newDefaulters := defaulterFuncMap{}
|
newDefaulters := defaulterFuncMap{}
|
||||||
for _, t := range pkg.Types {
|
for _, t := range typesPkg.Types {
|
||||||
if !shouldCreateObjectDefaulterFn(t) {
|
if !shouldCreateObjectDefaulterFn(t) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -328,18 +354,33 @@ func Packages(context *generator.Context, arguments *args.GeneratorArgs) generat
|
|||||||
glog.V(5).Infof("no defaulters in package %s", pkg.Name)
|
glog.V(5).Infof("no defaulters in package %s", pkg.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path := pkg.Path
|
||||||
|
// if the source path is within a /vendor/ directory (for example,
|
||||||
|
// k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1), allow
|
||||||
|
// generation to output to the proper relative path (under vendor).
|
||||||
|
// Otherwise, the generator will create the file in the wrong location
|
||||||
|
// in the output directory.
|
||||||
|
// TODO: build a more fundamental concept in gengo for dealing with modifications
|
||||||
|
// to vendored packages.
|
||||||
|
if strings.HasPrefix(pkg.SourcePath, arguments.OutputBase) {
|
||||||
|
expandedPath := strings.TrimPrefix(pkg.SourcePath, arguments.OutputBase)
|
||||||
|
if strings.Contains(expandedPath, "/vendor/") {
|
||||||
|
path = expandedPath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
packages = append(packages,
|
packages = append(packages,
|
||||||
&generator.DefaultPackage{
|
&generator.DefaultPackage{
|
||||||
PackageName: filepath.Base(pkg.Path),
|
PackageName: filepath.Base(pkg.Path),
|
||||||
PackagePath: pkg.Path,
|
PackagePath: path,
|
||||||
HeaderText: header,
|
HeaderText: header,
|
||||||
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
|
GeneratorFunc: func(c *generator.Context) (generators []generator.Generator) {
|
||||||
return []generator.Generator{
|
return []generator.Generator{
|
||||||
NewGenDefaulter(arguments.OutputFileBaseName, pkg.Path, existingDefaulters, newDefaulters, peerPkgs),
|
NewGenDefaulter(arguments.OutputFileBaseName, typesPkg.Path, pkg.Path, existingDefaulters, newDefaulters, peerPkgs),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FilterFunc: func(c *generator.Context, t *types.Type) bool {
|
FilterFunc: func(c *generator.Context, t *types.Type) bool {
|
||||||
return t.Name.Package == pkg.Path
|
return t.Name.Package == typesPkg.Path
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -442,7 +483,8 @@ const (
|
|||||||
// genDefaulter produces a file with a autogenerated conversions.
|
// genDefaulter produces a file with a autogenerated conversions.
|
||||||
type genDefaulter struct {
|
type genDefaulter struct {
|
||||||
generator.DefaultGen
|
generator.DefaultGen
|
||||||
targetPackage string
|
typesPackage string
|
||||||
|
outputPackage string
|
||||||
peerPackages []string
|
peerPackages []string
|
||||||
newDefaulters defaulterFuncMap
|
newDefaulters defaulterFuncMap
|
||||||
existingDefaulters defaulterFuncMap
|
existingDefaulters defaulterFuncMap
|
||||||
@ -450,12 +492,13 @@ type genDefaulter struct {
|
|||||||
typesForInit []*types.Type
|
typesForInit []*types.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGenDefaulter(sanitizedName, targetPackage string, existingDefaulters, newDefaulters defaulterFuncMap, peerPkgs []string) generator.Generator {
|
func NewGenDefaulter(sanitizedName, typesPackage, outputPackage string, existingDefaulters, newDefaulters defaulterFuncMap, peerPkgs []string) generator.Generator {
|
||||||
return &genDefaulter{
|
return &genDefaulter{
|
||||||
DefaultGen: generator.DefaultGen{
|
DefaultGen: generator.DefaultGen{
|
||||||
OptionalName: sanitizedName,
|
OptionalName: sanitizedName,
|
||||||
},
|
},
|
||||||
targetPackage: targetPackage,
|
typesPackage: typesPackage,
|
||||||
|
outputPackage: outputPackage,
|
||||||
peerPackages: peerPkgs,
|
peerPackages: peerPkgs,
|
||||||
newDefaulters: newDefaulters,
|
newDefaulters: newDefaulters,
|
||||||
existingDefaulters: existingDefaulters,
|
existingDefaulters: existingDefaulters,
|
||||||
@ -467,15 +510,15 @@ func NewGenDefaulter(sanitizedName, targetPackage string, existingDefaulters, ne
|
|||||||
func (g *genDefaulter) Namers(c *generator.Context) namer.NameSystems {
|
func (g *genDefaulter) Namers(c *generator.Context) namer.NameSystems {
|
||||||
// Have the raw namer for this file track what it imports.
|
// Have the raw namer for this file track what it imports.
|
||||||
return namer.NameSystems{
|
return namer.NameSystems{
|
||||||
"raw": namer.NewRawNamer(g.targetPackage, g.imports),
|
"raw": namer.NewRawNamer(g.outputPackage, g.imports),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *genDefaulter) isOtherPackage(pkg string) bool {
|
func (g *genDefaulter) isOtherPackage(pkg string) bool {
|
||||||
if pkg == g.targetPackage {
|
if pkg == g.outputPackage {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(pkg, `"`+g.targetPackage+`"`) {
|
if strings.HasSuffix(pkg, `"`+g.outputPackage+`"`) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
8
vendor/k8s.io/gengo/generator/generator.go
generated
vendored
8
vendor/k8s.io/gengo/generator/generator.go
generated
vendored
@ -206,6 +206,14 @@ func NewContext(b *parser.Builder, nameSystems namer.NameSystems, canonicalOrder
|
|||||||
// AddDir adds a Go package to the context. The specified path must be a single
|
// AddDir adds a Go package to the context. The specified path must be a single
|
||||||
// go package import path. GOPATH, GOROOT, and the location of your go binary
|
// go package import path. GOPATH, GOROOT, and the location of your go binary
|
||||||
// (`which go`) will all be searched, in the normal Go fashion.
|
// (`which go`) will all be searched, in the normal Go fashion.
|
||||||
|
// Deprecated. Please use AddDirectory.
|
||||||
func (ctxt *Context) AddDir(path string) error {
|
func (ctxt *Context) AddDir(path string) error {
|
||||||
return ctxt.builder.AddDirTo(path, &ctxt.Universe)
|
return ctxt.builder.AddDirTo(path, &ctxt.Universe)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddDirectory adds a Go package to the context. The specified path must be a
|
||||||
|
// single go package import path. GOPATH, GOROOT, and the location of your go
|
||||||
|
// binary (`which go`) will all be searched, in the normal Go fashion.
|
||||||
|
func (ctxt *Context) AddDirectory(path string) (*types.Package, error) {
|
||||||
|
return ctxt.builder.AddDirectoryTo(path, &ctxt.Universe)
|
||||||
|
}
|
||||||
|
22
vendor/k8s.io/gengo/parser/parse.go
generated
vendored
22
vendor/k8s.io/gengo/parser/parse.go
generated
vendored
@ -251,6 +251,7 @@ func (b *Builder) AddDirRecursive(dir string) error {
|
|||||||
// generator (rather than just at init time. 'dir' must be a single go package.
|
// generator (rather than just at init time. 'dir' must be a single go package.
|
||||||
// GOPATH, GOROOT, and the location of your go binary (`which go`) will all be
|
// GOPATH, GOROOT, and the location of your go binary (`which go`) will all be
|
||||||
// searched if dir doesn't literally resolve.
|
// searched if dir doesn't literally resolve.
|
||||||
|
// Deprecated. Please use AddDirectoryTo.
|
||||||
func (b *Builder) AddDirTo(dir string, u *types.Universe) error {
|
func (b *Builder) AddDirTo(dir string, u *types.Universe) error {
|
||||||
// We want all types from this package, as if they were directly added
|
// We want all types from this package, as if they were directly added
|
||||||
// by the user. They WERE added by the user, in effect.
|
// by the user. They WERE added by the user, in effect.
|
||||||
@ -260,6 +261,24 @@ func (b *Builder) AddDirTo(dir string, u *types.Universe) error {
|
|||||||
return b.findTypesIn(canonicalizeImportPath(b.buildPackages[dir].ImportPath), u)
|
return b.findTypesIn(canonicalizeImportPath(b.buildPackages[dir].ImportPath), u)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddDirectoryTo adds an entire directory to a given Universe. Unlike AddDir,
|
||||||
|
// this processes the package immediately, which makes it safe to use from
|
||||||
|
// within a generator (rather than just at init time. 'dir' must be a single go
|
||||||
|
// package. GOPATH, GOROOT, and the location of your go binary (`which go`)
|
||||||
|
// will all be searched if dir doesn't literally resolve.
|
||||||
|
func (b *Builder) AddDirectoryTo(dir string, u *types.Universe) (*types.Package, error) {
|
||||||
|
// We want all types from this package, as if they were directly added
|
||||||
|
// by the user. They WERE added by the user, in effect.
|
||||||
|
if _, err := b.importPackage(dir, true); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
path := canonicalizeImportPath(b.buildPackages[dir].ImportPath)
|
||||||
|
if err := b.findTypesIn(path, u); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return u.Package(string(path)), nil
|
||||||
|
}
|
||||||
|
|
||||||
// The implementation of AddDir. A flag indicates whether this directory was
|
// The implementation of AddDir. A flag indicates whether this directory was
|
||||||
// user-requested or just from following the import graph.
|
// user-requested or just from following the import graph.
|
||||||
func (b *Builder) addDir(dir string, userRequested bool) error {
|
func (b *Builder) addDir(dir string, userRequested bool) error {
|
||||||
@ -462,6 +481,9 @@ func (b *Builder) findTypesIn(pkgPath importPathString, u *types.Universe) error
|
|||||||
for _, f := range b.parsed[pkgPath] {
|
for _, f := range b.parsed[pkgPath] {
|
||||||
if strings.HasSuffix(f.name, "/doc.go") {
|
if strings.HasSuffix(f.name, "/doc.go") {
|
||||||
tp := u.Package(string(pkgPath))
|
tp := u.Package(string(pkgPath))
|
||||||
|
// findTypesIn might be called multiple times. Clean up tp.Comments
|
||||||
|
// to avoid repeatedly fill same comments to it.
|
||||||
|
tp.Comments = []string{}
|
||||||
for i := range f.file.Comments {
|
for i := range f.file.Comments {
|
||||||
tp.Comments = append(tp.Comments, splitLines(f.file.Comments[i].Text())...)
|
tp.Comments = append(tp.Comments, splitLines(f.file.Comments[i].Text())...)
|
||||||
}
|
}
|
||||||
|
5
vendor/k8s.io/gengo/types/types.go
generated
vendored
5
vendor/k8s.io/gengo/types/types.go
generated
vendored
@ -101,10 +101,11 @@ type Package struct {
|
|||||||
// 'package x' line.
|
// 'package x' line.
|
||||||
Name string
|
Name string
|
||||||
|
|
||||||
// DocComments from doc.go, if any.
|
// The comment right above the package declaration in doc.go, if any.
|
||||||
DocComments []string
|
DocComments []string
|
||||||
|
|
||||||
// Comments from doc.go, if any.
|
// All comments from doc.go, if any.
|
||||||
|
// TODO: remove Comments and use DocComments everywhere.
|
||||||
Comments []string
|
Comments []string
|
||||||
|
|
||||||
// Types within this package, indexed by their name (*not* including
|
// Types within this package, indexed by their name (*not* including
|
||||||
|
Loading…
Reference in New Issue
Block a user