Update kubernetes projects version in vendor to 1.12.1

This commit is contained in:
robbiezhang
2018-10-06 00:53:39 +00:00
parent 26d8fbcde8
commit 5a00c27b9c
678 changed files with 61266 additions and 17514 deletions

View File

@@ -6,4 +6,4 @@ import "unsafe"
func resolveTypeOff(rtype unsafe.Pointer, off int32) unsafe.Pointer {
return nil
}
}

View File

@@ -1,9 +1,9 @@
package reflect2
import (
"github.com/modern-go/concurrent"
"reflect"
"unsafe"
"github.com/modern-go/concurrent"
)
type Type interface {
@@ -136,7 +136,7 @@ type frozenConfig struct {
func (cfg Config) Froze() *frozenConfig {
return &frozenConfig{
useSafeImplementation: cfg.UseSafeImplementation,
cache: concurrent.NewMap(),
cache: concurrent.NewMap(),
}
}
@@ -150,6 +150,9 @@ func (cfg *frozenConfig) TypeOf(obj interface{}) Type {
}
func (cfg *frozenConfig) Type2(type1 reflect.Type) Type {
if type1 == nil {
return nil
}
cacheKey := uintptr(unpackEFace(type1).data)
typeObj, found := cfg.cache.Load(cacheKey)
if found {
@@ -213,6 +216,9 @@ func TypeOfPtr(obj interface{}) PtrType {
}
func Type2(type1 reflect.Type) Type {
if type1 == nil {
return nil
}
return ConfigUnsafe.Type2(type1)
}
@@ -279,4 +285,14 @@ func likePtrType(typ reflect.Type) bool {
func NoEscape(p unsafe.Pointer) unsafe.Pointer {
x := uintptr(p)
return unsafe.Pointer(x ^ 0)
}
}
func UnsafeCastString(str string) []byte {
stringHeader := (*reflect.StringHeader)(unsafe.Pointer(&str))
sliceHeader := &reflect.SliceHeader{
Data: stringHeader.Data,
Cap: stringHeader.Len,
Len: stringHeader.Len,
}
return *(*[]byte)(unsafe.Pointer(sliceHeader))
}

View File

@@ -11,20 +11,20 @@ func DefaultTypeOfKind(kind reflect.Kind) Type {
}
var kindTypes = map[reflect.Kind]Type{
reflect.Bool: TypeOf(true),
reflect.Uint8: TypeOf(uint8(0)),
reflect.Int8: TypeOf(int8(0)),
reflect.Uint16: TypeOf(uint16(0)),
reflect.Int16: TypeOf(int16(0)),
reflect.Uint32: TypeOf(uint32(0)),
reflect.Int32: TypeOf(int32(0)),
reflect.Uint64: TypeOf(uint64(0)),
reflect.Int64: TypeOf(int64(0)),
reflect.Uint: TypeOf(uint(0)),
reflect.Int: TypeOf(int(0)),
reflect.Float32: TypeOf(float32(0)),
reflect.Float64: TypeOf(float64(0)),
reflect.Uintptr: TypeOf(uintptr(0)),
reflect.String: TypeOf(""),
reflect.Bool: TypeOf(true),
reflect.Uint8: TypeOf(uint8(0)),
reflect.Int8: TypeOf(int8(0)),
reflect.Uint16: TypeOf(uint16(0)),
reflect.Int16: TypeOf(int16(0)),
reflect.Uint32: TypeOf(uint32(0)),
reflect.Int32: TypeOf(int32(0)),
reflect.Uint64: TypeOf(uint64(0)),
reflect.Int64: TypeOf(int64(0)),
reflect.Uint: TypeOf(uint(0)),
reflect.Int: TypeOf(int(0)),
reflect.Float32: TypeOf(float32(0)),
reflect.Float64: TypeOf(float64(0)),
reflect.Uintptr: TypeOf(uintptr(0)),
reflect.String: TypeOf(""),
reflect.UnsafePointer: TypeOf(unsafe.Pointer(nil)),
}
}

View File

@@ -55,4 +55,4 @@ func (field *safeField) Get(obj interface{}) interface{} {
func (field *safeField) UnsafeGet(obj unsafe.Pointer) unsafe.Pointer {
panic("does not support unsafe operation")
}
}

View File

@@ -76,8 +76,8 @@ func (type2 *safeMapType) UnsafeIterate(obj unsafe.Pointer) MapIterator {
}
type safeMapIterator struct {
i int
m reflect.Value
i int
m reflect.Value
keys []reflect.Value
}
@@ -98,4 +98,4 @@ func (iter *safeMapIterator) Next() (interface{}, interface{}) {
func (iter *safeMapIterator) UnsafeNext() (unsafe.Pointer, unsafe.Pointer) {
panic("does not support unsafe operation")
}
}

View File

@@ -89,4 +89,4 @@ func (type2 *safeSliceType) Cap(obj interface{}) int {
func (type2 *safeSliceType) UnsafeCap(ptr unsafe.Pointer) int {
panic("does not support unsafe operation")
}
}

View File

@@ -10,4 +10,20 @@ func (type2 *safeStructType) FieldByName(name string) StructField {
panic("field " + name + " not found")
}
return &safeField{StructField: field}
}
}
func (type2 *safeStructType) Field(i int) StructField {
return &safeField{StructField: type2.Type.Field(i)}
}
func (type2 *safeStructType) FieldByIndex(index []int) StructField {
return &safeField{StructField: type2.Type.FieldByIndex(index)}
}
func (type2 *safeStructType) FieldByNameFunc(match func(string) bool) StructField {
field, found := type2.Type.FieldByNameFunc(match)
if !found {
panic("field match condition not found in " + type2.Type.String())
}
return &safeField{StructField: field}
}

View File

@@ -75,4 +75,4 @@ func (type2 *safeType) UnsafeSet(ptr unsafe.Pointer, val unsafe.Pointer) {
func (type2 *safeType) AssignableTo(anotherType Type) bool {
return type2.Type1().AssignableTo(anotherType.Type1())
}
}

View File

@@ -1,10 +1,10 @@
package reflect2
import (
"unsafe"
"reflect"
"runtime"
"strings"
"unsafe"
)
// typelinks1 for 1.5 ~ 1.6
@@ -16,6 +16,7 @@ func typelinks1() [][]unsafe.Pointer
func typelinks2() (sections []unsafe.Pointer, offset [][]int32)
var types = map[string]reflect.Type{}
var packages = map[string]map[string]reflect.Type{}
func init() {
ver := runtime.Version()
@@ -36,11 +37,25 @@ func loadGo15Types() {
(*emptyInterface)(unsafe.Pointer(&obj)).word = typePtr
typ := obj.(reflect.Type)
if typ.Kind() == reflect.Ptr && typ.Elem().Kind() == reflect.Struct {
types[typ.Elem().String()] = typ.Elem()
loadedType := typ.Elem()
pkgTypes := packages[loadedType.PkgPath()]
if pkgTypes == nil {
pkgTypes = map[string]reflect.Type{}
packages[loadedType.PkgPath()] = pkgTypes
}
types[loadedType.String()] = loadedType
pkgTypes[loadedType.Name()] = loadedType
}
if typ.Kind() == reflect.Slice && typ.Elem().Kind() == reflect.Ptr &&
typ.Elem().Elem().Kind() == reflect.Struct {
types[typ.Elem().Elem().String()] = typ.Elem().Elem()
loadedType := typ.Elem().Elem()
pkgTypes := packages[loadedType.PkgPath()]
if pkgTypes == nil {
pkgTypes = map[string]reflect.Type{}
packages[loadedType.PkgPath()] = pkgTypes
}
types[loadedType.String()] = loadedType
pkgTypes[loadedType.Name()] = loadedType
}
}
}
@@ -55,7 +70,14 @@ func loadGo17Types() {
(*emptyInterface)(unsafe.Pointer(&obj)).word = resolveTypeOff(unsafe.Pointer(rodata), off)
typ := obj.(reflect.Type)
if typ.Kind() == reflect.Ptr && typ.Elem().Kind() == reflect.Struct {
types[typ.Elem().String()] = typ.Elem()
loadedType := typ.Elem()
pkgTypes := packages[loadedType.PkgPath()]
if pkgTypes == nil {
pkgTypes = map[string]reflect.Type{}
packages[loadedType.PkgPath()] = pkgTypes
}
types[loadedType.String()] = loadedType
pkgTypes[loadedType.Name()] = loadedType
}
}
}
@@ -70,3 +92,12 @@ type emptyInterface struct {
func TypeByName(typeName string) Type {
return Type2(types[typeName])
}
// TypeByPackageName return the type by its package and name
func TypeByPackageName(pkgPath string, name string) Type {
pkgTypes := packages[pkgPath]
if pkgTypes == nil {
return nil
}
return Type2(pkgTypes[name])
}

View File

@@ -1,8 +1,8 @@
package reflect2
import (
"unsafe"
"reflect"
"unsafe"
)
type UnsafeArrayType struct {

View File

@@ -1,8 +1,8 @@
package reflect2
import (
"unsafe"
"reflect"
"unsafe"
)
type eface struct {
@@ -56,4 +56,4 @@ func (type2 *UnsafeEFaceType) Indirect(obj interface{}) interface{} {
func (type2 *UnsafeEFaceType) UnsafeIndirect(ptr unsafe.Pointer) interface{} {
return *(*interface{})(ptr)
}
}

View File

@@ -1,8 +1,8 @@
package reflect2
import (
"unsafe"
"reflect"
"unsafe"
)
type iface struct {
@@ -61,4 +61,4 @@ func (type2 *UnsafeIFaceType) UnsafeIsNil(ptr unsafe.Pointer) bool {
return true
}
return false
}
}

View File

@@ -67,4 +67,4 @@ func add(p unsafe.Pointer, x uintptr, whySafe string) unsafe.Pointer {
// the benefit is to surface this assumption at the call site.)
func arrayAt(p unsafe.Pointer, i int, eltSize uintptr, whySafe string) unsafe.Pointer {
return add(p, uintptr(i)*eltSize, "i < len")
}
}

View File

@@ -1,8 +1,8 @@
package reflect2
import (
"unsafe"
"reflect"
"unsafe"
)
type UnsafePtrType struct {

View File

@@ -1,8 +1,8 @@
package reflect2
import (
"unsafe"
"reflect"
"unsafe"
)
// sliceHeader is a safe version of SliceHeader used within this package.

View File

@@ -56,4 +56,4 @@ func (type2 *UnsafeStructType) FieldByNameFunc(match func(string) bool) StructFi
panic("field match condition not found in " + type2.Type.String())
}
return newUnsafeStructField(type2, structField)
}
}

View File

@@ -1,8 +1,8 @@
package reflect2
import (
"unsafe"
"reflect"
"unsafe"
)
type unsafeType struct {
@@ -15,7 +15,7 @@ func newUnsafeType(cfg *frozenConfig, type1 reflect.Type) *unsafeType {
return &unsafeType{
safeType: safeType{
Type: type1,
cfg: cfg,
cfg: cfg,
},
rtype: unpackEFace(type1).data,
ptrRType: unpackEFace(reflect.PtrTo(type1)).data,