use istio client-go library instead of knative (#1661)
use istio client-go library instead of knative bump kubernetes dependency version change code coverage to codecov
This commit is contained in:
13
vendor/k8s.io/gengo/args/args.go
generated
vendored
13
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)
|
||||
|
||||
@@ -152,6 +159,9 @@ func (g *GeneratorArgs) InputIncludes(p *types.Package) bool {
|
||||
if strings.HasSuffix(d, "...") {
|
||||
d = strings.TrimSuffix(d, "...")
|
||||
}
|
||||
if strings.HasPrefix(d, "./vendor/") {
|
||||
d = strings.TrimPrefix(d, "./vendor/")
|
||||
}
|
||||
if strings.HasPrefix(p.Path, d) {
|
||||
return true
|
||||
}
|
||||
@@ -184,6 +194,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)
|
||||
|
||||
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.
|
||||
|
||||
7
vendor/k8s.io/gengo/generator/default_package.go
generated
vendored
7
vendor/k8s.io/gengo/generator/default_package.go
generated
vendored
@@ -26,6 +26,8 @@ type DefaultPackage struct {
|
||||
PackageName string
|
||||
// Import path of the package, and the location on disk of the package.
|
||||
PackagePath string
|
||||
// The location of the package on disk.
|
||||
Source string
|
||||
|
||||
// Emitted at the top of every file.
|
||||
HeaderText []byte
|
||||
@@ -43,8 +45,9 @@ type DefaultPackage struct {
|
||||
FilterFunc func(*Context, *types.Type) bool
|
||||
}
|
||||
|
||||
func (d *DefaultPackage) Name() string { return d.PackageName }
|
||||
func (d *DefaultPackage) Path() string { return d.PackagePath }
|
||||
func (d *DefaultPackage) Name() string { return d.PackageName }
|
||||
func (d *DefaultPackage) Path() string { return d.PackagePath }
|
||||
func (d *DefaultPackage) SourcePath() string { return d.Source }
|
||||
|
||||
func (d *DefaultPackage) Filter(c *Context, t *types.Type) bool {
|
||||
if d.FilterFunc != nil {
|
||||
|
||||
12
vendor/k8s.io/gengo/generator/execute.go
generated
vendored
12
vendor/k8s.io/gengo/generator/execute.go
generated
vendored
@@ -233,11 +233,13 @@ func (c *Context) ExecutePackage(outDir string, p Package) error {
|
||||
if f == nil {
|
||||
// This is the first generator to reference this file, so start it.
|
||||
f = &File{
|
||||
Name: g.Filename(),
|
||||
FileType: fileType,
|
||||
PackageName: p.Name(),
|
||||
Header: p.Header(g.Filename()),
|
||||
Imports: map[string]struct{}{},
|
||||
Name: g.Filename(),
|
||||
FileType: fileType,
|
||||
PackageName: p.Name(),
|
||||
PackagePath: p.Path(),
|
||||
PackageSourcePath: p.SourcePath(),
|
||||
Header: p.Header(g.Filename()),
|
||||
Imports: map[string]struct{}{},
|
||||
}
|
||||
files[f.Name] = f
|
||||
} else {
|
||||
|
||||
53
vendor/k8s.io/gengo/generator/generator.go
generated
vendored
53
vendor/k8s.io/gengo/generator/generator.go
generated
vendored
@@ -31,6 +31,8 @@ type Package interface {
|
||||
Name() string
|
||||
// Path returns the package import path.
|
||||
Path() string
|
||||
// SourcePath returns the location of the package on disk.
|
||||
SourcePath() string
|
||||
|
||||
// Filter should return true if this package cares about this type.
|
||||
// Otherwise, this type will be omitted from the type ordering for
|
||||
@@ -50,14 +52,16 @@ type Package interface {
|
||||
}
|
||||
|
||||
type File struct {
|
||||
Name string
|
||||
FileType string
|
||||
PackageName string
|
||||
Header []byte
|
||||
Imports map[string]struct{}
|
||||
Vars bytes.Buffer
|
||||
Consts bytes.Buffer
|
||||
Body bytes.Buffer
|
||||
Name string
|
||||
FileType string
|
||||
PackageName string
|
||||
Header []byte
|
||||
PackagePath string
|
||||
PackageSourcePath string
|
||||
Imports map[string]struct{}
|
||||
Vars bytes.Buffer
|
||||
Consts bytes.Buffer
|
||||
Body bytes.Buffer
|
||||
}
|
||||
|
||||
type FileType interface {
|
||||
@@ -156,6 +160,12 @@ type Context struct {
|
||||
// All the types, in case you want to look up something.
|
||||
Universe types.Universe
|
||||
|
||||
// Incoming imports, i.e. packages importing the given package.
|
||||
incomingImports map[string][]string
|
||||
|
||||
// Incoming transitive imports, i.e. the transitive closure of IncomingImports
|
||||
incomingTransitiveImports map[string][]string
|
||||
|
||||
// All the user-specified packages. This is after recursive expansion.
|
||||
Inputs []string
|
||||
|
||||
@@ -203,11 +213,36 @@ func NewContext(b *parser.Builder, nameSystems namer.NameSystems, canonicalOrder
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// IncomingImports returns the incoming imports for each package. The map is lazily computed.
|
||||
func (ctxt *Context) IncomingImports() map[string][]string {
|
||||
if ctxt.incomingImports == nil {
|
||||
incoming := map[string][]string{}
|
||||
for _, pkg := range ctxt.Universe {
|
||||
for imp := range pkg.Imports {
|
||||
incoming[imp] = append(incoming[imp], pkg.Path)
|
||||
}
|
||||
}
|
||||
ctxt.incomingImports = incoming
|
||||
}
|
||||
return ctxt.incomingImports
|
||||
}
|
||||
|
||||
// TransitiveIncomingImports returns the transitive closure of the incoming imports for each package.
|
||||
// The map is lazily computed.
|
||||
func (ctxt *Context) TransitiveIncomingImports() map[string][]string {
|
||||
if ctxt.incomingTransitiveImports == nil {
|
||||
ctxt.incomingTransitiveImports = transitiveClosure(ctxt.IncomingImports())
|
||||
}
|
||||
return ctxt.incomingTransitiveImports
|
||||
}
|
||||
|
||||
// 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
|
||||
// (`which go`) will all be searched, in the normal Go fashion.
|
||||
// Deprecated. Please use AddDirectory.
|
||||
func (ctxt *Context) AddDir(path string) error {
|
||||
ctxt.incomingImports = nil
|
||||
ctxt.incomingTransitiveImports = nil
|
||||
return ctxt.builder.AddDirTo(path, &ctxt.Universe)
|
||||
}
|
||||
|
||||
@@ -215,5 +250,7 @@ func (ctxt *Context) AddDir(path string) error {
|
||||
// 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) {
|
||||
ctxt.incomingImports = nil
|
||||
ctxt.incomingTransitiveImports = nil
|
||||
return ctxt.builder.AddDirectoryTo(path, &ctxt.Universe)
|
||||
}
|
||||
|
||||
6
vendor/k8s.io/gengo/generator/import_tracker.go
generated
vendored
6
vendor/k8s.io/gengo/generator/import_tracker.go
generated
vendored
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package generator
|
||||
|
||||
import (
|
||||
"go/token"
|
||||
"strings"
|
||||
|
||||
"k8s.io/klog"
|
||||
@@ -58,6 +59,11 @@ func golangTrackerLocalName(tracker namer.ImportTracker, t types.Name) string {
|
||||
// This name collides with some other package
|
||||
continue
|
||||
}
|
||||
|
||||
// If the import name is a Go keyword, prefix with an underscore.
|
||||
if token.Lookup(name).IsKeyword() {
|
||||
name = "_" + name
|
||||
}
|
||||
return name
|
||||
}
|
||||
panic("can't find import for " + path)
|
||||
|
||||
65
vendor/k8s.io/gengo/generator/transitive_closure.go
generated
vendored
Normal file
65
vendor/k8s.io/gengo/generator/transitive_closure.go
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright 2019 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package generator
|
||||
|
||||
import "sort"
|
||||
|
||||
type edge struct {
|
||||
from string
|
||||
to string
|
||||
}
|
||||
|
||||
func transitiveClosure(in map[string][]string) map[string][]string {
|
||||
adj := make(map[edge]bool)
|
||||
imports := make(map[string]struct{})
|
||||
for from, tos := range in {
|
||||
for _, to := range tos {
|
||||
adj[edge{from, to}] = true
|
||||
imports[to] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
// Warshal's algorithm
|
||||
for k := range in {
|
||||
for i := range in {
|
||||
if !adj[edge{i, k}] {
|
||||
continue
|
||||
}
|
||||
for j := range imports {
|
||||
if adj[edge{i, j}] {
|
||||
continue
|
||||
}
|
||||
if adj[edge{k, j}] {
|
||||
adj[edge{i, j}] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out := make(map[string][]string, len(in))
|
||||
for i := range in {
|
||||
for j := range imports {
|
||||
if adj[edge{i, j}] {
|
||||
out[i] = append(out[i], j)
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(out[i])
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
3
vendor/k8s.io/gengo/namer/order.go
generated
vendored
3
vendor/k8s.io/gengo/namer/order.go
generated
vendored
@@ -43,6 +43,9 @@ func (o *Orderer) OrderUniverse(u types.Universe) []*types.Type {
|
||||
for _, v := range p.Variables {
|
||||
list.types = append(list.types, v)
|
||||
}
|
||||
for _, v := range p.Constants {
|
||||
list.types = append(list.types, v)
|
||||
}
|
||||
}
|
||||
sort.Sort(list)
|
||||
return list.types
|
||||
|
||||
49
vendor/k8s.io/gengo/parser/parse.go
generated
vendored
49
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
|
||||
@@ -224,12 +227,16 @@ func (b *Builder) AddDirRecursive(dir string) error {
|
||||
klog.Warningf("Ignoring directory %v: %v", dir, err)
|
||||
}
|
||||
|
||||
// filepath.Walk includes the root dir, but we already did that, so we'll
|
||||
// remove that prefix and rebuild a package import path.
|
||||
prefix := b.buildPackages[dir].Dir
|
||||
// filepath.Walk does not follow symlinks. We therefore evaluate symlinks and use that with
|
||||
// filepath.Walk.
|
||||
realPath, err := filepath.EvalSymlinks(b.buildPackages[dir].Dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fn := func(filePath string, info os.FileInfo, err error) error {
|
||||
if info != nil && info.IsDir() {
|
||||
rel := filepath.ToSlash(strings.TrimPrefix(filePath, prefix))
|
||||
rel := filepath.ToSlash(strings.TrimPrefix(filePath, realPath))
|
||||
if rel != "" {
|
||||
// Make a pkg path.
|
||||
pkg := path.Join(string(canonicalizeImportPath(b.buildPackages[dir].ImportPath)), rel)
|
||||
@@ -242,7 +249,7 @@ func (b *Builder) AddDirRecursive(dir string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err := filepath.Walk(b.buildPackages[dir].Dir, fn); err != nil {
|
||||
if err := filepath.Walk(realPath, fn); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -304,11 +311,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)
|
||||
@@ -535,6 +548,10 @@ func (b *Builder) findTypesIn(pkgPath importPathString, u *types.Universe) error
|
||||
if ok && !tv.IsField() {
|
||||
b.addVariable(*u, nil, tv)
|
||||
}
|
||||
tconst, ok := obj.(*tc.Const)
|
||||
if ok {
|
||||
b.addConstant(*u, nil, tconst)
|
||||
}
|
||||
}
|
||||
|
||||
importedPkgs := []string{}
|
||||
@@ -765,7 +782,10 @@ func (b *Builder) walkType(u types.Universe, useName *types.Name, in tc.Type) *t
|
||||
if out.Methods == nil {
|
||||
out.Methods = map[string]*types.Type{}
|
||||
}
|
||||
out.Methods[t.Method(i).Name()] = b.walkType(u, nil, t.Method(i).Type())
|
||||
method := t.Method(i)
|
||||
mt := b.walkType(u, nil, method.Type())
|
||||
mt.CommentLines = splitLines(b.priorCommentLines(method.Pos(), 1).Text())
|
||||
out.Methods[method.Name()] = mt
|
||||
}
|
||||
}
|
||||
return out
|
||||
@@ -802,6 +822,17 @@ func (b *Builder) addVariable(u types.Universe, useName *types.Name, in *tc.Var)
|
||||
return out
|
||||
}
|
||||
|
||||
func (b *Builder) addConstant(u types.Universe, useName *types.Name, in *tc.Const) *types.Type {
|
||||
name := tcVarNameToName(in.String())
|
||||
if useName != nil {
|
||||
name = *useName
|
||||
}
|
||||
out := u.Constant(name)
|
||||
out.Kind = types.DeclarationOf
|
||||
out.Underlying = b.walkType(u, nil, in.Type())
|
||||
return out
|
||||
}
|
||||
|
||||
// canonicalizeImportPath takes an import path and returns the actual package.
|
||||
// It doesn't support nested vendoring.
|
||||
func canonicalizeImportPath(importPath string) importPathString {
|
||||
|
||||
27
vendor/k8s.io/gengo/types/types.go
generated
vendored
27
vendor/k8s.io/gengo/types/types.go
generated
vendored
@@ -135,6 +135,10 @@ type Package struct {
|
||||
// package name).
|
||||
Variables map[string]*Type
|
||||
|
||||
// Global constants within this package, indexed by their name (*not* including
|
||||
// package name).
|
||||
Constants map[string]*Type
|
||||
|
||||
// Packages imported by this package, indexed by (canonicalized)
|
||||
// package path.
|
||||
Imports map[string]*Package
|
||||
@@ -193,6 +197,20 @@ func (p *Package) Variable(varName string) *Type {
|
||||
return t
|
||||
}
|
||||
|
||||
// Constant gets the given constant Type in this Package. If the constant is
|
||||
// not already defined, this will add it. If a constant is added, it's the caller's
|
||||
// responsibility to finish construction of the constant by setting Underlying
|
||||
// to the correct type.
|
||||
func (p *Package) Constant(constName string) *Type {
|
||||
if t, ok := p.Constants[constName]; ok {
|
||||
return t
|
||||
}
|
||||
t := &Type{Name: Name{Package: p.Path, Name: constName}}
|
||||
t.Kind = DeclarationOf
|
||||
p.Constants[constName] = t
|
||||
return t
|
||||
}
|
||||
|
||||
// HasImport returns true if p imports packageName. Package names include the
|
||||
// package directory.
|
||||
func (p *Package) HasImport(packageName string) bool {
|
||||
@@ -229,6 +247,14 @@ func (u Universe) Variable(n Name) *Type {
|
||||
return u.Package(n.Package).Variable(n.Name)
|
||||
}
|
||||
|
||||
// Constant returns the canonical constant for the given fully-qualified name.
|
||||
// If a non-existing constant is requested, this will create (a marker for) it.
|
||||
// If a marker is created, it's the caller's responsibility to finish
|
||||
// construction of the constant by setting Underlying to the correct type.
|
||||
func (u Universe) Constant(n Name) *Type {
|
||||
return u.Package(n.Package).Constant(n.Name)
|
||||
}
|
||||
|
||||
// AddImports registers import lines for packageName. May be called multiple times.
|
||||
// You are responsible for canonicalizing all package paths.
|
||||
func (u Universe) AddImports(packagePath string, importPaths ...string) {
|
||||
@@ -251,6 +277,7 @@ func (u Universe) Package(packagePath string) *Package {
|
||||
Types: map[string]*Type{},
|
||||
Functions: map[string]*Type{},
|
||||
Variables: map[string]*Type{},
|
||||
Constants: map[string]*Type{},
|
||||
Imports: map[string]*Package{},
|
||||
}
|
||||
u[packagePath] = p
|
||||
|
||||
Reference in New Issue
Block a user