From 2f1efbe8d5cd65c74c17406efa8fa3db247d0cb7 Mon Sep 17 00:00:00 2001 From: Xabier Larrakoetxea Date: Mon, 2 Jul 2018 14:36:01 +0200 Subject: [PATCH 1/2] Set correct dependency for github.com/json-iterator/go Signed-off-by: Xabier Larrakoetxea --- Gopkg.lock | 9 +-- Gopkg.toml | 7 -- vendor/github.com/json-iterator/go/Gopkg.lock | 12 +--- vendor/github.com/json-iterator/go/Gopkg.toml | 2 +- .../github.com/modern-go/reflect2/.gitignore | 1 + .../github.com/modern-go/reflect2/.travis.yml | 15 ++++ .../github.com/modern-go/reflect2/Gopkg.toml | 2 +- .../github.com/modern-go/reflect2/README.md | 69 +++++++++++++++++++ .../modern-go/reflect2/go_below_17.go | 2 +- .../github.com/modern-go/reflect2/reflect2.go | 22 +++++- .../modern-go/reflect2/reflect2_kind.go | 32 ++++----- .../modern-go/reflect2/safe_field.go | 2 +- .../github.com/modern-go/reflect2/safe_map.go | 6 +- .../modern-go/reflect2/safe_slice.go | 2 +- .../modern-go/reflect2/safe_struct.go | 18 ++++- .../modern-go/reflect2/safe_type.go | 2 +- vendor/github.com/modern-go/reflect2/test.sh | 12 ++++ .../github.com/modern-go/reflect2/type_map.go | 39 +++++++++-- .../modern-go/reflect2/unsafe_array.go | 2 +- .../modern-go/reflect2/unsafe_eface.go | 4 +- .../modern-go/reflect2/unsafe_iface.go | 4 +- .../modern-go/reflect2/unsafe_link.go | 2 +- .../modern-go/reflect2/unsafe_ptr.go | 2 +- .../modern-go/reflect2/unsafe_slice.go | 2 +- .../modern-go/reflect2/unsafe_struct.go | 2 +- .../modern-go/reflect2/unsafe_type.go | 4 +- 26 files changed, 212 insertions(+), 64 deletions(-) create mode 100644 vendor/github.com/modern-go/reflect2/.travis.yml create mode 100755 vendor/github.com/modern-go/reflect2/test.sh diff --git a/Gopkg.lock b/Gopkg.lock index 1695f839..57d9aee3 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -104,7 +104,8 @@ [[projects]] name = "github.com/json-iterator/go" packages = ["."] - revision = "f2b4162afba35581b6d4a50d3b8f34e33c144682" + revision = "ab8a2e0c74be9d3be70b3184d9acc634935ded82" + version = "1.1.4" [[projects]] name = "github.com/matttproud/golang_protobuf_extensions" @@ -121,8 +122,8 @@ [[projects]] name = "github.com/modern-go/reflect2" packages = ["."] - revision = "1df9eeb2bb81f327b96228865c5687bc2194af3f" - version = "1.0.0" + revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd" + version = "1.0.1" [[projects]] name = "github.com/opentracing/opentracing-go" @@ -545,6 +546,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "bab7060c393c1528303de8ea5f2f50ad857260b6d8171bd25769aede1d95133c" + inputs-digest = "61c44b2a4a927af698c410710deafedea43157a2fdc3f03b72c5a49754c7a1ab" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 3be12503..53df3332 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -40,13 +40,6 @@ name = "k8s.io/kubernetes" version = "v1.10.5" -# Fixes pinning versions for other dependencies with not correct dependency settings. - -# Fix for "k8s.io/apimachinery" -[[override]] - name = "github.com/json-iterator/go" - revision = "f2b4162afba35581b6d4a50d3b8f34e33c144682" - [prune] go-tests = true unused-packages = true \ No newline at end of file diff --git a/vendor/github.com/json-iterator/go/Gopkg.lock b/vendor/github.com/json-iterator/go/Gopkg.lock index 3719afe8..c8a9fbb3 100644 --- a/vendor/github.com/json-iterator/go/Gopkg.lock +++ b/vendor/github.com/json-iterator/go/Gopkg.lock @@ -1,12 +1,6 @@ # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. -[[projects]] - name = "github.com/json-iterator/go" - packages = ["."] - revision = "ca39e5af3ece67bbcda3d0f4f56a8e24d9f2dad4" - version = "1.1.3" - [[projects]] name = "github.com/modern-go/concurrent" packages = ["."] @@ -16,12 +10,12 @@ [[projects]] name = "github.com/modern-go/reflect2" packages = ["."] - revision = "1df9eeb2bb81f327b96228865c5687bc2194af3f" - version = "1.0.0" + revision = "4b7aa43c6742a2c18fdef89dd197aaae7dac7ccd" + version = "1.0.1" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "56a0b9e9e61d2bc8af5e1b68537401b7f4d60805eda3d107058f3171aa5cf793" + inputs-digest = "ea54a775e5a354cb015502d2e7aa4b74230fc77e894f34a838b268c25ec8eeb8" solver-name = "gps-cdcl" solver-version = 1 diff --git a/vendor/github.com/json-iterator/go/Gopkg.toml b/vendor/github.com/json-iterator/go/Gopkg.toml index 5801ffa1..313a0f88 100644 --- a/vendor/github.com/json-iterator/go/Gopkg.toml +++ b/vendor/github.com/json-iterator/go/Gopkg.toml @@ -23,4 +23,4 @@ ignored = ["github.com/davecgh/go-spew*","github.com/google/gofuzz*","github.com [[constraint]] name = "github.com/modern-go/reflect2" - version = "1.0.0" + version = "1.0.1" diff --git a/vendor/github.com/modern-go/reflect2/.gitignore b/vendor/github.com/modern-go/reflect2/.gitignore index 61ead866..7b26c946 100644 --- a/vendor/github.com/modern-go/reflect2/.gitignore +++ b/vendor/github.com/modern-go/reflect2/.gitignore @@ -1 +1,2 @@ /vendor +/coverage.txt diff --git a/vendor/github.com/modern-go/reflect2/.travis.yml b/vendor/github.com/modern-go/reflect2/.travis.yml new file mode 100644 index 00000000..fbb43744 --- /dev/null +++ b/vendor/github.com/modern-go/reflect2/.travis.yml @@ -0,0 +1,15 @@ +language: go + +go: + - 1.8.x + - 1.x + +before_install: + - go get -t -v ./... + - go get -t -v github.com/modern-go/reflect2-tests/... + +script: + - ./test.sh + +after_success: + - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/github.com/modern-go/reflect2/Gopkg.toml b/vendor/github.com/modern-go/reflect2/Gopkg.toml index 3593fd04..2f4f4dbd 100644 --- a/vendor/github.com/modern-go/reflect2/Gopkg.toml +++ b/vendor/github.com/modern-go/reflect2/Gopkg.toml @@ -24,7 +24,7 @@ # go-tests = true # unused-packages = true -ignored = ["github.com/modern-go/test","github.com/modern-go/test/must","github.com/modern-go/test/should"] +ignored = [] [[constraint]] name = "github.com/modern-go/concurrent" diff --git a/vendor/github.com/modern-go/reflect2/README.md b/vendor/github.com/modern-go/reflect2/README.md index 6b429efd..6f968aab 100644 --- a/vendor/github.com/modern-go/reflect2/README.md +++ b/vendor/github.com/modern-go/reflect2/README.md @@ -1,2 +1,71 @@ # reflect2 + +[![Sourcegraph](https://sourcegraph.com/github.com/modern-go/reflect2/-/badge.svg)](https://sourcegraph.com/github.com/modern-go/reflect2?badge) +[![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/modern-go/reflect2) +[![Build Status](https://travis-ci.org/modern-go/reflect2.svg?branch=master)](https://travis-ci.org/modern-go/reflect2) +[![codecov](https://codecov.io/gh/modern-go/reflect2/branch/master/graph/badge.svg)](https://codecov.io/gh/modern-go/reflect2) +[![rcard](https://goreportcard.com/badge/github.com/modern-go/reflect2)](https://goreportcard.com/report/github.com/modern-go/reflect2) +[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://raw.githubusercontent.com/modern-go/reflect2/master/LICENSE) + reflect api that avoids runtime reflect.Value cost + +* reflect get/set interface{}, with type checking +* reflect get/set unsafe.Pointer, without type checking +* `reflect2.TypeByName` works like `Class.forName` found in java + +[json-iterator](https://github.com/json-iterator/go) use this package to save runtime dispatching cost. +This package is designed for low level libraries to optimize reflection performance. +General application should still use reflect standard library. + +# reflect2.TypeByName + +```go +// given package is github.com/your/awesome-package +type MyStruct struct { + // ... +} + +// will return the type +reflect2.TypeByName("awesome-package.MyStruct") +// however, if the type has not been used +// it will be eliminated by compiler, so we can not get it in runtime +``` + +# reflect2 get/set interface{} + +```go +valType := reflect2.TypeOf(1) +i := 1 +j := 10 +valType.Set(&i, &j) +// i will be 10 +``` + +to get set `type`, always use its pointer `*type` + +# reflect2 get/set unsafe.Pointer + +```go +valType := reflect2.TypeOf(1) +i := 1 +j := 10 +valType.UnsafeSet(unsafe.Pointer(&i), unsafe.Pointer(&j)) +// i will be 10 +``` + +to get set `type`, always use its pointer `*type` + +# benchmark + +Benchmark is not necessary for this package. It does nothing actually. +As it is just a thin wrapper to make go runtime public. +Both `reflect2` and `reflect` call same function +provided by `runtime` package exposed by go language. + +# unsafe safety + +Instead of casting `[]byte` to `sliceHeader` in your application using unsafe. +We can use reflect2 instead. This way, if `sliceHeader` changes in the future, +only reflect2 need to be upgraded. + +reflect2 tries its best to keep the implementation same as reflect (by testing). \ No newline at end of file diff --git a/vendor/github.com/modern-go/reflect2/go_below_17.go b/vendor/github.com/modern-go/reflect2/go_below_17.go index 81142317..65a93c88 100644 --- a/vendor/github.com/modern-go/reflect2/go_below_17.go +++ b/vendor/github.com/modern-go/reflect2/go_below_17.go @@ -6,4 +6,4 @@ import "unsafe" func resolveTypeOff(rtype unsafe.Pointer, off int32) unsafe.Pointer { return nil -} \ No newline at end of file +} diff --git a/vendor/github.com/modern-go/reflect2/reflect2.go b/vendor/github.com/modern-go/reflect2/reflect2.go index feabb610..63b49c79 100644 --- a/vendor/github.com/modern-go/reflect2/reflect2.go +++ b/vendor/github.com/modern-go/reflect2/reflect2.go @@ -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) -} \ No newline at end of file +} + +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)) +} diff --git a/vendor/github.com/modern-go/reflect2/reflect2_kind.go b/vendor/github.com/modern-go/reflect2/reflect2_kind.go index f13cbe13..62f299e4 100644 --- a/vendor/github.com/modern-go/reflect2/reflect2_kind.go +++ b/vendor/github.com/modern-go/reflect2/reflect2_kind.go @@ -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)), -} \ No newline at end of file +} diff --git a/vendor/github.com/modern-go/reflect2/safe_field.go b/vendor/github.com/modern-go/reflect2/safe_field.go index f68de456..d4ba1f4f 100644 --- a/vendor/github.com/modern-go/reflect2/safe_field.go +++ b/vendor/github.com/modern-go/reflect2/safe_field.go @@ -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") -} \ No newline at end of file +} diff --git a/vendor/github.com/modern-go/reflect2/safe_map.go b/vendor/github.com/modern-go/reflect2/safe_map.go index 6a1ba23d..88362205 100644 --- a/vendor/github.com/modern-go/reflect2/safe_map.go +++ b/vendor/github.com/modern-go/reflect2/safe_map.go @@ -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") -} \ No newline at end of file +} diff --git a/vendor/github.com/modern-go/reflect2/safe_slice.go b/vendor/github.com/modern-go/reflect2/safe_slice.go index 7e348c1a..bcce6fd2 100644 --- a/vendor/github.com/modern-go/reflect2/safe_slice.go +++ b/vendor/github.com/modern-go/reflect2/safe_slice.go @@ -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") -} \ No newline at end of file +} diff --git a/vendor/github.com/modern-go/reflect2/safe_struct.go b/vendor/github.com/modern-go/reflect2/safe_struct.go index d8eb4534..e5fb9b31 100644 --- a/vendor/github.com/modern-go/reflect2/safe_struct.go +++ b/vendor/github.com/modern-go/reflect2/safe_struct.go @@ -10,4 +10,20 @@ func (type2 *safeStructType) FieldByName(name string) StructField { panic("field " + name + " not found") } return &safeField{StructField: field} -} \ No newline at end of file +} + +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} +} diff --git a/vendor/github.com/modern-go/reflect2/safe_type.go b/vendor/github.com/modern-go/reflect2/safe_type.go index 3cd6331a..ee4e7bb6 100644 --- a/vendor/github.com/modern-go/reflect2/safe_type.go +++ b/vendor/github.com/modern-go/reflect2/safe_type.go @@ -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()) -} \ No newline at end of file +} diff --git a/vendor/github.com/modern-go/reflect2/test.sh b/vendor/github.com/modern-go/reflect2/test.sh new file mode 100755 index 00000000..3d2b9768 --- /dev/null +++ b/vendor/github.com/modern-go/reflect2/test.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e +echo "" > coverage.txt + +for d in $(go list github.com/modern-go/reflect2-tests/... | grep -v vendor); do + go test -coverprofile=profile.out -coverpkg=github.com/modern-go/reflect2 $d + if [ -f profile.out ]; then + cat profile.out >> coverage.txt + rm profile.out + fi +done diff --git a/vendor/github.com/modern-go/reflect2/type_map.go b/vendor/github.com/modern-go/reflect2/type_map.go index 122141f8..6d489112 100644 --- a/vendor/github.com/modern-go/reflect2/type_map.go +++ b/vendor/github.com/modern-go/reflect2/type_map.go @@ -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]) +} diff --git a/vendor/github.com/modern-go/reflect2/unsafe_array.go b/vendor/github.com/modern-go/reflect2/unsafe_array.go index 924b0262..76cbdba6 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_array.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_array.go @@ -1,8 +1,8 @@ package reflect2 import ( - "unsafe" "reflect" + "unsafe" ) type UnsafeArrayType struct { diff --git a/vendor/github.com/modern-go/reflect2/unsafe_eface.go b/vendor/github.com/modern-go/reflect2/unsafe_eface.go index 446f4206..805010f3 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_eface.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_eface.go @@ -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) -} \ No newline at end of file +} diff --git a/vendor/github.com/modern-go/reflect2/unsafe_iface.go b/vendor/github.com/modern-go/reflect2/unsafe_iface.go index 8f451ca3..b6019553 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_iface.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_iface.go @@ -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 -} \ No newline at end of file +} diff --git a/vendor/github.com/modern-go/reflect2/unsafe_link.go b/vendor/github.com/modern-go/reflect2/unsafe_link.go index a25a5f4d..57229c8d 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_link.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_link.go @@ -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") -} \ No newline at end of file +} diff --git a/vendor/github.com/modern-go/reflect2/unsafe_ptr.go b/vendor/github.com/modern-go/reflect2/unsafe_ptr.go index 843724d8..8e5ec9cf 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_ptr.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_ptr.go @@ -1,8 +1,8 @@ package reflect2 import ( - "unsafe" "reflect" + "unsafe" ) type UnsafePtrType struct { diff --git a/vendor/github.com/modern-go/reflect2/unsafe_slice.go b/vendor/github.com/modern-go/reflect2/unsafe_slice.go index 5ce85afb..1c6d876c 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_slice.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_slice.go @@ -1,8 +1,8 @@ package reflect2 import ( - "unsafe" "reflect" + "unsafe" ) // sliceHeader is a safe version of SliceHeader used within this package. diff --git a/vendor/github.com/modern-go/reflect2/unsafe_struct.go b/vendor/github.com/modern-go/reflect2/unsafe_struct.go index f91ef179..804d9166 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_struct.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_struct.go @@ -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) -} \ No newline at end of file +} diff --git a/vendor/github.com/modern-go/reflect2/unsafe_type.go b/vendor/github.com/modern-go/reflect2/unsafe_type.go index e7ad4a65..13941716 100644 --- a/vendor/github.com/modern-go/reflect2/unsafe_type.go +++ b/vendor/github.com/modern-go/reflect2/unsafe_type.go @@ -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, From fad668338e04c4b680b087e4144665c7dc791d7f Mon Sep 17 00:00:00 2001 From: Xabier Larrakoetxea Date: Mon, 2 Jul 2018 14:40:34 +0200 Subject: [PATCH 2/2] Bump 0.3.0 Signed-off-by: Xabier Larrakoetxea --- CHANGELOG | 2 +- README.md | 70 +++++++++++++++++++++++++++---------------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ee42022b..9f594ba1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -## x.x.x / xxxx-xx-xx +## 0.3.0 / 2018-07-02 This release breaks handler interface to allow passing a context (used to allow tracing). diff --git a/README.md b/README.md index f8aaa78c..fd4f2a66 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -Kooper [![Build Status][travis-image]][travis-url] [![Go Report Card][goreport-image]][goreport-url] [![GoDoc][godoc-image]][godoc-url] -====== +# Kooper [![Build Status][travis-image]][travis-url] [![Go Report Card][goreport-image]][goreport-url] [![GoDoc][godoc-image]][godoc-url] Kooper is a simple Go library to create Kubernetes [operators](https://coreos.com/operators/) and [controllers](https://github.com/kubernetes/community/blob/master/contributors/devel/controllers.md). @@ -7,22 +6,22 @@ Kooper is a simple Go library to create Kubernetes [operators](https://coreos.co Kooper is a set of utilities packed as a library or framework to easily create Kubernetes controllers and operators. -There is a little of discussion of what a controller and what an operator is, see [here](https://stackoverflow.com/questions/47848258/kubernetes-controller-vs-kubernetes-operator) for more information. +There is a little of discussion of what a controller and what an operator is, see [here](https://stackoverflow.com/questions/47848258/kubernetes-controller-vs-kubernetes-operator) for more information. In Kooper the concepts of controller an operator are very simple, a controller controls the state of a resource in Kubernetes, and an operator is a controller that initializes custom resources (CRD) and controls the state of this custom resource. ## Features -* Easy and decoupled library. -* Well structured and a clear API. -* Remove all duplicated code from every controller and operator. -* Uses the tooling already created by Kubernetes. -* Remove complexity from operators and controllers so the focus is on domain logic. -* Easy to mock and extend functionality (Go interfaces!). -* Only support CRD, no TPR support (Kubernetes >=1.7). -* Controller metrics. -* Leader election. -* Tracing with [Opentracing][opentracing-url]. +- Easy and decoupled library. +- Well structured and a clear API. +- Remove all duplicated code from every controller and operator. +- Uses the tooling already created by Kubernetes. +- Remove complexity from operators and controllers so the focus is on domain logic. +- Easy to mock and extend functionality (Go interfaces!). +- Only support CRD, no TPR support (Kubernetes >=1.7). +- Controller metrics. +- Leader election. +- Tracing with [Opentracing][opentracing-url]. ## Example @@ -94,13 +93,13 @@ At this moment there is no standard, although there are some projects like [rook Spotahome studied these projects before developing Kooper and they didn't fit the requirements: -* Clear and maintanable code. -* Easy to test and mock. -* Well tested library. -* Easy and clear programming API. -* Good abstraction and structure to focus on domain logic (the meat of the controller). -* Reduce complexity in all the operators and controllers that use the library. -* Not only operators, controllers as first class citizen also. +- Clear and maintanable code. +- Easy to test and mock. +- Well tested library. +- Easy and clear programming API. +- Good abstraction and structure to focus on domain logic (the meat of the controller). +- Reduce complexity in all the operators and controllers that use the library. +- Not only operators, controllers as first class citizen also. ## Installing @@ -116,11 +115,12 @@ Managing a project that uses different kubernetes libs as dependencies can be tr ## Compatibility matrix -| | Kubernetes 1.8 | Kubernetes 1.9 | Kubernetes 1.10 | -|---------------------|----------------|----------------|-----------------| -| kooper 0.1 | ✓ | ✓ | ? | -| kooper 0.2 | ✓ | ✓ | ? | -| kooper HEAD | ? | ? | ✓ | +| | Kubernetes 1.8 | Kubernetes 1.9 | Kubernetes 1.10 | Kubernetes 1.11 | +| ----------- | -------------- | -------------- | --------------- | --------------- | +| kooper 0.1 | ✓ | ✓ | ? | ? | +| kooper 0.2 | ✓ | ✓ | ? | ? | +| kooper 0.3 | ? | ?+ | ✓ | ? | +| kooper HEAD | ? | ? | ?+ | ✓ | Based on this matrix Kooper needs different versions of Kubernetes dependencies. @@ -154,24 +154,24 @@ Kooper comes with different topics as documentation. ### Core -* [Basic concepts](docs/concepts.md) -* [Controller tutorial](docs/controller-tutorial.md) -* [Operator tutorial](docs/operator-tutorial.md) +- [Basic concepts](docs/concepts.md) +- [Controller tutorial](docs/controller-tutorial.md) +- [Operator tutorial](docs/operator-tutorial.md) ### Other -* [Metrics](docs/metrics.md) -* [Logger](docs/logger.md) -* [Leader election](docs/leader-election.md) -* [Tracing](docs/tracing.md) +- [Metrics](docs/metrics.md) +- [Logger](docs/logger.md) +- [Leader election](docs/leader-election.md) +- [Tracing](docs/tracing.md) The starting point would be to check the [concepts](docs/concepts.md) and then continue with the controller and operator tutorials. ## Who is using kooper -* [redis-operator](https://github.com/spotahome/redis-operator) -* [node-labeler-operator](https://github.com/barpilot/node-labeler-operator) -* [source-ranges-controller](https://github.com/jeffersongirao/source-ranges-controller) +- [redis-operator](https://github.com/spotahome/redis-operator) +- [node-labeler-operator](https://github.com/barpilot/node-labeler-operator) +- [source-ranges-controller](https://github.com/jeffersongirao/source-ranges-controller) [travis-image]: https://travis-ci.org/spotahome/kooper.svg?branch=master [travis-url]: https://travis-ci.org/spotahome/kooper