Update go dependencies (#4524)
This commit is contained in:
parent
2ba1a9e71a
commit
341d64b652
412 changed files with 43034 additions and 34165 deletions
10
vendor/k8s.io/gengo/args/args.go
generated
vendored
10
vendor/k8s.io/gengo/args/args.go
generated
vendored
|
|
@ -74,6 +74,9 @@ type GeneratorArgs struct {
|
|||
// If true, only verify, don't write anything.
|
||||
VerifyOnly bool
|
||||
|
||||
// If true, include *_test.go files
|
||||
IncludeTestFiles bool
|
||||
|
||||
// GeneratedBuildTag is the tag used to identify code generated by execution
|
||||
// of this type. Each generator should use a different tag, and different
|
||||
// groups of generators (external API that depends on Kube generations) should
|
||||
|
|
@ -127,6 +130,10 @@ func (g *GeneratorArgs) LoadGoBoilerplate() ([]byte, error) {
|
|||
// directories.
|
||||
func (g *GeneratorArgs) NewBuilder() (*parser.Builder, error) {
|
||||
b := parser.New()
|
||||
|
||||
// flag for including *_test.go
|
||||
b.IncludeTestFiles = g.IncludeTestFiles
|
||||
|
||||
// Ignore all auto-generated files.
|
||||
b.AddBuildTags(g.GeneratedBuildTag)
|
||||
|
||||
|
|
@ -184,6 +191,9 @@ func (g *GeneratorArgs) Execute(nameSystems namer.NameSystems, defaultSystem str
|
|||
return fmt.Errorf("Failed making a parser: %v", err)
|
||||
}
|
||||
|
||||
// pass through the flag on whether to include *_test.go files
|
||||
b.IncludeTestFiles = g.IncludeTestFiles
|
||||
|
||||
c, err := generator.NewContext(b, nameSystems, defaultSystem)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed making a context: %v", err)
|
||||
|
|
|
|||
22
vendor/k8s.io/gengo/examples/deepcopy-gen/generators/deepcopy.go
generated
vendored
22
vendor/k8s.io/gengo/examples/deepcopy-gen/generators/deepcopy.go
generated
vendored
|
|
@ -718,7 +718,7 @@ func (g *genDeepCopy) doMap(t *types.Type, sw *generator.SnippetWriter) {
|
|||
}
|
||||
|
||||
if !ut.Key.IsAssignable() {
|
||||
klog.Fatalf("Hit an unsupported type %v.", uet)
|
||||
klog.Fatalf("Hit an unsupported type %v for: %v", uet, t)
|
||||
}
|
||||
|
||||
sw.Do("*out = make($.|raw$, len(*in))\n", t)
|
||||
|
|
@ -745,6 +745,10 @@ func (g *genDeepCopy) doMap(t *types.Type, sw *generator.SnippetWriter) {
|
|||
case uet.IsAssignable():
|
||||
sw.Do("(*out)[key] = val\n", nil)
|
||||
case uet.Kind == types.Interface:
|
||||
// Note: do not generate code that won't compile as `DeepCopyinterface{}()` is not a valid function
|
||||
if uet.Name.Name == "interface{}" {
|
||||
klog.Fatalf("DeepCopy of %q is unsupported. Instead, use named interfaces with DeepCopy<named-interface> as one of the methods.", uet.Name.Name)
|
||||
}
|
||||
sw.Do("if val == nil {(*out)[key]=nil} else {\n", nil)
|
||||
// Note: if t.Elem has been an alias "J" of an interface "I" in Go, we will see it
|
||||
// as kind Interface of name "J" here, i.e. generate val.DeepCopyJ(). The golang
|
||||
|
|
@ -761,7 +765,7 @@ func (g *genDeepCopy) doMap(t *types.Type, sw *generator.SnippetWriter) {
|
|||
case uet.Kind == types.Struct:
|
||||
sw.Do("(*out)[key] = *val.DeepCopy()\n", uet)
|
||||
default:
|
||||
klog.Fatalf("Hit an unsupported type %v.", uet)
|
||||
klog.Fatalf("Hit an unsupported type %v for %v", uet, t)
|
||||
}
|
||||
sw.Do("}\n", nil)
|
||||
}
|
||||
|
|
@ -793,6 +797,10 @@ func (g *genDeepCopy) doSlice(t *types.Type, sw *generator.SnippetWriter) {
|
|||
g.generateFor(ut.Elem, sw)
|
||||
sw.Do("}\n", nil)
|
||||
} else if uet.Kind == types.Interface {
|
||||
// Note: do not generate code that won't compile as `DeepCopyinterface{}()` is not a valid function
|
||||
if uet.Name.Name == "interface{}" {
|
||||
klog.Fatalf("DeepCopy of %q is unsupported. Instead, use named interfaces with DeepCopy<named-interface> as one of the methods.", uet.Name.Name)
|
||||
}
|
||||
sw.Do("if (*in)[i] != nil {\n", nil)
|
||||
// Note: if t.Elem has been an alias "J" of an interface "I" in Go, we will see it
|
||||
// as kind Interface of name "J" here, i.e. generate val.DeepCopyJ(). The golang
|
||||
|
|
@ -802,7 +810,7 @@ func (g *genDeepCopy) doSlice(t *types.Type, sw *generator.SnippetWriter) {
|
|||
} else if uet.Kind == types.Struct {
|
||||
sw.Do("(*in)[i].DeepCopyInto(&(*out)[i])\n", nil)
|
||||
} else {
|
||||
klog.Fatalf("Hit an unsupported type %v.", uet)
|
||||
klog.Fatalf("Hit an unsupported type %v for %v", uet, t)
|
||||
}
|
||||
sw.Do("}\n", nil)
|
||||
}
|
||||
|
|
@ -863,6 +871,10 @@ func (g *genDeepCopy) doStruct(t *types.Type, sw *generator.SnippetWriter) {
|
|||
sw.Do("in.$.name$.DeepCopyInto(&out.$.name$)\n", args)
|
||||
}
|
||||
case uft.Kind == types.Interface:
|
||||
// Note: do not generate code that won't compile as `DeepCopyinterface{}()` is not a valid function
|
||||
if uft.Name.Name == "interface{}" {
|
||||
klog.Fatalf("DeepCopy of %q is unsupported. Instead, use named interfaces with DeepCopy<named-interface> as one of the methods.", uft.Name.Name)
|
||||
}
|
||||
sw.Do("if in.$.name$ != nil {\n", args)
|
||||
// Note: if t.Elem has been an alias "J" of an interface "I" in Go, we will see it
|
||||
// as kind Interface of name "J" here, i.e. generate val.DeepCopyJ(). The golang
|
||||
|
|
@ -870,7 +882,7 @@ func (g *genDeepCopy) doStruct(t *types.Type, sw *generator.SnippetWriter) {
|
|||
sw.Do(fmt.Sprintf("out.$.name$ = in.$.name$.DeepCopy%s()\n", uft.Name.Name), args)
|
||||
sw.Do("}\n", nil)
|
||||
default:
|
||||
klog.Fatalf("Hit an unsupported type %v.", uft)
|
||||
klog.Fatalf("Hit an unsupported type %v for %v, from %v", uft, ft, t)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -907,6 +919,6 @@ func (g *genDeepCopy) doPointer(t *types.Type, sw *generator.SnippetWriter) {
|
|||
sw.Do("*out = new($.Elem|raw$)\n", ut)
|
||||
sw.Do("(*in).DeepCopyInto(*out)\n", nil)
|
||||
default:
|
||||
klog.Fatalf("Hit an unsupported type %v.", uet)
|
||||
klog.Fatalf("Hit an unsupported type %v for %v", uet, t)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
22
vendor/k8s.io/gengo/examples/import-boss/generators/import_restrict.go
generated
vendored
22
vendor/k8s.io/gengo/examples/import-boss/generators/import_restrict.go
generated
vendored
|
|
@ -19,6 +19,7 @@ package generators
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
|
@ -196,6 +197,8 @@ func (importRuleFile) VerifyFile(f *generator.File, path string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
forbiddenImports := map[string]string{}
|
||||
allowedMismatchedImports := []string{}
|
||||
for _, r := range rules.Rules {
|
||||
re, err := regexp.Compile(r.SelectorRegexp)
|
||||
if err != nil {
|
||||
|
|
@ -209,7 +212,7 @@ func (importRuleFile) VerifyFile(f *generator.File, path string) error {
|
|||
for _, forbidden := range r.ForbiddenPrefixes {
|
||||
klog.V(4).Infof("Checking %v against %v\n", v, forbidden)
|
||||
if strings.HasPrefix(v, forbidden) {
|
||||
return fmt.Errorf("import %v has forbidden prefix %v", v, forbidden)
|
||||
forbiddenImports[v] = forbidden
|
||||
}
|
||||
}
|
||||
found := false
|
||||
|
|
@ -221,10 +224,25 @@ func (importRuleFile) VerifyFile(f *generator.File, path string) error {
|
|||
}
|
||||
}
|
||||
if !found {
|
||||
return fmt.Errorf("import %v did not match any allowed prefix", v)
|
||||
allowedMismatchedImports = append(allowedMismatchedImports, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(forbiddenImports) > 0 || len(allowedMismatchedImports) > 0 {
|
||||
var errorBuilder strings.Builder
|
||||
for i, f := range forbiddenImports {
|
||||
fmt.Fprintf(&errorBuilder, "import %v has forbidden prefix %v\n", i, f)
|
||||
}
|
||||
if len(allowedMismatchedImports) > 0 {
|
||||
sort.Sort(sort.StringSlice(allowedMismatchedImports))
|
||||
fmt.Fprintf(&errorBuilder, "the following imports did not match any allowed prefix:\n")
|
||||
for _, i := range allowedMismatchedImports {
|
||||
fmt.Fprintf(&errorBuilder, " %v\n", i)
|
||||
}
|
||||
}
|
||||
return errors.New(errorBuilder.String())
|
||||
}
|
||||
if len(rules.Rules) > 0 {
|
||||
klog.V(2).Infof("%v passes rules found in %v\n", path, actualPath)
|
||||
}
|
||||
|
|
|
|||
6
vendor/k8s.io/gengo/examples/set-gen/generators/sets.go
generated
vendored
6
vendor/k8s.io/gengo/examples/set-gen/generators/sets.go
generated
vendored
|
|
@ -205,17 +205,19 @@ func $.type|public$KeySet(theMap interface{}) $.type|public$ {
|
|||
}
|
||||
|
||||
// Insert adds items to the set.
|
||||
func (s $.type|public$) Insert(items ...$.type|raw$) {
|
||||
func (s $.type|public$) Insert(items ...$.type|raw$) $.type|public$ {
|
||||
for _, item := range items {
|
||||
s[item] = Empty{}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Delete removes all items from the set.
|
||||
func (s $.type|public$) Delete(items ...$.type|raw$) {
|
||||
func (s $.type|public$) Delete(items ...$.type|raw$) $.type|public$ {
|
||||
for _, item := range items {
|
||||
delete(s, item)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Has returns true if and only if item is contained in the set.
|
||||
|
|
|
|||
6
vendor/k8s.io/gengo/examples/set-gen/sets/byte.go
generated
vendored
6
vendor/k8s.io/gengo/examples/set-gen/sets/byte.go
generated
vendored
|
|
@ -46,17 +46,19 @@ func ByteKeySet(theMap interface{}) Byte {
|
|||
}
|
||||
|
||||
// Insert adds items to the set.
|
||||
func (s Byte) Insert(items ...byte) {
|
||||
func (s Byte) Insert(items ...byte) Byte {
|
||||
for _, item := range items {
|
||||
s[item] = Empty{}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Delete removes all items from the set.
|
||||
func (s Byte) Delete(items ...byte) {
|
||||
func (s Byte) Delete(items ...byte) Byte {
|
||||
for _, item := range items {
|
||||
delete(s, item)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Has returns true if and only if item is contained in the set.
|
||||
|
|
|
|||
6
vendor/k8s.io/gengo/examples/set-gen/sets/int.go
generated
vendored
6
vendor/k8s.io/gengo/examples/set-gen/sets/int.go
generated
vendored
|
|
@ -46,17 +46,19 @@ func IntKeySet(theMap interface{}) Int {
|
|||
}
|
||||
|
||||
// Insert adds items to the set.
|
||||
func (s Int) Insert(items ...int) {
|
||||
func (s Int) Insert(items ...int) Int {
|
||||
for _, item := range items {
|
||||
s[item] = Empty{}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Delete removes all items from the set.
|
||||
func (s Int) Delete(items ...int) {
|
||||
func (s Int) Delete(items ...int) Int {
|
||||
for _, item := range items {
|
||||
delete(s, item)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Has returns true if and only if item is contained in the set.
|
||||
|
|
|
|||
6
vendor/k8s.io/gengo/examples/set-gen/sets/int64.go
generated
vendored
6
vendor/k8s.io/gengo/examples/set-gen/sets/int64.go
generated
vendored
|
|
@ -46,17 +46,19 @@ func Int64KeySet(theMap interface{}) Int64 {
|
|||
}
|
||||
|
||||
// Insert adds items to the set.
|
||||
func (s Int64) Insert(items ...int64) {
|
||||
func (s Int64) Insert(items ...int64) Int64 {
|
||||
for _, item := range items {
|
||||
s[item] = Empty{}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Delete removes all items from the set.
|
||||
func (s Int64) Delete(items ...int64) {
|
||||
func (s Int64) Delete(items ...int64) Int64 {
|
||||
for _, item := range items {
|
||||
delete(s, item)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Has returns true if and only if item is contained in the set.
|
||||
|
|
|
|||
6
vendor/k8s.io/gengo/examples/set-gen/sets/string.go
generated
vendored
6
vendor/k8s.io/gengo/examples/set-gen/sets/string.go
generated
vendored
|
|
@ -46,17 +46,19 @@ func StringKeySet(theMap interface{}) String {
|
|||
}
|
||||
|
||||
// Insert adds items to the set.
|
||||
func (s String) Insert(items ...string) {
|
||||
func (s String) Insert(items ...string) String {
|
||||
for _, item := range items {
|
||||
s[item] = Empty{}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Delete removes all items from the set.
|
||||
func (s String) Delete(items ...string) {
|
||||
func (s String) Delete(items ...string) String {
|
||||
for _, item := range items {
|
||||
delete(s, item)
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// Has returns true if and only if item is contained in the set.
|
||||
|
|
|
|||
15
vendor/k8s.io/gengo/parser/parse.go
generated
vendored
15
vendor/k8s.io/gengo/parser/parse.go
generated
vendored
|
|
@ -43,6 +43,9 @@ type importPathString string
|
|||
type Builder struct {
|
||||
context *build.Context
|
||||
|
||||
// If true, include *_test.go
|
||||
IncludeTestFiles bool
|
||||
|
||||
// Map of package names to more canonical information about the package.
|
||||
// This might hold the same value for multiple names, e.g. if someone
|
||||
// referenced ./pkg/name or in the case of vendoring, which canonicalizes
|
||||
|
|
@ -304,11 +307,17 @@ func (b *Builder) addDir(dir string, userRequested bool) error {
|
|||
b.absPaths[pkgPath] = buildPkg.Dir
|
||||
}
|
||||
|
||||
for _, n := range buildPkg.GoFiles {
|
||||
if !strings.HasSuffix(n, ".go") {
|
||||
files := []string{}
|
||||
files = append(files, buildPkg.GoFiles...)
|
||||
if b.IncludeTestFiles {
|
||||
files = append(files, buildPkg.TestGoFiles...)
|
||||
}
|
||||
|
||||
for _, file := range files {
|
||||
if !strings.HasSuffix(file, ".go") {
|
||||
continue
|
||||
}
|
||||
absPath := filepath.Join(buildPkg.Dir, n)
|
||||
absPath := filepath.Join(buildPkg.Dir, file)
|
||||
data, err := ioutil.ReadFile(absPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("while loading %q: %v", absPath, err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue