Update go dependencies
This commit is contained in:
parent
a858c549d9
commit
f3bde94d68
643 changed files with 14296 additions and 19354 deletions
2
vendor/k8s.io/apimachinery/pkg/conversion/unstructured/BUILD
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/conversion/unstructured/BUILD
generated
vendored
|
|
@ -11,11 +11,9 @@ go_library(
|
|||
"converter.go",
|
||||
"doc.go",
|
||||
],
|
||||
importpath = "k8s.io/apimachinery/pkg/conversion/unstructured",
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/json:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
|
|
|
|||
58
vendor/k8s.io/apimachinery/pkg/conversion/unstructured/converter.go
generated
vendored
58
vendor/k8s.io/apimachinery/pkg/conversion/unstructured/converter.go
generated
vendored
|
|
@ -29,7 +29,6 @@ import (
|
|||
"sync/atomic"
|
||||
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/diff"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
|
|
@ -107,8 +106,6 @@ func NewConverter(mismatchDetection bool) Converter {
|
|||
}
|
||||
}
|
||||
|
||||
// FromUnstructured converts an object from map[string]interface{} representation into a concrete type.
|
||||
// It uses encoding/json/Unmarshaler if object implements it or reflection if not.
|
||||
func (c *converterImpl) FromUnstructured(u map[string]interface{}, obj interface{}) error {
|
||||
t := reflect.TypeOf(obj)
|
||||
value := reflect.ValueOf(obj)
|
||||
|
|
@ -391,27 +388,19 @@ func interfaceFromUnstructured(sv, dv reflect.Value) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// ToUnstructured converts an object into map[string]interface{} representation.
|
||||
// It uses encoding/json/Marshaler if object implements it or reflection if not.
|
||||
func (c *converterImpl) ToUnstructured(obj interface{}) (map[string]interface{}, error) {
|
||||
var u map[string]interface{}
|
||||
var err error
|
||||
if unstr, ok := obj.(runtime.Unstructured); ok {
|
||||
u = DeepCopyJSON(unstr.UnstructuredContent())
|
||||
} else {
|
||||
t := reflect.TypeOf(obj)
|
||||
value := reflect.ValueOf(obj)
|
||||
if t.Kind() != reflect.Ptr || value.IsNil() {
|
||||
return nil, fmt.Errorf("ToUnstructured requires a non-nil pointer to an object, got %v", t)
|
||||
}
|
||||
u = map[string]interface{}{}
|
||||
err = toUnstructured(value.Elem(), reflect.ValueOf(&u).Elem())
|
||||
t := reflect.TypeOf(obj)
|
||||
value := reflect.ValueOf(obj)
|
||||
if t.Kind() != reflect.Ptr || value.IsNil() {
|
||||
return nil, fmt.Errorf("ToUnstructured requires a non-nil pointer to an object, got %v", t)
|
||||
}
|
||||
u := &map[string]interface{}{}
|
||||
err := toUnstructured(value.Elem(), reflect.ValueOf(u).Elem())
|
||||
if c.mismatchDetection {
|
||||
newUnstr := map[string]interface{}{}
|
||||
newErr := toUnstructuredViaJSON(obj, &newUnstr)
|
||||
newUnstr := &map[string]interface{}{}
|
||||
newErr := toUnstructuredViaJSON(obj, newUnstr)
|
||||
if (err != nil) != (newErr != nil) {
|
||||
glog.Fatalf("ToUnstructured unexpected error for %v: error: %v; newErr: %v", obj, err, newErr)
|
||||
glog.Fatalf("ToUnstructured unexpected error for %v: error: %v", obj, err)
|
||||
}
|
||||
if err == nil && !apiequality.Semantic.DeepEqual(u, newUnstr) {
|
||||
glog.Fatalf("ToUnstructured mismatch for %#v, diff: %v", u, diff.ObjectReflectDiff(u, newUnstr))
|
||||
|
|
@ -420,34 +409,7 @@ func (c *converterImpl) ToUnstructured(obj interface{}) (map[string]interface{},
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// DeepCopyJSON deep copies the passed value, assuming it is a valid JSON representation i.e. only contains
|
||||
// types produced by json.Unmarshal().
|
||||
func DeepCopyJSON(x map[string]interface{}) map[string]interface{} {
|
||||
return deepCopyJSON(x).(map[string]interface{})
|
||||
}
|
||||
|
||||
func deepCopyJSON(x interface{}) interface{} {
|
||||
switch x := x.(type) {
|
||||
case map[string]interface{}:
|
||||
clone := make(map[string]interface{}, len(x))
|
||||
for k, v := range x {
|
||||
clone[k] = deepCopyJSON(v)
|
||||
}
|
||||
return clone
|
||||
case []interface{}:
|
||||
clone := make([]interface{}, len(x))
|
||||
for i, v := range x {
|
||||
clone[i] = deepCopyJSON(v)
|
||||
}
|
||||
return clone
|
||||
case string, int64, bool, float64, nil, encodingjson.Number:
|
||||
return x
|
||||
default:
|
||||
panic(fmt.Errorf("cannot deep copy %T", x))
|
||||
}
|
||||
return *u, nil
|
||||
}
|
||||
|
||||
func toUnstructuredViaJSON(obj interface{}, u *map[string]interface{}) error {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue