Bumping k8s dependencies to 1.13

This commit is contained in:
Cheng Xing
2018-11-16 14:08:25 -08:00
parent 305407125c
commit b4c0b68ec7
8002 changed files with 884099 additions and 276228 deletions

View File

@@ -132,7 +132,7 @@ func (c *Config) AddIndirectQuery(v ssa.Value) {
// // 'type T struct { F *int }', the following query will access the field F.
// c.AddExtendedQuery(v, "x[1][0].F")
func (c *Config) AddExtendedQuery(v ssa.Value, query string) (*Pointer, error) {
ops, _, err := parseExtendedQuery(v.Type().Underlying(), query)
ops, _, err := parseExtendedQuery(v.Type(), query)
if err != nil {
return nil, fmt.Errorf("invalid query %q: %s", query, err)
}

View File

@@ -67,7 +67,7 @@ func destructuringOps(typ types.Type, expr ast.Expr) ([]interface{}, types.Type,
}
var structT *types.Struct
switch typ := typ.(type) {
switch typ := typ.Underlying().(type) {
case *types.Pointer:
var ok bool
structT, ok = typ.Elem().Underlying().(*types.Struct)
@@ -107,7 +107,7 @@ func destructuringOps(typ types.Type, expr ast.Expr) ([]interface{}, types.Type,
if err != nil {
return nil, nil, err
}
switch typ := typ.(type) {
switch typ := typ.Underlying().(type) {
case *types.Array:
out = append(out, "arrayelem")
return out, typ.Elem().Underlying(), nil

View File

@@ -1,17 +1,20 @@
package pointer
import (
"go/ast"
"go/parser"
"go/token"
"go/types"
"reflect"
"testing"
"golang.org/x/tools/go/loader"
)
func TestParseExtendedQuery(t *testing.T) {
const myprog = `
package pkg
import "reflect"
type T []*int
var V1 *int
var V2 **int
var V3 []*int
@@ -19,6 +22,8 @@ var V4 chan []*int
var V5 struct {F1, F2 chan *int}
var V6 [1]chan *int
var V7 int
var V8 T
var V9 reflect.Value
`
tests := []struct {
in string
@@ -27,8 +32,10 @@ var V7 int
valid bool
}{
{`x`, []interface{}{"x"}, "V1", true},
{`x`, []interface{}{"x"}, "V9", true},
{`*x`, []interface{}{"x", "load"}, "V2", true},
{`x[0]`, []interface{}{"x", "sliceelem"}, "V3", true},
{`x[0]`, []interface{}{"x", "sliceelem"}, "V8", true},
{`<-x`, []interface{}{"x", "recv"}, "V4", true},
{`(<-x)[0]`, []interface{}{"x", "recv", "sliceelem"}, "V4", true},
{`<-x.F2`, []interface{}{"x", "field", 1, "recv"}, "V5", true},
@@ -40,19 +47,20 @@ var V7 int
{`close(x)`, nil, "V1", false},
}
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "file.go", myprog, 0)
var conf loader.Config
f, err := conf.ParseFile("file.go", myprog)
if err != nil {
t.Fatal(err)
}
cfg := &types.Config{}
pkg, err := cfg.Check("main", fset, []*ast.File{f}, nil)
conf.CreateFromFiles("main", f)
lprog, err := conf.Load()
if err != nil {
t.Fatal(err)
}
pkg := lprog.Created[0].Pkg
for _, test := range tests {
typ := pkg.Scope().Lookup(test.v).Type().Underlying()
typ := pkg.Scope().Lookup(test.v).Type()
ops, _, err := parseExtendedQuery(typ, test.in)
if test.valid && err != nil {
t.Errorf("parseExtendedQuery(%q) = %s, expected no error", test.in, err)

View File

@@ -30,7 +30,7 @@ package pointer
import (
"fmt"
exact "go/constant"
"go/constant"
"go/types"
"reflect"
@@ -1024,7 +1024,7 @@ func ext۰reflect۰ChanOf(a *analysis, cgn *cgnode) {
var dir reflect.ChanDir // unknown
if site := cgn.callersite; site != nil {
if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok {
v, _ := exact.Int64Val(c.Value)
v, _ := constant.Int64Val(c.Value)
if 0 <= v && v <= int64(reflect.BothDir) {
dir = reflect.ChanDir(v)
}
@@ -1668,7 +1668,7 @@ func ext۰reflect۰rtype۰FieldByName(a *analysis, cgn *cgnode) {
var name string
if site := cgn.callersite; site != nil {
if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok {
name = exact.StringVal(c.Value)
name = constant.StringVal(c.Value)
}
}
@@ -1751,7 +1751,7 @@ func ext۰reflect۰rtype۰InOut(a *analysis, cgn *cgnode, out bool) {
index := -1
if site := cgn.callersite; site != nil {
if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok {
v, _ := exact.Int64Val(c.Value)
v, _ := constant.Int64Val(c.Value)
index = int(v)
}
}
@@ -1910,7 +1910,7 @@ func ext۰reflect۰rtype۰MethodByName(a *analysis, cgn *cgnode) {
var name string
if site := cgn.callersite; site != nil {
if c, ok := site.instr.Common().Args[0].(*ssa.Const); ok {
name = exact.StringVal(c.Value)
name = constant.StringVal(c.Value)
}
}