Update go dependencies

This commit is contained in:
Manuel de Brito Fontes 2017-11-12 14:14:23 -03:00
parent a858c549d9
commit f3bde94d68
643 changed files with 14296 additions and 19354 deletions

View file

@ -8,7 +8,6 @@ load(
go_library(
name = "go_default_library",
srcs = ["semantic.go"],
importpath = "k8s.io/apimachinery/pkg/api/equality",
deps = [
"//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["errors_test.go"],
importpath = "k8s.io/apimachinery/pkg/api/errors",
library = ":go_default_library",
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
@ -25,7 +24,6 @@ go_library(
"doc.go",
"errors.go",
],
importpath = "k8s.io/apimachinery/pkg/api/errors",
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",

View file

@ -20,6 +20,7 @@ reviewers:
- dims
- hongchaodeng
- krousey
- satnam6502
- cjcullen
- david-mcmahon
- goltermann

View file

@ -14,7 +14,6 @@ go_test(
"priority_test.go",
"restmapper_test.go",
],
importpath = "k8s.io/apimachinery/pkg/api/meta",
library = ":go_default_library",
deps = [
"//vendor/github.com/google/gofuzz:go_default_library",
@ -40,7 +39,6 @@ go_library(
"restmapper.go",
"unstructured.go",
],
importpath = "k8s.io/apimachinery/pkg/api/meta",
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",

View file

@ -15,7 +15,6 @@ go_test(
"quantity_test.go",
"scale_int_test.go",
],
importpath = "k8s.io/apimachinery/pkg/api/resource",
library = ":go_default_library",
deps = [
"//vendor/github.com/google/gofuzz:go_default_library",
@ -34,15 +33,12 @@ go_library(
"quantity_proto.go",
"scale_int.go",
"suffix.go",
"zz_generated.deepcopy.go",
],
importpath = "k8s.io/apimachinery/pkg/api/resource",
deps = [
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/gopkg.in/inf.v0:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
"//vendor/k8s.io/kube-openapi/pkg/common:go_default_library",
],
)
@ -50,7 +46,6 @@ go_library(
go_test(
name = "go_default_xtest",
srcs = ["quantity_example_test.go"],
importpath = "k8s.io/apimachinery/pkg/api/resource_test",
deps = ["//vendor/k8s.io/apimachinery/pkg/api/resource:go_default_library"],
)

View file

@ -87,7 +87,6 @@ option go_package = "resource";
// +protobuf.embed=string
// +protobuf.options.marshal=false
// +protobuf.options.(gogoproto.goproto_stringer)=false
// +k8s:deepcopy-gen=true
// +k8s:openapi-gen=true
message Quantity {
optional string string = 1;

View file

@ -93,7 +93,6 @@ import (
// +protobuf.embed=string
// +protobuf.options.marshal=false
// +protobuf.options.(gogoproto.goproto_stringer)=false
// +k8s:deepcopy-gen=true
// +k8s:openapi-gen=true
type Quantity struct {
// i is the quantity in int64 scaled form, if d.Dec == nil
@ -416,7 +415,7 @@ func (_ Quantity) OpenAPIDefinition() openapi.OpenAPIDefinition {
// Note about BinarySI:
// * If q.Format is set to BinarySI and q.Amount represents a non-zero value between
// -1 and +1, it will be emitted as if q.Format were DecimalSI.
// * Otherwise, if q.Format is set to BinarySI, fractional parts of q.Amount will be
// * Otherwise, if q.Format is set to BinarySI, frational parts of q.Amount will be
// rounded up. (1.1i becomes 2i.)
func (q *Quantity) CanonicalizeBytes(out []byte) (result, suffix []byte) {
if q.IsZero() {

View file

@ -1,44 +0,0 @@
// +build !ignore_autogenerated
/*
Copyright 2017 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.
*/
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package resource
import (
conversion "k8s.io/apimachinery/pkg/conversion"
reflect "reflect"
)
// GetGeneratedDeepCopyFuncs returns the generated funcs, since we aren't registering them.
//
// Deprecated: deepcopy registration will go away when static deepcopy is fully implemented.
func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
return []conversion.GeneratedDeepCopyFunc{
{Fn: func(in interface{}, out interface{}, c *conversion.Cloner) error {
in.(*Quantity).DeepCopyInto(out.(*Quantity))
return nil
}, InType: reflect.TypeOf(&Quantity{})},
}
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Quantity) DeepCopyInto(out *Quantity) {
*out = in.DeepCopy()
return
}

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["objectmeta_test.go"],
importpath = "k8s.io/apimachinery/pkg/api/validation",
library = ":go_default_library",
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
@ -24,7 +23,6 @@ go_library(
"generic.go",
"objectmeta.go",
],
importpath = "k8s.io/apimachinery/pkg/api/validation",
deps = [
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["types_test.go"],
importpath = "k8s.io/apimachinery/pkg/apimachinery",
library = ":go_default_library",
deps = ["//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library"],
)
@ -20,7 +19,6 @@ go_library(
"doc.go",
"types.go",
],
importpath = "k8s.io/apimachinery/pkg/apimachinery",
deps = [
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["announced_test.go"],
importpath = "k8s.io/apimachinery/pkg/apimachinery/announced",
library = ":go_default_library",
deps = ["//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library"],
)
@ -20,7 +19,6 @@ go_library(
"announced.go",
"group_factory.go",
],
importpath = "k8s.io/apimachinery/pkg/apimachinery/announced",
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["registered_test.go"],
importpath = "k8s.io/apimachinery/pkg/apimachinery/registered",
library = ":go_default_library",
deps = [
"//vendor/k8s.io/apimachinery/pkg/apimachinery:go_default_library",
@ -20,7 +19,6 @@ go_test(
go_library(
name = "go_default_library",
srcs = ["registered.go"],
importpath = "k8s.io/apimachinery/pkg/apimachinery/registered",
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",

View file

@ -12,7 +12,6 @@ go_test(
"register_test.go",
"roundtrip_test.go",
],
importpath = "k8s.io/apimachinery/pkg/apis/meta/internalversion",
library = ":go_default_library",
deps = [
"//vendor/k8s.io/apimachinery/pkg/api/testing/roundtrip:go_default_library",
@ -32,7 +31,6 @@ go_library(
"zz_generated.conversion.go",
"zz_generated.deepcopy.go",
],
importpath = "k8s.io/apimachinery/pkg/apis/meta/internalversion",
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1alpha1:go_default_library",

View file

@ -38,6 +38,9 @@ var (
AddToScheme = localSchemeBuilder.AddToScheme
)
// Copier exposes copying on this scheme.
var Copier runtime.ObjectCopier = scheme
// Codecs provides access to encoding and decoding for the scheme.
var Codecs = serializer.NewCodecFactory(scheme)

View file

@ -18,7 +18,6 @@ go_test(
"time_test.go",
"types_test.go",
],
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1",
library = ":go_default_library",
deps = [
"//vendor/github.com/ghodss/yaml:go_default_library",
@ -51,7 +50,6 @@ go_library(
"zz_generated.deepcopy.go",
"zz_generated.defaults.go",
],
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1",
deps = [
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/gogo/protobuf/proto:go_default_library",

View file

@ -175,10 +175,10 @@ func (t *MicroTime) Fuzz(c fuzz.Continue) {
if t == nil {
return
}
// Allow for about 1000 years of randomness. Accurate to a tenth of
// micro second. Leave off nanoseconds because JSON doesn't
// represent them so they can't round-trip properly.
t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60), 1000*c.Rand.Int63n(1000000))
// Allow for about 1000 years of randomness. Leave off nanoseconds
// because JSON doesn't represent them so they can't round-trip
// properly.
t.Time = time.Unix(c.Rand.Int63n(1000*365*24*60*60*1000*1000), 0)
}
var _ fuzz.Interface = &MicroTime{}

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["unstructured_test.go"],
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
library = ":go_default_library",
deps = ["//vendor/github.com/stretchr/testify/assert:go_default_library"],
)
@ -20,7 +19,6 @@ go_library(
"unstructured.go",
"zz_generated.deepcopy.go",
],
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",

View file

@ -145,13 +145,33 @@ func (u *Unstructured) UnmarshalJSON(b []byte) error {
return err
}
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 := range x {
clone[i] = deepCopyJSON(x[i])
}
return clone
default:
// only non-pointer values (float64, int64, bool, string) are left. These can be copied by-value.
return x
}
}
func (in *Unstructured) DeepCopy() *Unstructured {
if in == nil {
return nil
}
out := new(Unstructured)
*out = *in
out.Object = unstructured.DeepCopyJSON(in.Object)
out.Object = deepCopyJSON(in.Object).(map[string]interface{})
return out
}
@ -161,7 +181,7 @@ func (in *UnstructuredList) DeepCopy() *UnstructuredList {
}
out := new(UnstructuredList)
*out = *in
out.Object = unstructured.DeepCopyJSON(in.Object)
out.Object = deepCopyJSON(in.Object).(map[string]interface{})
out.Items = make([]Unstructured, len(in.Items))
for i := range in.Items {
in.Items[i].DeepCopyInto(&out.Items[i])

View file

@ -58,21 +58,3 @@ func TestUnstructuredList(t *testing.T) {
t.Fatalf("unexpected fields: %#v", items[0])
}
}
func TestNilDeletionTimestamp(t *testing.T) {
var u Unstructured
del := u.GetDeletionTimestamp()
if del != nil {
t.Errorf("unexpected non-nil deletion timestamp: %v", del)
}
u.SetDeletionTimestamp(u.GetDeletionTimestamp())
del = u.GetDeletionTimestamp()
if del != nil {
t.Errorf("unexpected non-nil deletion timestamp: %v", del)
}
metadata := u.Object["metadata"].(map[string]interface{})
deletionTimestamp := metadata["deletionTimestamp"]
if deletionTimestamp != nil {
t.Errorf("unexpected deletion timestamp field: %q", deletionTimestamp)
}
}

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["validation_test.go"],
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1/validation",
library = ":go_default_library",
deps = ["//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library"],
)
@ -17,7 +16,6 @@ go_test(
go_library(
name = "go_default_library",
srcs = ["validation.go"],
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1/validation",
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",

View file

@ -18,7 +18,6 @@ go_library(
"zz_generated.deepcopy.go",
"zz_generated.defaults.go",
],
importpath = "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
deps = [
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",

View file

@ -98,7 +98,7 @@ type TableRowCondition struct {
type RowConditionType string
// These are valid conditions of a row. This list is not exhaustive and new conditions may be
// included by other resources.
// inculded by other resources.
const (
// RowCompleted means the underlying resource has reached completion and may be given less
// visual priority than other resources.

View file

@ -13,7 +13,6 @@ go_test(
"deep_copy_test.go",
"helper_test.go",
],
importpath = "k8s.io/apimachinery/pkg/conversion",
library = ":go_default_library",
deps = [
"//vendor/github.com/google/gofuzz:go_default_library",
@ -31,7 +30,6 @@ go_library(
"doc.go",
"helper.go",
],
importpath = "k8s.io/apimachinery/pkg/conversion",
deps = ["//vendor/k8s.io/apimachinery/third_party/forked/golang/reflect:go_default_library"],
)

View file

@ -12,13 +12,11 @@ go_library(
"convert.go",
"doc.go",
],
importpath = "k8s.io/apimachinery/pkg/conversion/queryparams",
)
go_test(
name = "go_default_xtest",
srcs = ["convert_test.go"],
importpath = "k8s.io/apimachinery/pkg/conversion/queryparams_test",
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion/queryparams:go_default_library",

View file

@ -90,14 +90,7 @@ func customMarshalValue(value reflect.Value) (reflect.Value, bool) {
marshaler, ok := value.Interface().(Marshaler)
if !ok {
if !isPointerKind(value.Kind()) && value.CanAddr() {
marshaler, ok = value.Addr().Interface().(Marshaler)
if !ok {
return reflect.Value{}, false
}
} else {
return reflect.Value{}, false
}
return reflect.Value{}, false
}
// Don't invoke functions on nil pointers

View file

@ -66,13 +66,12 @@ func (obj *baz) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKin
// childStructs tests some of the types we serialize to query params for log API calls
// notably, the nested time struct
type childStructs struct {
Container string `json:"container,omitempty"`
Follow bool `json:"follow,omitempty"`
Previous bool `json:"previous,omitempty"`
SinceSeconds *int64 `json:"sinceSeconds,omitempty"`
SinceTime *metav1.Time `json:"sinceTime,omitempty"`
EmptyTime *metav1.Time `json:"emptyTime"`
NonPointerTime metav1.Time `json:"nonPointerTime"`
Container string `json:"container,omitempty"`
Follow bool `json:"follow,omitempty"`
Previous bool `json:"previous,omitempty"`
SinceSeconds *int64 `json:"sinceSeconds,omitempty"`
SinceTime *metav1.Time `json:"sinceTime,omitempty"`
EmptyTime *metav1.Time `json:"emptyTime"`
}
func (obj *childStructs) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind }
@ -178,26 +177,24 @@ func TestConvert(t *testing.T) {
},
{
input: &childStructs{
Container: "mycontainer",
Follow: true,
Previous: true,
SinceSeconds: &sinceSeconds,
SinceTime: &sinceTime, // test a custom marshaller
EmptyTime: nil, // test a nil custom marshaller without omitempty
NonPointerTime: sinceTime,
Container: "mycontainer",
Follow: true,
Previous: true,
SinceSeconds: &sinceSeconds,
SinceTime: &sinceTime, // test a custom marshaller
EmptyTime: nil, // test a nil custom marshaller without omitempty
},
expected: url.Values{"container": {"mycontainer"}, "follow": {"true"}, "previous": {"true"}, "sinceSeconds": {"123"}, "sinceTime": {"2000-01-01T12:34:56Z"}, "emptyTime": {""}, "nonPointerTime": {"2000-01-01T12:34:56Z"}},
expected: url.Values{"container": {"mycontainer"}, "follow": {"true"}, "previous": {"true"}, "sinceSeconds": {"123"}, "sinceTime": {"2000-01-01T12:34:56Z"}, "emptyTime": {""}},
},
{
input: &childStructs{
Container: "mycontainer",
Follow: true,
Previous: true,
SinceSeconds: &sinceSeconds,
SinceTime: nil, // test a nil custom marshaller with omitempty
NonPointerTime: sinceTime,
Container: "mycontainer",
Follow: true,
Previous: true,
SinceSeconds: &sinceSeconds,
SinceTime: nil, // test a nil custom marshaller with omitempty
},
expected: url.Values{"container": {"mycontainer"}, "follow": {"true"}, "previous": {"true"}, "sinceSeconds": {"123"}, "emptyTime": {""}, "nonPointerTime": {"2000-01-01T12:34:56Z"}},
expected: url.Values{"container": {"mycontainer"}, "follow": {"true"}, "previous": {"true"}, "sinceSeconds": {"123"}, "emptyTime": {""}},
},
}

View file

@ -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",

View file

@ -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 {

View file

@ -12,7 +12,6 @@ go_test(
"fields_test.go",
"selector_test.go",
],
importpath = "k8s.io/apimachinery/pkg/fields",
library = ":go_default_library",
)
@ -24,7 +23,6 @@ go_library(
"requirements.go",
"selector.go",
],
importpath = "k8s.io/apimachinery/pkg/fields",
deps = ["//vendor/k8s.io/apimachinery/pkg/selection:go_default_library"],
)

View file

@ -12,7 +12,6 @@ go_test(
"labels_test.go",
"selector_test.go",
],
importpath = "k8s.io/apimachinery/pkg/labels",
library = ":go_default_library",
deps = [
"//vendor/k8s.io/apimachinery/pkg/selection:go_default_library",
@ -28,7 +27,6 @@ go_library(
"selector.go",
"zz_generated.deepcopy.go",
],
importpath = "k8s.io/apimachinery/pkg/labels",
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["swagger_doc_generator_test.go"],
importpath = "k8s.io/apimachinery/pkg/runtime",
library = ":go_default_library",
)
@ -34,7 +33,6 @@ go_library(
"types_proto.go",
"zz_generated.deepcopy.go",
],
importpath = "k8s.io/apimachinery/pkg/runtime",
deps = [
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
@ -52,7 +50,6 @@ go_test(
"extension_test.go",
"scheme_test.go",
],
importpath = "k8s.io/apimachinery/pkg/runtime_test",
deps = [
"//vendor/github.com/google/gofuzz:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",

View file

@ -203,6 +203,13 @@ type ObjectCreater interface {
New(kind schema.GroupVersionKind) (out Object, err error)
}
// ObjectCopier duplicates an object.
type ObjectCopier interface {
// Copy returns an exact copy of the provided Object, or an error if the
// copy could not be completed.
Copy(Object) (Object, error)
}
// ResourceVersioner provides methods for setting and retrieving
// the resource version from an API object.
type ResourceVersioner interface {

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["group_version_test.go"],
importpath = "k8s.io/apimachinery/pkg/runtime/schema",
library = ":go_default_library",
)
@ -20,7 +19,6 @@ go_library(
"group_version.go",
"interfaces.go",
],
importpath = "k8s.io/apimachinery/pkg/runtime/schema",
deps = ["//vendor/github.com/gogo/protobuf/proto:go_default_library"],
)

View file

@ -420,6 +420,20 @@ func (s *Scheme) Default(src Object) {
}
}
// Copy does a deep copy of an API object.
func (s *Scheme) Copy(src Object) (Object, error) {
dst, err := s.DeepCopy(src)
if err != nil {
return nil, err
}
return dst.(Object), nil
}
// Performs a deep copy of the given object.
func (s *Scheme) DeepCopy(src interface{}) (interface{}, error) {
return s.cloner.DeepCopy(src)
}
// Convert will attempt to convert in into out. Both must be pointers. For easy
// testing of conversion functions. Returns an error if the conversion isn't
// possible. You can call this with types that haven't been registered (for example,
@ -487,9 +501,9 @@ func (s *Scheme) convertToVersion(copy bool, in Object, target GroupVersioner) (
// TODO: when we move to server API versions, we should completely remove the unversioned concept
if unversionedKind, ok := s.unversionedTypes[t]; ok {
if gvk, ok := target.KindForGroupVersionKinds([]schema.GroupVersionKind{unversionedKind}); ok {
return copyAndSetTargetKind(copy, in, gvk)
return copyAndSetTargetKind(copy, s, in, gvk)
}
return copyAndSetTargetKind(copy, in, unversionedKind)
return copyAndSetTargetKind(copy, s, in, unversionedKind)
}
return nil, NewNotRegisteredErrForTarget(t, target)
@ -498,16 +512,16 @@ func (s *Scheme) convertToVersion(copy bool, in Object, target GroupVersioner) (
// target wants to use the existing type, set kind and return (no conversion necessary)
for _, kind := range kinds {
if gvk == kind {
return copyAndSetTargetKind(copy, in, gvk)
return copyAndSetTargetKind(copy, s, in, gvk)
}
}
// type is unversioned, no conversion necessary
if unversionedKind, ok := s.unversionedTypes[t]; ok {
if gvk, ok := target.KindForGroupVersionKinds([]schema.GroupVersionKind{unversionedKind}); ok {
return copyAndSetTargetKind(copy, in, gvk)
return copyAndSetTargetKind(copy, s, in, gvk)
}
return copyAndSetTargetKind(copy, in, unversionedKind)
return copyAndSetTargetKind(copy, s, in, unversionedKind)
}
out, err := s.New(gvk)
@ -535,7 +549,7 @@ func (s *Scheme) generateConvertMeta(in interface{}) (conversion.FieldMatchingFl
}
// copyAndSetTargetKind performs a conditional copy before returning the object, or an error if copy was not successful.
func copyAndSetTargetKind(copy bool, obj Object, kind schema.GroupVersionKind) (Object, error) {
func copyAndSetTargetKind(copy bool, copier ObjectCopier, obj Object, kind schema.GroupVersionKind) (Object, error) {
if copy {
obj = obj.DeepCopyObject()
}

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["codec_test.go"],
importpath = "k8s.io/apimachinery/pkg/runtime/serializer",
library = ":go_default_library",
deps = [
"//vendor/github.com/ghodss/yaml:go_default_library",
@ -31,7 +30,6 @@ go_library(
"negotiated_codec.go",
"protobuf_extension.go",
],
importpath = "k8s.io/apimachinery/pkg/runtime/serializer",
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["meta_test.go"],
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/json",
library = ":go_default_library",
)
@ -19,7 +18,6 @@ go_library(
"json.go",
"meta.go",
],
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/json",
deps = [
"//vendor/github.com/ghodss/yaml:go_default_library",
"//vendor/github.com/json-iterator/go:go_default_library",
@ -34,7 +32,6 @@ go_library(
go_test(
name = "go_default_xtest",
srcs = ["json_test.go"],
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/json_test",
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",

View file

@ -11,7 +11,6 @@ go_library(
"doc.go",
"protobuf.go",
],
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
deps = [
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",

View file

@ -8,7 +8,6 @@ load(
go_library(
name = "go_default_library",
srcs = ["recognizer.go"],
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["streaming_test.go"],
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
library = ":go_default_library",
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
@ -21,7 +20,6 @@ go_test(
go_library(
name = "go_default_library",
srcs = ["streaming.go"],
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["versioning_test.go"],
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
library = ":go_default_library",
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
@ -21,10 +20,10 @@ go_test(
go_library(
name = "go_default_library",
srcs = ["versioning.go"],
importpath = "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
],
)

View file

@ -21,6 +21,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
)
// NewCodecForScheme is a convenience method for callers that are using a scheme.
@ -32,7 +33,7 @@ func NewCodecForScheme(
encodeVersion runtime.GroupVersioner,
decodeVersion runtime.GroupVersioner,
) runtime.Codec {
return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, nil, encodeVersion, decodeVersion)
return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, scheme, nil, encodeVersion, decodeVersion)
}
// NewDefaultingCodecForScheme is a convenience method for callers that are using a scheme.
@ -44,7 +45,7 @@ func NewDefaultingCodecForScheme(
encodeVersion runtime.GroupVersioner,
decodeVersion runtime.GroupVersioner,
) runtime.Codec {
return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, scheme, encodeVersion, decodeVersion)
return NewCodec(encoder, decoder, runtime.UnsafeObjectConvertor(scheme), scheme, scheme, scheme, scheme, encodeVersion, decodeVersion)
}
// NewCodec takes objects in their internal versions and converts them to external versions before
@ -55,6 +56,7 @@ func NewCodec(
decoder runtime.Decoder,
convertor runtime.ObjectConvertor,
creater runtime.ObjectCreater,
copier runtime.ObjectCopier,
typer runtime.ObjectTyper,
defaulter runtime.ObjectDefaulter,
encodeVersion runtime.GroupVersioner,
@ -65,6 +67,7 @@ func NewCodec(
decoder: decoder,
convertor: convertor,
creater: creater,
copier: copier,
typer: typer,
defaulter: defaulter,
@ -79,6 +82,7 @@ type codec struct {
decoder runtime.Decoder
convertor runtime.ObjectConvertor
creater runtime.ObjectCreater
copier runtime.ObjectCopier
typer runtime.ObjectTyper
defaulter runtime.ObjectDefaulter
@ -119,7 +123,12 @@ func (c *codec) Decode(data []byte, defaultGVK *schema.GroupVersionKind, into ru
if c.defaulter != nil {
// create a copy to ensure defaulting is not applied to the original versioned objects
if isVersioned {
versioned.Objects = []runtime.Object{obj.DeepCopyObject()}
copied, err := c.copier.Copy(obj)
if err != nil {
utilruntime.HandleError(err)
copied = obj
}
versioned.Objects = []runtime.Object{copied}
}
c.defaulter.Default(obj)
} else {
@ -142,7 +151,12 @@ func (c *codec) Decode(data []byte, defaultGVK *schema.GroupVersionKind, into ru
// Convert if needed.
if isVersioned {
// create a copy, because ConvertToVersion does not guarantee non-mutation of objects
versioned.Objects = []runtime.Object{obj.DeepCopyObject()}
copied, err := c.copier.Copy(obj)
if err != nil {
utilruntime.HandleError(err)
copied = obj
}
versioned.Objects = []runtime.Object{copied}
}
// perform defaulting if requested

View file

@ -38,8 +38,11 @@ func (d *testDecodable) GetObjectKind() schema.ObjectKind { retur
func (d *testDecodable) SetGroupVersionKind(gvk schema.GroupVersionKind) { d.gvk = gvk }
func (d *testDecodable) GroupVersionKind() schema.GroupVersionKind { return d.gvk }
func (d *testDecodable) DeepCopyObject() runtime.Object {
// no real deepcopy because these tests check for pointer equality
return d
if d == nil {
return nil
}
clone := *d
return &clone
}
type testNestedDecodable struct {
@ -55,8 +58,11 @@ func (d *testNestedDecodable) GetObjectKind() schema.ObjectKind {
func (d *testNestedDecodable) SetGroupVersionKind(gvk schema.GroupVersionKind) { d.gvk = gvk }
func (d *testNestedDecodable) GroupVersionKind() schema.GroupVersionKind { return d.gvk }
func (d *testNestedDecodable) DeepCopyObject() runtime.Object {
// no real deepcopy because these tests check for pointer equality
return d
if d == nil {
return nil
}
clone := *d
return &clone
}
func (d *testNestedDecodable) EncodeNestedObjects(e runtime.Encoder) error {
@ -72,7 +78,7 @@ func (d *testNestedDecodable) DecodeNestedObjects(_ runtime.Decoder) error {
func TestNestedDecode(t *testing.T) {
n := &testNestedDecodable{nestedErr: fmt.Errorf("unable to decode")}
decoder := &mockSerializer{obj: n}
codec := NewCodec(nil, decoder, nil, nil, nil, nil, nil, nil)
codec := NewCodec(nil, decoder, nil, nil, nil, nil, nil, nil, nil)
if _, _, err := codec.Decode([]byte(`{}`), nil, n); err != n.nestedErr {
t.Errorf("unexpected error: %v", err)
}
@ -88,7 +94,7 @@ func TestNestedEncode(t *testing.T) {
codec := NewCodec(
encoder, nil,
&checkConvertor{obj: n2, groupVersion: schema.GroupVersion{Group: "other"}},
nil,
nil, nil,
&mockTyper{gvks: []schema.GroupVersionKind{{Kind: "test"}}},
nil,
schema.GroupVersion{Group: "other"}, nil,
@ -112,6 +118,7 @@ func TestDecode(t *testing.T) {
serializer runtime.Serializer
convertor runtime.ObjectConvertor
creater runtime.ObjectCreater
copier runtime.ObjectCopier
typer runtime.ObjectTyper
defaulter runtime.ObjectDefaulter
yaml bool
@ -184,6 +191,17 @@ func TestDecode(t *testing.T) {
into: &runtime.VersionedObjects{Objects: []runtime.Object{}},
serializer: &mockSerializer{actual: gvk1, obj: decodable1},
copier: &checkCopy{in: decodable1, obj: decodable1},
convertor: &checkConvertor{in: decodable1, obj: decodable2, groupVersion: schema.GroupVersion{Group: "other", Version: "__internal"}},
expectedGVK: gvk1,
expectedObject: &runtime.VersionedObjects{Objects: []runtime.Object{decodable1, decodable2}},
decodes: schema.GroupVersion{Group: "other", Version: "__internal"},
},
{
into: &runtime.VersionedObjects{Objects: []runtime.Object{}},
serializer: &mockSerializer{actual: gvk1, obj: decodable1},
copier: &checkCopy{in: decodable1, obj: nil, err: fmt.Errorf("error on copy")},
convertor: &checkConvertor{in: decodable1, obj: decodable2, groupVersion: schema.GroupVersion{Group: "other", Version: "__internal"}},
expectedGVK: gvk1,
expectedObject: &runtime.VersionedObjects{Objects: []runtime.Object{decodable1, decodable2}},
@ -205,6 +223,7 @@ func TestDecode(t *testing.T) {
serializer: &mockSerializer{actual: gvk1, obj: decodable1},
convertor: &checkConvertor{in: decodable1, obj: decodable1, groupVersion: schema.GroupVersions{{Group: "other", Version: "blah"}}},
copier: &checkCopy{in: decodable1, obj: decodable1, err: nil},
expectedGVK: gvk1,
expectedObject: &runtime.VersionedObjects{Objects: []runtime.Object{decodable1}},
},
@ -224,6 +243,7 @@ func TestDecode(t *testing.T) {
serializer: &mockSerializer{actual: gvk1, obj: decodable1},
convertor: &checkConvertor{in: decodable1, obj: decodable1, groupVersion: schema.GroupVersions{{Group: "something", Version: "else"}}},
copier: &checkCopy{in: decodable1, obj: decodable1, err: nil},
expectedGVK: gvk1,
expectedObject: &runtime.VersionedObjects{Objects: []runtime.Object{decodable1}},
},
@ -231,7 +251,7 @@ func TestDecode(t *testing.T) {
for i, test := range testCases {
t.Logf("%d", i)
s := NewCodec(test.serializer, test.serializer, test.convertor, test.creater, test.typer, test.defaulter, test.encodes, test.decodes)
s := NewCodec(test.serializer, test.serializer, test.convertor, test.creater, test.copier, test.typer, test.defaulter, test.encodes, test.decodes)
obj, gvk, err := s.Decode([]byte(`{}`), test.defaultGVK, test.into)
if !reflect.DeepEqual(test.expectedGVK, gvk) {
@ -275,6 +295,18 @@ func TestDecode(t *testing.T) {
}
}
type checkCopy struct {
in, obj runtime.Object
err error
}
func (c *checkCopy) Copy(obj runtime.Object) (runtime.Object, error) {
if c.in != nil && c.in != obj {
return nil, fmt.Errorf("unexpected input to copy: %#v", obj)
}
return c.obj, c.err
}
type checkConvertor struct {
err error
in, obj runtime.Object

View file

@ -8,7 +8,6 @@ load(
go_library(
name = "go_default_library",
srcs = ["operator.go"],
importpath = "k8s.io/apimachinery/pkg/selection",
)
filegroup(

View file

@ -14,7 +14,6 @@ go_library(
"patch.go",
"uid.go",
],
importpath = "k8s.io/apimachinery/pkg/types",
)
filegroup(

View file

@ -12,7 +12,6 @@ go_test(
"cache_test.go",
"lruexpirecache_test.go",
],
importpath = "k8s.io/apimachinery/pkg/util/cache",
library = ":go_default_library",
deps = [
"//vendor/github.com/golang/groupcache/lru:go_default_library",
@ -26,7 +25,6 @@ go_library(
"cache.go",
"lruexpirecache.go",
],
importpath = "k8s.io/apimachinery/pkg/util/cache",
deps = ["//vendor/github.com/hashicorp/golang-lru:go_default_library"],
)

View file

@ -9,14 +9,12 @@ load(
go_test(
name = "go_default_test",
srcs = ["clock_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/clock",
library = ":go_default_library",
)
go_library(
name = "go_default_library",
srcs = ["clock.go"],
importpath = "k8s.io/apimachinery/pkg/util/clock",
)
filegroup(

View file

@ -9,14 +9,12 @@ load(
go_test(
name = "go_default_test",
srcs = ["diff_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/diff",
library = ":go_default_library",
)
go_library(
name = "go_default_library",
srcs = ["diff.go"],
importpath = "k8s.io/apimachinery/pkg/util/diff",
deps = [
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",

View file

@ -142,6 +142,10 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
}
if sub := objectReflectDiff(path.Child(a.Type().Field(i).Name), a.Field(i), b.Field(i)); len(sub) > 0 {
changes = append(changes, sub...)
} else {
if !reflect.DeepEqual(a.Field(i).Interface(), b.Field(i).Interface()) {
changes = append(changes, diff{path: path, a: a.Field(i).Interface(), b: b.Field(i).Interface()})
}
}
}
return changes
@ -174,18 +178,21 @@ func objectReflectDiff(path *field.Path, a, b reflect.Value) []diff {
}
return nil
}
var diffs []diff
for i := 0; i < l; i++ {
if !reflect.DeepEqual(a.Index(i), b.Index(i)) {
diffs = append(diffs, objectReflectDiff(path.Index(i), a.Index(i), b.Index(i))...)
return objectReflectDiff(path.Index(i), a.Index(i), b.Index(i))
}
}
var diffs []diff
for i := l; i < lA; i++ {
diffs = append(diffs, diff{path: path.Index(i), a: a.Index(i), b: nil})
}
for i := l; i < lB; i++ {
diffs = append(diffs, diff{path: path.Index(i), a: nil, b: b.Index(i)})
}
if len(diffs) == 0 {
diffs = append(diffs, diff{path: path, a: a, b: b})
}
return diffs
case reflect.Map:
if reflect.DeepEqual(a.Interface(), b.Interface()) {

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["errors_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/errors",
library = ":go_default_library",
)
@ -19,7 +18,6 @@ go_library(
"doc.go",
"errors.go",
],
importpath = "k8s.io/apimachinery/pkg/util/errors",
)
filegroup(

View file

@ -9,14 +9,12 @@ load(
go_test(
name = "go_default_test",
srcs = ["framer_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/framer",
library = ":go_default_library",
)
go_library(
name = "go_default_library",
srcs = ["framer.go"],
importpath = "k8s.io/apimachinery/pkg/util/framer",
)
filegroup(

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["httpstream_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/httpstream",
library = ":go_default_library",
)
@ -19,7 +18,6 @@ go_library(
"doc.go",
"httpstream.go",
],
importpath = "k8s.io/apimachinery/pkg/util/httpstream",
)
filegroup(

View file

@ -13,7 +13,6 @@ go_test(
"roundtripper_test.go",
"upgrade_test.go",
],
importpath = "k8s.io/apimachinery/pkg/util/httpstream/spdy",
library = ":go_default_library",
deps = [
"//vendor/github.com/elazarl/goproxy:go_default_library",
@ -28,7 +27,6 @@ go_library(
"roundtripper.go",
"upgrade.go",
],
importpath = "k8s.io/apimachinery/pkg/util/httpstream/spdy",
deps = [
"//vendor/github.com/docker/spdystream:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["intstr_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/intstr",
library = ":go_default_library",
deps = ["//vendor/github.com/ghodss/yaml:go_default_library"],
)
@ -20,7 +19,6 @@ go_library(
"generated.pb.go",
"intstr.go",
],
importpath = "k8s.io/apimachinery/pkg/util/intstr",
deps = [
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/gogo/protobuf/proto:go_default_library",

View file

@ -9,13 +9,11 @@ load(
go_library(
name = "go_default_library",
srcs = ["json.go"],
importpath = "k8s.io/apimachinery/pkg/util/json",
)
go_test(
name = "go_default_test",
srcs = ["json_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/json",
library = ":go_default_library",
)

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["util_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/mergepatch",
library = ":go_default_library",
)
@ -19,7 +18,6 @@ go_library(
"errors.go",
"util.go",
],
importpath = "k8s.io/apimachinery/pkg/util/mergepatch",
deps = [
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
"//vendor/github.com/ghodss/yaml:go_default_library",

View file

@ -15,7 +15,6 @@ go_test(
"port_split_test.go",
"util_test.go",
],
importpath = "k8s.io/apimachinery/pkg/util/net",
library = ":go_default_library",
deps = ["//vendor/github.com/spf13/pflag:go_default_library"],
)
@ -29,7 +28,6 @@ go_library(
"port_split.go",
"util.go",
],
importpath = "k8s.io/apimachinery/pkg/util/net",
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/golang.org/x/net/http2:go_default_library",

View file

@ -256,11 +256,8 @@ func isDefault(transportProxier func(*http.Request) (*url.URL, error)) bool {
// NewProxierWithNoProxyCIDR constructs a Proxier function that respects CIDRs in NO_PROXY and delegates if
// no matching CIDRs are found
func NewProxierWithNoProxyCIDR(delegate func(req *http.Request) (*url.URL, error)) func(req *http.Request) (*url.URL, error) {
// we wrap the default method, so we only need to perform our check if the NO_PROXY (or no_proxy) envvar has a CIDR in it
// we wrap the default method, so we only need to perform our check if the NO_PROXY envvar has a CIDR in it
noProxyEnv := os.Getenv("NO_PROXY")
if noProxyEnv == "" {
noProxyEnv = os.Getenv("no_proxy")
}
noProxyRules := strings.Split(noProxyEnv, ",")
cidrs := []*net.IPNet{}

31
vendor/k8s.io/apimachinery/pkg/util/rand/BUILD generated vendored Normal file
View file

@ -0,0 +1,31 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_test(
name = "go_default_test",
srcs = ["rand_test.go"],
library = ":go_default_library",
)
go_library(
name = "go_default_library",
srcs = ["rand.go"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

95
vendor/k8s.io/apimachinery/pkg/util/rand/rand.go generated vendored Normal file
View file

@ -0,0 +1,95 @@
/*
Copyright 2015 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 rand provides utilities related to randomization.
package rand
import (
"math/rand"
"sync"
"time"
)
var rng = struct {
sync.Mutex
rand *rand.Rand
}{
rand: rand.New(rand.NewSource(time.Now().UTC().UnixNano())),
}
// Intn generates an integer in range [0,max).
// By design this should panic if input is invalid, <= 0.
func Intn(max int) int {
rng.Lock()
defer rng.Unlock()
return rng.rand.Intn(max)
}
// IntnRange generates an integer in range [min,max).
// By design this should panic if input is invalid, <= 0.
func IntnRange(min, max int) int {
rng.Lock()
defer rng.Unlock()
return rng.rand.Intn(max-min) + min
}
// IntnRange generates an int64 integer in range [min,max).
// By design this should panic if input is invalid, <= 0.
func Int63nRange(min, max int64) int64 {
rng.Lock()
defer rng.Unlock()
return rng.rand.Int63n(max-min) + min
}
// Seed seeds the rng with the provided seed.
func Seed(seed int64) {
rng.Lock()
defer rng.Unlock()
rng.rand = rand.New(rand.NewSource(seed))
}
// Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n)
// from the default Source.
func Perm(n int) []int {
rng.Lock()
defer rng.Unlock()
return rng.rand.Perm(n)
}
// We omit vowels from the set of available characters to reduce the chances
// of "bad words" being formed.
var alphanums = []rune("bcdfghjklmnpqrstvwxz2456789")
// String generates a random alphanumeric string, without vowels, which is n
// characters long. This will panic if n is less than zero.
func String(length int) string {
b := make([]rune, length)
for i := range b {
b[i] = alphanums[Intn(len(alphanums))]
}
return string(b)
}
// SafeEncodeString encodes s using the same characters as rand.String. This reduces the chances of bad words and
// ensures that strings generated from hash functions appear consistent throughout the API.
func SafeEncodeString(s string) string {
r := make([]rune, len(s))
for i, b := range []rune(s) {
r[i] = alphanums[(int(b) % len(alphanums))]
}
return string(r)
}

101
vendor/k8s.io/apimachinery/pkg/util/rand/rand_test.go generated vendored Normal file
View file

@ -0,0 +1,101 @@
/*
Copyright 2015 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 rand
import (
"math/rand"
"strings"
"testing"
)
const (
maxRangeTestCount = 500
)
func TestString(t *testing.T) {
valid := "0123456789abcdefghijklmnopqrstuvwxyz"
for _, l := range []int{0, 1, 2, 10, 123} {
s := String(l)
if len(s) != l {
t.Errorf("expected string of size %d, got %q", l, s)
}
for _, c := range s {
if !strings.ContainsRune(valid, c) {
t.Errorf("expected valid charaters, got %v", c)
}
}
}
}
// Confirm that panic occurs on invalid input.
func TestRangePanic(t *testing.T) {
defer func() {
if err := recover(); err == nil {
t.Errorf("Panic didn't occur!")
}
}()
// Should result in an error...
Intn(0)
}
func TestIntn(t *testing.T) {
// 0 is invalid.
for _, max := range []int{1, 2, 10, 123} {
inrange := Intn(max)
if inrange < 0 || inrange > max {
t.Errorf("%v out of range (0,%v)", inrange, max)
}
}
}
func TestPerm(t *testing.T) {
Seed(5)
rand.Seed(5)
for i := 1; i < 20; i++ {
actual := Perm(i)
expected := rand.Perm(i)
for j := 0; j < i; j++ {
if actual[j] != expected[j] {
t.Errorf("Perm call result is unexpected")
}
}
}
}
func TestIntnRange(t *testing.T) {
// 0 is invalid.
for min, max := range map[int]int{1: 2, 10: 123, 100: 500} {
for i := 0; i < maxRangeTestCount; i++ {
inrange := IntnRange(min, max)
if inrange < min || inrange >= max {
t.Errorf("%v out of range (%v,%v)", inrange, min, max)
}
}
}
}
func TestInt63nRange(t *testing.T) {
// 0 is invalid.
for min, max := range map[int64]int64{1: 2, 10: 123, 100: 500} {
for i := 0; i < maxRangeTestCount; i++ {
inrange := Int63nRange(min, max)
if inrange < min || inrange >= max {
t.Errorf("%v out of range (%v,%v)", inrange, min, max)
}
}
}
}

View file

@ -8,7 +8,6 @@ load(
go_library(
name = "go_default_library",
srcs = ["constants.go"],
importpath = "k8s.io/apimachinery/pkg/util/remotecommand",
deps = ["//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library"],
)

View file

@ -9,14 +9,12 @@ load(
go_test(
name = "go_default_test",
srcs = ["runtime_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/runtime",
library = ":go_default_library",
)
go_library(
name = "go_default_library",
srcs = ["runtime.go"],
importpath = "k8s.io/apimachinery/pkg/util/runtime",
deps = ["//vendor/github.com/golang/glog:go_default_library"],
)

View file

@ -17,7 +17,6 @@ go_library(
"int64.go",
"string.go",
],
importpath = "k8s.io/apimachinery/pkg/util/sets",
)
go_genrule(
@ -51,7 +50,6 @@ $(location //vendor/k8s.io/code-generator/cmd/set-gen) \
go_test(
name = "go_default_test",
srcs = ["set_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/sets",
library = ":go_default_library",
)

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["patch_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/strategicpatch",
library = ":go_default_library",
deps = [
"//vendor/github.com/davecgh/go-spew/spew:go_default_library",
@ -23,7 +22,6 @@ go_test(
go_library(
name = "go_default_library",
srcs = ["patch.go"],
importpath = "k8s.io/apimachinery/pkg/util/strategicpatch",
deps = [
"//vendor/k8s.io/apimachinery/pkg/util/json:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/mergepatch:go_default_library",

View file

@ -8,7 +8,6 @@ load(
go_library(
name = "go_default_library",
srcs = ["uuid.go"],
importpath = "k8s.io/apimachinery/pkg/util/uuid",
deps = [
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/types:go_default_library",

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["validation_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/validation",
library = ":go_default_library",
deps = ["//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library"],
)
@ -17,7 +16,6 @@ go_test(
go_library(
name = "go_default_library",
srcs = ["validation.go"],
importpath = "k8s.io/apimachinery/pkg/util/validation",
deps = ["//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library"],
)

View file

@ -12,7 +12,6 @@ go_test(
"errors_test.go",
"path_test.go",
],
importpath = "k8s.io/apimachinery/pkg/util/validation/field",
library = ":go_default_library",
)
@ -22,7 +21,6 @@ go_library(
"errors.go",
"path.go",
],
importpath = "k8s.io/apimachinery/pkg/util/validation/field",
deps = [
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",

View file

@ -19,7 +19,6 @@ package field
import (
"fmt"
"reflect"
"strconv"
"strings"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
@ -176,11 +175,7 @@ func Invalid(field *Path, value interface{}, detail string) *Error {
func NotSupported(field *Path, value interface{}, validValues []string) *Error {
detail := ""
if validValues != nil && len(validValues) > 0 {
quotedValues := make([]string, len(validValues))
for i, v := range validValues {
quotedValues[i] = strconv.Quote(v)
}
detail = "supported values: " + strings.Join(quotedValues, ", ")
detail = "supported values: " + strings.Join(validValues, ", ")
}
return &Error{ErrorTypeNotSupported, field.String(), value, detail}
}

View file

@ -165,11 +165,3 @@ func TestErrListFilter(t *testing.T) {
t.Errorf("should filter")
}
}
func TestNotSupported(t *testing.T) {
notSupported := NotSupported(NewPath("f"), "v", []string{"a", "b", "c"})
expected := `Unsupported value: "v": supported values: "a", "b", "c"`
if notSupported.ErrorBody() != expected {
t.Errorf("Expected: %s\n, but got: %s\n", expected, notSupported.ErrorBody())
}
}

View file

@ -9,7 +9,6 @@ load(
go_test(
name = "go_default_test",
srcs = ["wait_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/wait",
library = ":go_default_library",
deps = ["//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library"],
)
@ -20,7 +19,6 @@ go_library(
"doc.go",
"wait.go",
],
importpath = "k8s.io/apimachinery/pkg/util/wait",
deps = ["//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library"],
)

View file

@ -9,14 +9,12 @@ load(
go_test(
name = "go_default_test",
srcs = ["decoder_test.go"],
importpath = "k8s.io/apimachinery/pkg/util/yaml",
library = ":go_default_library",
)
go_library(
name = "go_default_library",
srcs = ["decoder.go"],
importpath = "k8s.io/apimachinery/pkg/util/yaml",
deps = [
"//vendor/github.com/ghodss/yaml:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",

View file

@ -11,7 +11,6 @@ go_library(
"doc.go",
"types.go",
],
importpath = "k8s.io/apimachinery/pkg/version",
)
filegroup(

View file

@ -17,7 +17,6 @@ go_library(
"watch.go",
"zz_generated.deepcopy.go",
],
importpath = "k8s.io/apimachinery/pkg/watch",
deps = [
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/conversion:go_default_library",
@ -37,7 +36,6 @@ go_test(
"streamwatcher_test.go",
"watch_test.go",
],
importpath = "k8s.io/apimachinery/pkg/watch_test",
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
@ -49,7 +47,6 @@ go_test(
go_test(
name = "go_default_test",
srcs = ["until_test.go"],
importpath = "k8s.io/apimachinery/pkg/watch",
library = ":go_default_library",
deps = [
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",