summaryrefslogtreecommitdiff
path: root/vendor/k8s.io/apimachinery/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-05-08 12:59:42 +0200
committerGitHub <noreply@github.com>2020-05-08 12:59:42 +0200
commit4b300a12cedabff3c57ee657afac0696cefaae0a (patch)
tree61c5fceec50e88338038415fa1375371bef2dca4 /vendor/k8s.io/apimachinery/pkg
parent70e7fc670be13d3877e65e160456c312e23a5806 (diff)
parent2f0bc5ff1cde9afb595868b92dd123478af9ef74 (diff)
downloadpodman-4b300a12cedabff3c57ee657afac0696cefaae0a.tar.gz
podman-4b300a12cedabff3c57ee657afac0696cefaae0a.tar.bz2
podman-4b300a12cedabff3c57ee657afac0696cefaae0a.zip
Merge pull request #6086 from containers/dependabot/go_modules/k8s.io/api-0.18.2
Bump k8s.io/api from 0.17.4 to 0.18.2
Diffstat (limited to 'vendor/k8s.io/apimachinery/pkg')
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go2
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/resource/math.go8
-rw-r--r--vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go5
-rw-r--r--vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion.go59
-rw-r--r--vendor/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go5
-rw-r--r--vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go60
-rw-r--r--vendor/k8s.io/apimachinery/pkg/apis/meta/v1/helpers.go4
-rw-r--r--vendor/k8s.io/apimachinery/pkg/apis/meta/v1/register.go17
-rw-r--r--vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go10
-rw-r--r--vendor/k8s.io/apimachinery/pkg/conversion/converter.go155
-rw-r--r--vendor/k8s.io/apimachinery/pkg/runtime/conversion.go32
-rw-r--r--vendor/k8s.io/apimachinery/pkg/runtime/converter.go122
-rw-r--r--vendor/k8s.io/apimachinery/pkg/runtime/embedded.go15
-rw-r--r--vendor/k8s.io/apimachinery/pkg/runtime/generated.pb.go60
-rw-r--r--vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.pb.go2
-rw-r--r--vendor/k8s.io/apimachinery/pkg/runtime/scheme.go45
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/clock/clock.go29
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/errors/errors.go32
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go8
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go60
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go3
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/net/http.go55
-rw-r--r--vendor/k8s.io/apimachinery/pkg/util/validation/validation.go38
-rw-r--r--vendor/k8s.io/apimachinery/pkg/watch/streamwatcher.go2
-rw-r--r--vendor/k8s.io/apimachinery/pkg/watch/watch.go10
25 files changed, 298 insertions, 540 deletions
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
index 9fca2e165..2e09f4fac 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
@@ -36,7 +36,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
+const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
func (m *Quantity) Reset() { *m = Quantity{} }
func (*Quantity) ProtoMessage() {}
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/math.go b/vendor/k8s.io/apimachinery/pkg/api/resource/math.go
index 7f63175d3..8ffcb9f09 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/resource/math.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/math.go
@@ -37,12 +37,8 @@ var (
big1024 = big.NewInt(1024)
// Commonly needed inf.Dec values-- treat as read only!
- decZero = inf.NewDec(0, 0)
- decOne = inf.NewDec(1, 0)
- decMinusOne = inf.NewDec(-1, 0)
- decThousand = inf.NewDec(1000, 0)
- dec1024 = inf.NewDec(1024, 0)
- decMinus1024 = inf.NewDec(-1024, 0)
+ decZero = inf.NewDec(0, 0)
+ decOne = inf.NewDec(1, 0)
// Largest (in magnitude) number allowed.
maxAllowed = infDecAmount{inf.NewDec((1<<63)-1, 0)} // == max int64
diff --git a/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go b/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
index 516d041da..d95e03aa9 100644
--- a/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
+++ b/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
@@ -634,6 +634,11 @@ func (q Quantity) MarshalJSON() ([]byte, error) {
return result, nil
}
+// ToUnstructured implements the value.UnstructuredConverter interface.
+func (q Quantity) ToUnstructured() interface{} {
+ return q.String()
+}
+
// UnmarshalJSON implements the json.Unmarshaller interface.
// TODO: Remove support for leading/trailing whitespace
func (q *Quantity) UnmarshalJSON(value []byte) error {
diff --git a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion.go b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion.go
index 285a41a42..b937398cd 100644
--- a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion.go
+++ b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/conversion.go
@@ -26,69 +26,10 @@ import (
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
- "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
)
-func AddConversionFuncs(scheme *runtime.Scheme) error {
- return scheme.AddConversionFuncs(
- Convert_v1_TypeMeta_To_v1_TypeMeta,
-
- Convert_v1_ListMeta_To_v1_ListMeta,
-
- Convert_v1_DeleteOptions_To_v1_DeleteOptions,
-
- Convert_intstr_IntOrString_To_intstr_IntOrString,
- Convert_Pointer_intstr_IntOrString_To_intstr_IntOrString,
- Convert_intstr_IntOrString_To_Pointer_intstr_IntOrString,
-
- Convert_Pointer_v1_Duration_To_v1_Duration,
- Convert_v1_Duration_To_Pointer_v1_Duration,
-
- Convert_Slice_string_To_v1_Time,
- Convert_Slice_string_To_Pointer_v1_Time,
-
- Convert_v1_Time_To_v1_Time,
- Convert_v1_MicroTime_To_v1_MicroTime,
-
- Convert_resource_Quantity_To_resource_Quantity,
-
- Convert_string_To_labels_Selector,
- Convert_labels_Selector_To_string,
-
- Convert_string_To_fields_Selector,
- Convert_fields_Selector_To_string,
-
- Convert_Pointer_bool_To_bool,
- Convert_bool_To_Pointer_bool,
-
- Convert_Pointer_string_To_string,
- Convert_string_To_Pointer_string,
-
- Convert_Pointer_int64_To_int,
- Convert_int_To_Pointer_int64,
-
- Convert_Pointer_int32_To_int32,
- Convert_int32_To_Pointer_int32,
-
- Convert_Pointer_int64_To_int64,
- Convert_int64_To_Pointer_int64,
-
- Convert_Pointer_float64_To_float64,
- Convert_float64_To_Pointer_float64,
-
- Convert_Map_string_To_string_To_v1_LabelSelector,
- Convert_v1_LabelSelector_To_Map_string_To_string,
-
- Convert_Slice_string_To_Slice_int32,
-
- Convert_Slice_string_To_Pointer_v1_DeletionPropagation,
-
- Convert_Slice_string_To_v1_IncludeObjectPolicy,
- )
-}
-
func Convert_Pointer_float64_To_float64(in **float64, out *float64, s conversion.Scope) error {
if *in == nil {
*out = 0
diff --git a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go
index babe8a8b5..a22b07878 100644
--- a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go
+++ b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/duration.go
@@ -49,6 +49,11 @@ func (d Duration) MarshalJSON() ([]byte, error) {
return json.Marshal(d.Duration.String())
}
+// ToUnstructured implements the value.UnstructuredConverter interface.
+func (d Duration) ToUnstructured() interface{} {
+ return d.Duration.String()
+}
+
// OpenAPISchemaType is used by the kube-openapi generator when constructing
// the OpenAPI spec of this type.
//
diff --git a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go
index 31b1d955e..3288c5649 100644
--- a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go
+++ b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go
@@ -47,7 +47,7 @@ var _ = time.Kitchen
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
+const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
func (m *APIGroup) Reset() { *m = APIGroup{} }
func (*APIGroup) ProtoMessage() {}
@@ -11004,6 +11004,7 @@ func (m *WatchEvent) Unmarshal(dAtA []byte) error {
func skipGenerated(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
+ depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
@@ -11035,10 +11036,8 @@ func skipGenerated(dAtA []byte) (n int, err error) {
break
}
}
- return iNdEx, nil
case 1:
iNdEx += 8
- return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
@@ -11059,55 +11058,30 @@ func skipGenerated(dAtA []byte) (n int, err error) {
return 0, ErrInvalidLengthGenerated
}
iNdEx += length
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenerated
- }
- return iNdEx, nil
case 3:
- for {
- var innerWire uint64
- var start int = iNdEx
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenerated
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- innerWire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- innerWireType := int(innerWire & 0x7)
- if innerWireType == 4 {
- break
- }
- next, err := skipGenerated(dAtA[start:])
- if err != nil {
- return 0, err
- }
- iNdEx = start + next
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenerated
- }
- }
- return iNdEx, nil
+ depth++
case 4:
- return iNdEx, nil
+ if depth == 0 {
+ return 0, ErrUnexpectedEndOfGroupGenerated
+ }
+ depth--
case 5:
iNdEx += 4
- return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
+ if iNdEx < 0 {
+ return 0, ErrInvalidLengthGenerated
+ }
+ if depth == 0 {
+ return iNdEx, nil
+ }
}
- panic("unreachable")
+ return 0, io.ErrUnexpectedEOF
}
var (
- ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow")
+ ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow")
+ ErrUnexpectedEndOfGroupGenerated = fmt.Errorf("proto: unexpected end of group")
)
diff --git a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/helpers.go b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/helpers.go
index ec016fd3c..ad989ad75 100644
--- a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/helpers.go
+++ b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/helpers.go
@@ -252,7 +252,9 @@ func ResetObjectMetaForStatus(meta, existingMeta Object) {
meta.SetAnnotations(existingMeta.GetAnnotations())
meta.SetFinalizers(existingMeta.GetFinalizers())
meta.SetOwnerReferences(existingMeta.GetOwnerReferences())
- meta.SetManagedFields(existingMeta.GetManagedFields())
+ // managedFields must be preserved since it's been modified to
+ // track changed fields in the status update.
+ //meta.SetManagedFields(existingMeta.GetManagedFields())
}
// MarshalJSON implements json.Marshaler
diff --git a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/register.go b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/register.go
index a7b8aa34f..c1a077178 100644
--- a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/register.go
+++ b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/register.go
@@ -53,15 +53,6 @@ var scheme = runtime.NewScheme()
// ParameterCodec knows about query parameters used with the meta v1 API spec.
var ParameterCodec = runtime.NewParameterCodec(scheme)
-func addEventConversionFuncs(scheme *runtime.Scheme) error {
- return scheme.AddConversionFuncs(
- Convert_v1_WatchEvent_To_watch_Event,
- Convert_v1_InternalEvent_To_v1_WatchEvent,
- Convert_watch_Event_To_v1_WatchEvent,
- Convert_v1_WatchEvent_To_v1_InternalEvent,
- )
-}
-
var optionsTypes = []runtime.Object{
&ListOptions{},
&ExportOptions{},
@@ -90,10 +81,8 @@ func AddToGroupVersion(scheme *runtime.Scheme, groupVersion schema.GroupVersion)
&APIResourceList{},
)
- utilruntime.Must(addEventConversionFuncs(scheme))
-
// register manually. This usually goes through the SchemeBuilder, which we cannot use here.
- utilruntime.Must(AddConversionFuncs(scheme))
+ utilruntime.Must(RegisterConversions(scheme))
utilruntime.Must(RegisterDefaults(scheme))
}
@@ -106,9 +95,7 @@ func AddMetaToScheme(scheme *runtime.Scheme) error {
&PartialObjectMetadataList{},
)
- return scheme.AddConversionFuncs(
- Convert_Slice_string_To_v1_IncludeObjectPolicy,
- )
+ return nil
}
func init() {
diff --git a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
index fe510ed9e..4a1d89cfc 100644
--- a/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
+++ b/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
@@ -153,6 +153,16 @@ func (t Time) MarshalJSON() ([]byte, error) {
return buf, nil
}
+// ToUnstructured implements the value.UnstructuredConverter interface.
+func (t Time) ToUnstructured() interface{} {
+ if t.IsZero() {
+ return nil
+ }
+ buf := make([]byte, 0, len(time.RFC3339))
+ buf = t.UTC().AppendFormat(buf, time.RFC3339)
+ return string(buf)
+}
+
// OpenAPISchemaType is used by the kube-openapi generator when constructing
// the OpenAPI spec of this type.
//
diff --git a/vendor/k8s.io/apimachinery/pkg/conversion/converter.go b/vendor/k8s.io/apimachinery/pkg/conversion/converter.go
index bc615dc3a..2d7c8bd1e 100644
--- a/vendor/k8s.io/apimachinery/pkg/conversion/converter.go
+++ b/vendor/k8s.io/apimachinery/pkg/conversion/converter.go
@@ -54,7 +54,8 @@ type Converter struct {
generatedConversionFuncs ConversionFuncs
// Set of conversions that should be treated as a no-op
- ignoredConversions map[typePair]struct{}
+ ignoredConversions map[typePair]struct{}
+ ignoredUntypedConversions map[typePair]struct{}
// This is a map from a source field type and name, to a list of destination
// field type and name.
@@ -83,17 +84,23 @@ type Converter struct {
// NewConverter creates a new Converter object.
func NewConverter(nameFn NameFunc) *Converter {
c := &Converter{
- conversionFuncs: NewConversionFuncs(),
- generatedConversionFuncs: NewConversionFuncs(),
- ignoredConversions: make(map[typePair]struct{}),
- nameFunc: nameFn,
- structFieldDests: make(map[typeNamePair][]typeNamePair),
- structFieldSources: make(map[typeNamePair][]typeNamePair),
+ conversionFuncs: NewConversionFuncs(),
+ generatedConversionFuncs: NewConversionFuncs(),
+ ignoredConversions: make(map[typePair]struct{}),
+ ignoredUntypedConversions: make(map[typePair]struct{}),
+ nameFunc: nameFn,
+ structFieldDests: make(map[typeNamePair][]typeNamePair),
+ structFieldSources: make(map[typeNamePair][]typeNamePair),
inputFieldMappingFuncs: make(map[reflect.Type]FieldMappingFunc),
inputDefaultFlags: make(map[reflect.Type]FieldMatchingFlags),
}
- c.RegisterConversionFunc(Convert_Slice_byte_To_Slice_byte)
+ c.RegisterUntypedConversionFunc(
+ (*[]byte)(nil), (*[]byte)(nil),
+ func(a, b interface{}, s Scope) error {
+ return Convert_Slice_byte_To_Slice_byte(a.(*[]byte), b.(*[]byte), s)
+ },
+ )
return c
}
@@ -131,10 +138,6 @@ type Scope interface {
// parameters, you'll run out of stack space before anything useful happens.
Convert(src, dest interface{}, flags FieldMatchingFlags) error
- // DefaultConvert performs the default conversion, without calling a conversion func
- // on the current stack frame. This makes it safe to call from a conversion func.
- DefaultConvert(src, dest interface{}, flags FieldMatchingFlags) error
-
// SrcTags and DestTags contain the struct tags that src and dest had, respectively.
// If the enclosing object was not a struct, then these will contain no tags, of course.
SrcTag() reflect.StructTag
@@ -153,31 +156,14 @@ type FieldMappingFunc func(key string, sourceTag, destTag reflect.StructTag) (so
func NewConversionFuncs() ConversionFuncs {
return ConversionFuncs{
- fns: make(map[typePair]reflect.Value),
untyped: make(map[typePair]ConversionFunc),
}
}
type ConversionFuncs struct {
- fns map[typePair]reflect.Value
untyped map[typePair]ConversionFunc
}
-// Add adds the provided conversion functions to the lookup table - they must have the signature
-// `func(type1, type2, Scope) error`. Functions are added in the order passed and will override
-// previously registered pairs.
-func (c ConversionFuncs) Add(fns ...interface{}) error {
- for _, fn := range fns {
- fv := reflect.ValueOf(fn)
- ft := fv.Type()
- if err := verifyConversionFunctionSignature(ft); err != nil {
- return err
- }
- c.fns[typePair{ft.In(0).Elem(), ft.In(1).Elem()}] = fv
- }
- return nil
-}
-
// AddUntyped adds the provided conversion function to the lookup table for the types that are
// supplied as a and b. a and b must be pointers or an error is returned. This method overwrites
// previously defined functions.
@@ -197,12 +183,6 @@ func (c ConversionFuncs) AddUntyped(a, b interface{}, fn ConversionFunc) error {
// both other and c, with other conversions taking precedence.
func (c ConversionFuncs) Merge(other ConversionFuncs) ConversionFuncs {
merged := NewConversionFuncs()
- for k, v := range c.fns {
- merged.fns[k] = v
- }
- for k, v := range other.fns {
- merged.fns[k] = v
- }
for k, v := range c.untyped {
merged.untyped[k] = v
}
@@ -290,12 +270,6 @@ func (s *scope) Convert(src, dest interface{}, flags FieldMatchingFlags) error {
return s.converter.Convert(src, dest, flags, s.meta)
}
-// DefaultConvert continues a conversion, performing a default conversion (no conversion func)
-// for the current stack frame.
-func (s *scope) DefaultConvert(src, dest interface{}, flags FieldMatchingFlags) error {
- return s.converter.DefaultConvert(src, dest, flags, s.meta)
-}
-
// SrcTag returns the tag of the struct containing the current source item, if any.
func (s *scope) SrcTag() reflect.StructTag {
return s.srcStack.top().tag
@@ -360,29 +334,6 @@ func verifyConversionFunctionSignature(ft reflect.Type) error {
return nil
}
-// RegisterConversionFunc registers a conversion func with the
-// Converter. conversionFunc must take three parameters: a pointer to the input
-// type, a pointer to the output type, and a conversion.Scope (which should be
-// used if recursive conversion calls are desired). It must return an error.
-//
-// Example:
-// c.RegisterConversionFunc(
-// func(in *Pod, out *v1.Pod, s Scope) error {
-// // conversion logic...
-// return nil
-// })
-// DEPRECATED: Will be removed in favor of RegisterUntypedConversionFunc
-func (c *Converter) RegisterConversionFunc(conversionFunc interface{}) error {
- return c.conversionFuncs.Add(conversionFunc)
-}
-
-// Similar to RegisterConversionFunc, but registers conversion function that were
-// automatically generated.
-// DEPRECATED: Will be removed in favor of RegisterGeneratedUntypedConversionFunc
-func (c *Converter) RegisterGeneratedConversionFunc(conversionFunc interface{}) error {
- return c.generatedConversionFuncs.Add(conversionFunc)
-}
-
// RegisterUntypedConversionFunc registers a function that converts between a and b by passing objects of those
// types to the provided function. The function *must* accept objects of a and b - this machinery will not enforce
// any other guarantee.
@@ -409,6 +360,7 @@ func (c *Converter) RegisterIgnoredConversion(from, to interface{}) error {
return fmt.Errorf("expected pointer arg for 'to' param 1, got: %v", typeTo)
}
c.ignoredConversions[typePair{typeFrom.Elem(), typeTo.Elem()}] = struct{}{}
+ c.ignoredUntypedConversions[typePair{typeFrom, typeTo}] = struct{}{}
return nil
}
@@ -470,18 +422,6 @@ func (c *Converter) Convert(src, dest interface{}, flags FieldMatchingFlags, met
return c.doConversion(src, dest, flags, meta, c.convert)
}
-// DefaultConvert will translate src to dest if it knows how. Both must be pointers.
-// No conversion func is used. If the default copying mechanism
-// doesn't work on this type pair, an error will be returned.
-// Read the comments on the various FieldMatchingFlags constants to understand
-// what the 'flags' parameter does.
-// 'meta' is given to allow you to pass information to conversion functions,
-// it is not used by DefaultConvert() other than storing it in the scope.
-// Not safe for objects with cyclic references!
-func (c *Converter) DefaultConvert(src, dest interface{}, flags FieldMatchingFlags, meta *Meta) error {
- return c.doConversion(src, dest, flags, meta, c.defaultConvert)
-}
-
type conversionFunc func(sv, dv reflect.Value, scope *scope) error
func (c *Converter) doConversion(src, dest interface{}, flags FieldMatchingFlags, meta *Meta, f conversionFunc) error {
@@ -491,6 +431,11 @@ func (c *Converter) doConversion(src, dest interface{}, flags FieldMatchingFlags
flags: flags,
meta: meta,
}
+
+ // ignore conversions of this type
+ if _, ok := c.ignoredUntypedConversions[pair]; ok {
+ return nil
+ }
if fn, ok := c.conversionFuncs.untyped[pair]; ok {
return fn(src, dest, scope)
}
@@ -517,33 +462,20 @@ func (c *Converter) doConversion(src, dest interface{}, flags FieldMatchingFlags
return f(sv, dv, scope)
}
-// callCustom calls 'custom' with sv & dv. custom must be a conversion function.
-func (c *Converter) callCustom(sv, dv, custom reflect.Value, scope *scope) error {
- if !sv.CanAddr() {
- sv2 := reflect.New(sv.Type())
- sv2.Elem().Set(sv)
- sv = sv2
- } else {
- sv = sv.Addr()
- }
+// callUntyped calls predefined conversion func.
+func (c *Converter) callUntyped(sv, dv reflect.Value, f ConversionFunc, scope *scope) error {
if !dv.CanAddr() {
- if !dv.CanSet() {
- return scope.errorf("can't addr or set dest.")
- }
- dvOrig := dv
- dv := reflect.New(dvOrig.Type())
- defer func() { dvOrig.Set(dv) }()
- } else {
- dv = dv.Addr()
+ return scope.errorf("cant addr dest")
}
- args := []reflect.Value{sv, dv, reflect.ValueOf(scope)}
- ret := custom.Call(args)[0].Interface()
- // This convolution is necessary because nil interfaces won't convert
- // to errors.
- if ret == nil {
- return nil
+ var svPointer reflect.Value
+ if sv.CanAddr() {
+ svPointer = sv.Addr()
+ } else {
+ svPointer = reflect.New(sv.Type())
+ svPointer.Elem().Set(sv)
}
- return ret.(error)
+ dvPointer := dv.Addr()
+ return f(svPointer.Interface(), dvPointer.Interface(), scope)
}
// convert recursively copies sv into dv, calling an appropriate conversion function if
@@ -561,27 +493,14 @@ func (c *Converter) convert(sv, dv reflect.Value, scope *scope) error {
}
// Convert sv to dv.
- if fv, ok := c.conversionFuncs.fns[pair]; ok {
- if c.Debug != nil {
- c.Debug.Logf("Calling custom conversion of '%v' to '%v'", st, dt)
- }
- return c.callCustom(sv, dv, fv, scope)
+ pair = typePair{reflect.PtrTo(sv.Type()), reflect.PtrTo(dv.Type())}
+ if f, ok := c.conversionFuncs.untyped[pair]; ok {
+ return c.callUntyped(sv, dv, f, scope)
}
- if fv, ok := c.generatedConversionFuncs.fns[pair]; ok {
- if c.Debug != nil {
- c.Debug.Logf("Calling generated conversion of '%v' to '%v'", st, dt)
- }
- return c.callCustom(sv, dv, fv, scope)
+ if f, ok := c.generatedConversionFuncs.untyped[pair]; ok {
+ return c.callUntyped(sv, dv, f, scope)
}
- return c.defaultConvert(sv, dv, scope)
-}
-
-// defaultConvert recursively copies sv into dv. no conversion function is called
-// for the current stack frame (but conversion functions may be called for nested objects)
-func (c *Converter) defaultConvert(sv, dv reflect.Value, scope *scope) error {
- dt, st := dv.Type(), sv.Type()
-
if !dv.CanSet() {
return scope.errorf("Cannot set dest. (Tried to deep copy something with unexported fields?)")
}
diff --git a/vendor/k8s.io/apimachinery/pkg/runtime/conversion.go b/vendor/k8s.io/apimachinery/pkg/runtime/conversion.go
index 0947dce73..d04d701f3 100644
--- a/vendor/k8s.io/apimachinery/pkg/runtime/conversion.go
+++ b/vendor/k8s.io/apimachinery/pkg/runtime/conversion.go
@@ -53,14 +53,6 @@ func JSONKeyMapper(key string, sourceTag, destTag reflect.StructTag) (string, st
return key, key
}
-// DefaultStringConversions are helpers for converting []string and string to real values.
-var DefaultStringConversions = []interface{}{
- Convert_Slice_string_To_string,
- Convert_Slice_string_To_int,
- Convert_Slice_string_To_bool,
- Convert_Slice_string_To_int64,
-}
-
func Convert_Slice_string_To_string(in *[]string, out *string, s conversion.Scope) error {
if len(*in) == 0 {
*out = ""
@@ -178,3 +170,27 @@ func Convert_Slice_string_To_Pointer_int64(in *[]string, out **int64, s conversi
*out = &i
return nil
}
+
+func RegisterStringConversions(s *Scheme) error {
+ if err := s.AddConversionFunc((*[]string)(nil), (*string)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_Slice_string_To_string(a.(*[]string), b.(*string), scope)
+ }); err != nil {
+ return err
+ }
+ if err := s.AddConversionFunc((*[]string)(nil), (*int)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_Slice_string_To_int(a.(*[]string), b.(*int), scope)
+ }); err != nil {
+ return err
+ }
+ if err := s.AddConversionFunc((*[]string)(nil), (*bool)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_Slice_string_To_bool(a.(*[]string), b.(*bool), scope)
+ }); err != nil {
+ return err
+ }
+ if err := s.AddConversionFunc((*[]string)(nil), (*int64)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_Slice_string_To_int64(a.(*[]string), b.(*int64), scope)
+ }); err != nil {
+ return err
+ }
+ return nil
+}
diff --git a/vendor/k8s.io/apimachinery/pkg/runtime/converter.go b/vendor/k8s.io/apimachinery/pkg/runtime/converter.go
index b3e8a53b3..918d0831d 100644
--- a/vendor/k8s.io/apimachinery/pkg/runtime/converter.go
+++ b/vendor/k8s.io/apimachinery/pkg/runtime/converter.go
@@ -17,7 +17,6 @@ limitations under the License.
package runtime
import (
- "bytes"
encodingjson "encoding/json"
"fmt"
"math"
@@ -32,6 +31,7 @@ import (
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/util/json"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
+ "sigs.k8s.io/structured-merge-diff/v3/value"
"k8s.io/klog"
)
@@ -68,13 +68,8 @@ func newFieldsCache() *fieldsCache {
}
var (
- marshalerType = reflect.TypeOf(new(encodingjson.Marshaler)).Elem()
- unmarshalerType = reflect.TypeOf(new(encodingjson.Unmarshaler)).Elem()
mapStringInterfaceType = reflect.TypeOf(map[string]interface{}{})
stringType = reflect.TypeOf(string(""))
- int64Type = reflect.TypeOf(int64(0))
- float64Type = reflect.TypeOf(float64(0))
- boolType = reflect.TypeOf(bool(false))
fieldCache = newFieldsCache()
// DefaultUnstructuredConverter performs unstructured to Go typed object conversions.
@@ -208,13 +203,9 @@ func fromUnstructured(sv, dv reflect.Value) error {
}
// Check if the object has a custom JSON marshaller/unmarshaller.
- if reflect.PtrTo(dt).Implements(unmarshalerType) {
- data, err := json.Marshal(sv.Interface())
- if err != nil {
- return fmt.Errorf("error encoding %s to json: %v", st.String(), err)
- }
- unmarshaler := dv.Addr().Interface().(encodingjson.Unmarshaler)
- return unmarshaler.UnmarshalJSON(data)
+ entry := value.TypeReflectEntryOf(dv.Type())
+ if entry.CanConvertFromUnstructured() {
+ return entry.FromUnstructured(sv, dv)
}
switch dt.Kind() {
@@ -256,6 +247,7 @@ func fieldInfoFromField(structType reflect.Type, field int) *fieldInfo {
for i := range items {
if items[i] == "omitempty" {
info.omitempty = true
+ break
}
}
}
@@ -483,112 +475,28 @@ func toUnstructuredViaJSON(obj interface{}, u *map[string]interface{}) error {
return json.Unmarshal(data, u)
}
-var (
- nullBytes = []byte("null")
- trueBytes = []byte("true")
- falseBytes = []byte("false")
-)
-
-func getMarshaler(v reflect.Value) (encodingjson.Marshaler, bool) {
- // Check value receivers if v is not a pointer and pointer receivers if v is a pointer
- if v.Type().Implements(marshalerType) {
- return v.Interface().(encodingjson.Marshaler), true
- }
- // Check pointer receivers if v is not a pointer
- if v.Kind() != reflect.Ptr && v.CanAddr() {
- v = v.Addr()
- if v.Type().Implements(marshalerType) {
- return v.Interface().(encodingjson.Marshaler), true
- }
- }
- return nil, false
-}
-
func toUnstructured(sv, dv reflect.Value) error {
- // Check if the object has a custom JSON marshaller/unmarshaller.
- if marshaler, ok := getMarshaler(sv); ok {
- if sv.Kind() == reflect.Ptr && sv.IsNil() {
- // We're done - we don't need to store anything.
- return nil
- }
-
- data, err := marshaler.MarshalJSON()
+ // Check if the object has a custom string converter.
+ entry := value.TypeReflectEntryOf(sv.Type())
+ if entry.CanConvertToUnstructured() {
+ v, err := entry.ToUnstructured(sv)
if err != nil {
return err
}
- switch {
- case len(data) == 0:
- return fmt.Errorf("error decoding from json: empty value")
-
- case bytes.Equal(data, nullBytes):
- // We're done - we don't need to store anything.
-
- case bytes.Equal(data, trueBytes):
- dv.Set(reflect.ValueOf(true))
-
- case bytes.Equal(data, falseBytes):
- dv.Set(reflect.ValueOf(false))
-
- case data[0] == '"':
- var result string
- err := json.Unmarshal(data, &result)
- if err != nil {
- return fmt.Errorf("error decoding string from json: %v", err)
- }
- dv.Set(reflect.ValueOf(result))
-
- case data[0] == '{':
- result := make(map[string]interface{})
- err := json.Unmarshal(data, &result)
- if err != nil {
- return fmt.Errorf("error decoding object from json: %v", err)
- }
- dv.Set(reflect.ValueOf(result))
-
- case data[0] == '[':
- result := make([]interface{}, 0)
- err := json.Unmarshal(data, &result)
- if err != nil {
- return fmt.Errorf("error decoding array from json: %v", err)
- }
- dv.Set(reflect.ValueOf(result))
-
- default:
- var (
- resultInt int64
- resultFloat float64
- err error
- )
- if err = json.Unmarshal(data, &resultInt); err == nil {
- dv.Set(reflect.ValueOf(resultInt))
- } else if err = json.Unmarshal(data, &resultFloat); err == nil {
- dv.Set(reflect.ValueOf(resultFloat))
- } else {
- return fmt.Errorf("error decoding number from json: %v", err)
- }
+ if v != nil {
+ dv.Set(reflect.ValueOf(v))
}
-
return nil
}
-
- st, dt := sv.Type(), dv.Type()
+ st := sv.Type()
switch st.Kind() {
case reflect.String:
- if dt.Kind() == reflect.Interface && dv.NumMethod() == 0 {
- dv.Set(reflect.New(stringType))
- }
dv.Set(reflect.ValueOf(sv.String()))
return nil
case reflect.Bool:
- if dt.Kind() == reflect.Interface && dv.NumMethod() == 0 {
- dv.Set(reflect.New(boolType))
- }
dv.Set(reflect.ValueOf(sv.Bool()))
return nil
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
- if dt.Kind() == reflect.Interface && dv.NumMethod() == 0 {
- dv.Set(reflect.New(int64Type))
- }
dv.Set(reflect.ValueOf(sv.Int()))
return nil
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
@@ -596,15 +504,9 @@ func toUnstructured(sv, dv reflect.Value) error {
if uVal > math.MaxInt64 {
return fmt.Errorf("unsigned value %d does not fit into int64 (overflow)", uVal)
}
- if dt.Kind() == reflect.Interface && dv.NumMethod() == 0 {
- dv.Set(reflect.New(int64Type))
- }
dv.Set(reflect.ValueOf(int64(uVal)))
return nil
case reflect.Float32, reflect.Float64:
- if dt.Kind() == reflect.Interface && dv.NumMethod() == 0 {
- dv.Set(reflect.New(float64Type))
- }
dv.Set(reflect.ValueOf(sv.Float()))
return nil
case reflect.Map:
diff --git a/vendor/k8s.io/apimachinery/pkg/runtime/embedded.go b/vendor/k8s.io/apimachinery/pkg/runtime/embedded.go
index db11eb8bc..7251e65f6 100644
--- a/vendor/k8s.io/apimachinery/pkg/runtime/embedded.go
+++ b/vendor/k8s.io/apimachinery/pkg/runtime/embedded.go
@@ -134,9 +134,16 @@ func Convert_runtime_RawExtension_To_runtime_Object(in *RawExtension, out *Objec
return nil
}
-func DefaultEmbeddedConversions() []interface{} {
- return []interface{}{
- Convert_runtime_Object_To_runtime_RawExtension,
- Convert_runtime_RawExtension_To_runtime_Object,
+func RegisterEmbeddedConversions(s *Scheme) error {
+ if err := s.AddConversionFunc((*Object)(nil), (*RawExtension)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_runtime_Object_To_runtime_RawExtension(a.(*Object), b.(*RawExtension), scope)
+ }); err != nil {
+ return err
}
+ if err := s.AddConversionFunc((*RawExtension)(nil), (*Object)(nil), func(a, b interface{}, scope conversion.Scope) error {
+ return Convert_runtime_RawExtension_To_runtime_Object(a.(*RawExtension), b.(*Object), scope)
+ }); err != nil {
+ return err
+ }
+ return nil
}
diff --git a/vendor/k8s.io/apimachinery/pkg/runtime/generated.pb.go b/vendor/k8s.io/apimachinery/pkg/runtime/generated.pb.go
index af2f076b8..071971817 100644
--- a/vendor/k8s.io/apimachinery/pkg/runtime/generated.pb.go
+++ b/vendor/k8s.io/apimachinery/pkg/runtime/generated.pb.go
@@ -40,7 +40,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
+const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
func (m *RawExtension) Reset() { *m = RawExtension{} }
func (*RawExtension) ProtoMessage() {}
@@ -772,6 +772,7 @@ func (m *Unknown) Unmarshal(dAtA []byte) error {
func skipGenerated(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
+ depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
@@ -803,10 +804,8 @@ func skipGenerated(dAtA []byte) (n int, err error) {
break
}
}
- return iNdEx, nil
case 1:
iNdEx += 8
- return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
@@ -827,55 +826,30 @@ func skipGenerated(dAtA []byte) (n int, err error) {
return 0, ErrInvalidLengthGenerated
}
iNdEx += length
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenerated
- }
- return iNdEx, nil
case 3:
- for {
- var innerWire uint64
- var start int = iNdEx
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenerated
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- innerWire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- innerWireType := int(innerWire & 0x7)
- if innerWireType == 4 {
- break
- }
- next, err := skipGenerated(dAtA[start:])
- if err != nil {
- return 0, err
- }
- iNdEx = start + next
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenerated
- }
- }
- return iNdEx, nil
+ depth++
case 4:
- return iNdEx, nil
+ if depth == 0 {
+ return 0, ErrUnexpectedEndOfGroupGenerated
+ }
+ depth--
case 5:
iNdEx += 4
- return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
+ if iNdEx < 0 {
+ return 0, ErrInvalidLengthGenerated
+ }
+ if depth == 0 {
+ return iNdEx, nil
+ }
}
- panic("unreachable")
+ return 0, io.ErrUnexpectedEOF
}
var (
- ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow")
+ ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow")
+ ErrUnexpectedEndOfGroupGenerated = fmt.Errorf("proto: unexpected end of group")
)
diff --git a/vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.pb.go b/vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.pb.go
index a7276649f..29d3ac45b 100644
--- a/vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.pb.go
+++ b/vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.pb.go
@@ -36,7 +36,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
+const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
func init() {
proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.proto", fileDescriptor_0462724132518e0d)
diff --git a/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go b/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go
index fd37e293a..4b739ec38 100644
--- a/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go
+++ b/vendor/k8s.io/apimachinery/pkg/runtime/scheme.go
@@ -102,10 +102,10 @@ func NewScheme() *Scheme {
}
s.converter = conversion.NewConverter(s.nameFunc)
- utilruntime.Must(s.AddConversionFuncs(DefaultEmbeddedConversions()...))
+ // Enable couple default conversions by default.
+ utilruntime.Must(RegisterEmbeddedConversions(s))
+ utilruntime.Must(RegisterStringConversions(s))
- // Enable map[string][]string conversions by default
- utilruntime.Must(s.AddConversionFuncs(DefaultStringConversions...))
utilruntime.Must(s.RegisterInputDefaults(&map[string][]string{}, JSONKeyMapper, conversion.AllowDifferentFieldTypeNames|conversion.IgnoreMissingFields))
utilruntime.Must(s.RegisterInputDefaults(&url.Values{}, JSONKeyMapper, conversion.AllowDifferentFieldTypeNames|conversion.IgnoreMissingFields))
return s
@@ -308,45 +308,6 @@ func (s *Scheme) AddIgnoredConversionType(from, to interface{}) error {
return s.converter.RegisterIgnoredConversion(from, to)
}
-// AddConversionFuncs adds functions to the list of conversion functions. The given
-// functions should know how to convert between two of your API objects, or their
-// sub-objects. We deduce how to call these functions from the types of their two
-// parameters; see the comment for Converter.Register.
-//
-// Note that, if you need to copy sub-objects that didn't change, you can use the
-// conversion.Scope object that will be passed to your conversion function.
-// Additionally, all conversions started by Scheme will set the SrcVersion and
-// DestVersion fields on the Meta object. Example:
-//
-// s.AddConversionFuncs(
-// func(in *InternalObject, out *ExternalObject, scope conversion.Scope) error {
-// // You can depend on Meta() being non-nil, and this being set to
-// // the source version, e.g., ""
-// s.Meta().SrcVersion
-// // You can depend on this being set to the destination version,
-// // e.g., "v1".
-// s.Meta().DestVersion
-// // Call scope.Convert to copy sub-fields.
-// s.Convert(&in.SubFieldThatMoved, &out.NewLocation.NewName, 0)
-// return nil
-// },
-// )
-//
-// (For more detail about conversion functions, see Converter.Register's comment.)
-//
-// Also note that the default behavior, if you don't add a conversion function, is to
-// sanely copy fields that have the same names and same type names. It's OK if the
-// destination type has extra fields, but it must not remove any. So you only need to
-// add conversion functions for things with changed/removed fields.
-func (s *Scheme) AddConversionFuncs(conversionFuncs ...interface{}) error {
- for _, f := range conversionFuncs {
- if err := s.converter.RegisterConversionFunc(f); err != nil {
- return err
- }
- }
- return nil
-}
-
// AddConversionFunc registers a function that converts between a and b by passing objects of those
// types to the provided function. The function *must* accept objects of a and b - this machinery will not enforce
// any other guarantee.
diff --git a/vendor/k8s.io/apimachinery/pkg/util/clock/clock.go b/vendor/k8s.io/apimachinery/pkg/util/clock/clock.go
index 1689e62e8..6cf13d83d 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/clock/clock.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/clock/clock.go
@@ -52,23 +52,26 @@ func (RealClock) Since(ts time.Time) time.Duration {
return time.Since(ts)
}
-// Same as time.After(d).
+// After is the same as time.After(d).
func (RealClock) After(d time.Duration) <-chan time.Time {
return time.After(d)
}
+// NewTimer returns a new Timer.
func (RealClock) NewTimer(d time.Duration) Timer {
return &realTimer{
timer: time.NewTimer(d),
}
}
+// NewTicker returns a new Ticker.
func (RealClock) NewTicker(d time.Duration) Ticker {
return &realTicker{
ticker: time.NewTicker(d),
}
}
+// Sleep pauses the RealClock for duration d.
func (RealClock) Sleep(d time.Duration) {
time.Sleep(d)
}
@@ -94,12 +97,14 @@ type fakeClockWaiter struct {
destChan chan time.Time
}
+// NewFakePassiveClock returns a new FakePassiveClock.
func NewFakePassiveClock(t time.Time) *FakePassiveClock {
return &FakePassiveClock{
time: t,
}
}
+// NewFakeClock returns a new FakeClock
func NewFakeClock(t time.Time) *FakeClock {
return &FakeClock{
FakePassiveClock: *NewFakePassiveClock(t),
@@ -120,14 +125,14 @@ func (f *FakePassiveClock) Since(ts time.Time) time.Duration {
return f.time.Sub(ts)
}
-// Sets the time.
+// SetTime sets the time on the FakePassiveClock.
func (f *FakePassiveClock) SetTime(t time.Time) {
f.lock.Lock()
defer f.lock.Unlock()
f.time = t
}
-// Fake version of time.After(d).
+// After is the Fake version of time.After(d).
func (f *FakeClock) After(d time.Duration) <-chan time.Time {
f.lock.Lock()
defer f.lock.Unlock()
@@ -140,7 +145,7 @@ func (f *FakeClock) After(d time.Duration) <-chan time.Time {
return ch
}
-// Fake version of time.NewTimer(d).
+// NewTimer is the Fake version of time.NewTimer(d).
func (f *FakeClock) NewTimer(d time.Duration) Timer {
f.lock.Lock()
defer f.lock.Unlock()
@@ -157,6 +162,7 @@ func (f *FakeClock) NewTimer(d time.Duration) Timer {
return timer
}
+// NewTicker returns a new Ticker.
func (f *FakeClock) NewTicker(d time.Duration) Ticker {
f.lock.Lock()
defer f.lock.Unlock()
@@ -174,14 +180,14 @@ func (f *FakeClock) NewTicker(d time.Duration) Ticker {
}
}
-// Move clock by Duration, notify anyone that's called After, Tick, or NewTimer
+// Step moves clock by Duration, notifies anyone that's called After, Tick, or NewTimer
func (f *FakeClock) Step(d time.Duration) {
f.lock.Lock()
defer f.lock.Unlock()
f.setTimeLocked(f.time.Add(d))
}
-// Sets the time.
+// SetTime sets the time on a FakeClock.
func (f *FakeClock) SetTime(t time.Time) {
f.lock.Lock()
defer f.lock.Unlock()
@@ -219,7 +225,7 @@ func (f *FakeClock) setTimeLocked(t time.Time) {
f.waiters = newWaiters
}
-// Returns true if After has been called on f but not yet satisfied (so you can
+// HasWaiters returns true if After has been called on f but not yet satisfied (so you can
// write race-free tests).
func (f *FakeClock) HasWaiters() bool {
f.lock.RLock()
@@ -227,6 +233,7 @@ func (f *FakeClock) HasWaiters() bool {
return len(f.waiters) > 0
}
+// Sleep pauses the FakeClock for duration d.
func (f *FakeClock) Sleep(d time.Duration) {
f.Step(d)
}
@@ -248,24 +255,25 @@ func (i *IntervalClock) Since(ts time.Time) time.Duration {
return i.Time.Sub(ts)
}
-// Unimplemented, will panic.
+// After is currently unimplemented, will panic.
// TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) After(d time.Duration) <-chan time.Time {
panic("IntervalClock doesn't implement After")
}
-// Unimplemented, will panic.
+// NewTimer is currently unimplemented, will panic.
// TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) NewTimer(d time.Duration) Timer {
panic("IntervalClock doesn't implement NewTimer")
}
-// Unimplemented, will panic.
+// NewTicker is currently unimplemented, will panic.
// TODO: make interval clock use FakeClock so this can be implemented.
func (*IntervalClock) NewTicker(d time.Duration) Ticker {
panic("IntervalClock doesn't implement NewTicker")
}
+// Sleep is currently unimplemented; will panic.
func (*IntervalClock) Sleep(d time.Duration) {
panic("IntervalClock doesn't implement Sleep")
}
@@ -355,6 +363,7 @@ func (f *fakeTimer) Reset(d time.Duration) bool {
return false
}
+// Ticker defines the Ticker interface
type Ticker interface {
C() <-chan time.Time
Stop()
diff --git a/vendor/k8s.io/apimachinery/pkg/util/errors/errors.go b/vendor/k8s.io/apimachinery/pkg/util/errors/errors.go
index 62a73f34e..5bafc218e 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/errors/errors.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/errors/errors.go
@@ -28,9 +28,14 @@ type MessageCountMap map[string]int
// Aggregate represents an object that contains multiple errors, but does not
// necessarily have singular semantic meaning.
+// The aggregate can be used with `errors.Is()` to check for the occurrence of
+// a specific error type.
+// Errors.As() is not supported, because the caller presumably cares about a
+// specific error of potentially multiple that match the given type.
type Aggregate interface {
error
Errors() []error
+ Is(error) bool
}
// NewAggregate converts a slice of errors into an Aggregate interface, which
@@ -71,16 +76,17 @@ func (agg aggregate) Error() string {
}
seenerrs := sets.NewString()
result := ""
- agg.visit(func(err error) {
+ agg.visit(func(err error) bool {
msg := err.Error()
if seenerrs.Has(msg) {
- return
+ return false
}
seenerrs.Insert(msg)
if len(seenerrs) > 1 {
result += ", "
}
result += msg
+ return false
})
if len(seenerrs) == 1 {
return result
@@ -88,19 +94,33 @@ func (agg aggregate) Error() string {
return "[" + result + "]"
}
-func (agg aggregate) visit(f func(err error)) {
+func (agg aggregate) Is(target error) bool {
+ return agg.visit(func(err error) bool {
+ return errors.Is(err, target)
+ })
+}
+
+func (agg aggregate) visit(f func(err error) bool) bool {
for _, err := range agg {
switch err := err.(type) {
case aggregate:
- err.visit(f)
+ if match := err.visit(f); match {
+ return match
+ }
case Aggregate:
for _, nestedErr := range err.Errors() {
- f(nestedErr)
+ if match := f(nestedErr); match {
+ return match
+ }
}
default:
- f(err)
+ if match := f(err); match {
+ return match
+ }
}
}
+
+ return false
}
// Errors is part of the Aggregate interface.
diff --git a/vendor/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go b/vendor/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go
index 50d9a366f..9d5fdeece 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go
@@ -123,15 +123,11 @@ func negotiateProtocol(clientProtocols, serverProtocols []string) string {
func Handshake(req *http.Request, w http.ResponseWriter, serverProtocols []string) (string, error) {
clientProtocols := req.Header[http.CanonicalHeaderKey(HeaderProtocolVersion)]
if len(clientProtocols) == 0 {
- // Kube 1.0 clients didn't support subprotocol negotiation.
- // TODO require clientProtocols once Kube 1.0 is no longer supported
- return "", nil
+ return "", fmt.Errorf("unable to upgrade: %s is required", HeaderProtocolVersion)
}
if len(serverProtocols) == 0 {
- // Kube 1.0 servers didn't support subprotocol negotiation. This is mainly for testing.
- // TODO require serverProtocols once Kube 1.0 is no longer supported
- return "", nil
+ panic(fmt.Errorf("unable to upgrade: serverProtocols is required"))
}
negotiatedProtocol := negotiateProtocol(clientProtocols, serverProtocols)
diff --git a/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go b/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
index 64cbc7703..ec1cb70f2 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
@@ -38,7 +38,7 @@ var _ = math.Inf
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
-const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
+const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
func (m *IntOrString) Reset() { *m = IntOrString{} }
func (*IntOrString) ProtoMessage() {}
@@ -289,6 +289,7 @@ func (m *IntOrString) Unmarshal(dAtA []byte) error {
func skipGenerated(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
+ depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
@@ -320,10 +321,8 @@ func skipGenerated(dAtA []byte) (n int, err error) {
break
}
}
- return iNdEx, nil
case 1:
iNdEx += 8
- return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
@@ -344,55 +343,30 @@ func skipGenerated(dAtA []byte) (n int, err error) {
return 0, ErrInvalidLengthGenerated
}
iNdEx += length
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenerated
- }
- return iNdEx, nil
case 3:
- for {
- var innerWire uint64
- var start int = iNdEx
- for shift := uint(0); ; shift += 7 {
- if shift >= 64 {
- return 0, ErrIntOverflowGenerated
- }
- if iNdEx >= l {
- return 0, io.ErrUnexpectedEOF
- }
- b := dAtA[iNdEx]
- iNdEx++
- innerWire |= (uint64(b) & 0x7F) << shift
- if b < 0x80 {
- break
- }
- }
- innerWireType := int(innerWire & 0x7)
- if innerWireType == 4 {
- break
- }
- next, err := skipGenerated(dAtA[start:])
- if err != nil {
- return 0, err
- }
- iNdEx = start + next
- if iNdEx < 0 {
- return 0, ErrInvalidLengthGenerated
- }
- }
- return iNdEx, nil
+ depth++
case 4:
- return iNdEx, nil
+ if depth == 0 {
+ return 0, ErrUnexpectedEndOfGroupGenerated
+ }
+ depth--
case 5:
iNdEx += 4
- return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
+ if iNdEx < 0 {
+ return 0, ErrInvalidLengthGenerated
+ }
+ if depth == 0 {
+ return iNdEx, nil
+ }
}
- panic("unreachable")
+ return 0, io.ErrUnexpectedEOF
}
var (
- ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling")
- ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow")
+ ErrInvalidLengthGenerated = fmt.Errorf("proto: negative length found during unmarshaling")
+ ErrIntOverflowGenerated = fmt.Errorf("proto: integer overflow")
+ ErrUnexpectedEndOfGroupGenerated = fmt.Errorf("proto: unexpected end of group")
)
diff --git a/vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go b/vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go
index 2df629555..cb974dcf7 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go
@@ -97,7 +97,8 @@ func (intstr *IntOrString) String() string {
}
// IntValue returns the IntVal if type Int, or if
-// it is a String, will attempt a conversion to int.
+// it is a String, will attempt a conversion to int,
+// returning 0 if a parsing error occurs.
func (intstr *IntOrString) IntValue() int {
if intstr.Type == String {
i, _ := strconv.Atoi(intstr.StrVal)
diff --git a/vendor/k8s.io/apimachinery/pkg/util/net/http.go b/vendor/k8s.io/apimachinery/pkg/util/net/http.go
index f9540c63b..7449cbb0a 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/net/http.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/net/http.go
@@ -55,6 +55,12 @@ func JoinPreservingTrailingSlash(elem ...string) string {
return result
}
+// IsTimeout returns true if the given error is a network timeout error
+func IsTimeout(err error) bool {
+ neterr, ok := err.(net.Error)
+ return ok && neterr != nil && neterr.Timeout()
+}
+
// IsProbableEOF returns true if the given error resembles a connection termination
// scenario that would justify assuming that the watch is empty.
// These errors are what the Go http stack returns back to us which are general
@@ -206,13 +212,17 @@ func GetHTTPClient(req *http.Request) string {
return "unknown"
}
-// SourceIPs splits the comma separated X-Forwarded-For header or returns the X-Real-Ip header or req.RemoteAddr,
-// in that order, ignoring invalid IPs. It returns nil if all of these are empty or invalid.
+// SourceIPs splits the comma separated X-Forwarded-For header and joins it with
+// the X-Real-Ip header and/or req.RemoteAddr, ignoring invalid IPs.
+// The X-Real-Ip is omitted if it's already present in the X-Forwarded-For chain.
+// The req.RemoteAddr is always the last IP in the returned list.
+// It returns nil if all of these are empty or invalid.
func SourceIPs(req *http.Request) []net.IP {
+ var srcIPs []net.IP
+
hdr := req.Header
// First check the X-Forwarded-For header for requests via proxy.
hdrForwardedFor := hdr.Get("X-Forwarded-For")
- forwardedForIPs := []net.IP{}
if hdrForwardedFor != "" {
// X-Forwarded-For can be a csv of IPs in case of multiple proxies.
// Use the first valid one.
@@ -220,38 +230,49 @@ func SourceIPs(req *http.Request) []net.IP {
for _, part := range parts {
ip := net.ParseIP(strings.TrimSpace(part))
if ip != nil {
- forwardedForIPs = append(forwardedForIPs, ip)
+ srcIPs = append(srcIPs, ip)
}
}
}
- if len(forwardedForIPs) > 0 {
- return forwardedForIPs
- }
// Try the X-Real-Ip header.
hdrRealIp := hdr.Get("X-Real-Ip")
if hdrRealIp != "" {
ip := net.ParseIP(hdrRealIp)
- if ip != nil {
- return []net.IP{ip}
+ // Only append the X-Real-Ip if it's not already contained in the X-Forwarded-For chain.
+ if ip != nil && !containsIP(srcIPs, ip) {
+ srcIPs = append(srcIPs, ip)
}
}
- // Fallback to Remote Address in request, which will give the correct client IP when there is no proxy.
+ // Always include the request Remote Address as it cannot be easily spoofed.
+ var remoteIP net.IP
// Remote Address in Go's HTTP server is in the form host:port so we need to split that first.
host, _, err := net.SplitHostPort(req.RemoteAddr)
if err == nil {
- if remoteIP := net.ParseIP(host); remoteIP != nil {
- return []net.IP{remoteIP}
- }
+ remoteIP = net.ParseIP(host)
}
-
// Fallback if Remote Address was just IP.
- if remoteIP := net.ParseIP(req.RemoteAddr); remoteIP != nil {
- return []net.IP{remoteIP}
+ if remoteIP == nil {
+ remoteIP = net.ParseIP(req.RemoteAddr)
+ }
+
+ // Don't duplicate remote IP if it's already the last address in the chain.
+ if remoteIP != nil && (len(srcIPs) == 0 || !remoteIP.Equal(srcIPs[len(srcIPs)-1])) {
+ srcIPs = append(srcIPs, remoteIP)
}
- return nil
+ return srcIPs
+}
+
+// Checks whether the given IP address is contained in the list of IPs.
+func containsIP(ips []net.IP, ip net.IP) bool {
+ for _, v := range ips {
+ if v.Equal(ip) {
+ return true
+ }
+ }
+ return false
}
// Extracts and returns the clients IP from the given request.
diff --git a/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go b/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go
index 8e1907c2a..915231f2e 100644
--- a/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go
+++ b/vendor/k8s.io/apimachinery/pkg/util/validation/validation.go
@@ -109,6 +109,44 @@ func IsFullyQualifiedDomainName(fldPath *field.Path, name string) field.ErrorLis
return allErrors
}
+// Allowed characters in an HTTP Path as defined by RFC 3986. A HTTP path may
+// contain:
+// * unreserved characters (alphanumeric, '-', '.', '_', '~')
+// * percent-encoded octets
+// * sub-delims ("!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "=")
+// * a colon character (":")
+const httpPathFmt string = `[A-Za-z0-9/\-._~%!$&'()*+,;=:]+`
+
+var httpPathRegexp = regexp.MustCompile("^" + httpPathFmt + "$")
+
+// IsDomainPrefixedPath checks if the given string is a domain-prefixed path
+// (e.g. acme.io/foo). All characters before the first "/" must be a valid
+// subdomain as defined by RFC 1123. All characters trailing the first "/" must
+// be valid HTTP Path characters as defined by RFC 3986.
+func IsDomainPrefixedPath(fldPath *field.Path, dpPath string) field.ErrorList {
+ var allErrs field.ErrorList
+ if len(dpPath) == 0 {
+ return append(allErrs, field.Required(fldPath, ""))
+ }
+
+ segments := strings.SplitN(dpPath, "/", 2)
+ if len(segments) != 2 || len(segments[0]) == 0 || len(segments[1]) == 0 {
+ return append(allErrs, field.Invalid(fldPath, dpPath, "must be a domain-prefixed path (such as \"acme.io/foo\")"))
+ }
+
+ host := segments[0]
+ for _, err := range IsDNS1123Subdomain(host) {
+ allErrs = append(allErrs, field.Invalid(fldPath, host, err))
+ }
+
+ path := segments[1]
+ if !httpPathRegexp.MatchString(path) {
+ return append(allErrs, field.Invalid(fldPath, path, RegexError("Invalid path", httpPathFmt)))
+ }
+
+ return allErrs
+}
+
const labelValueFmt string = "(" + qualifiedNameFmt + ")?"
const labelValueErrMsg string = "a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character"
diff --git a/vendor/k8s.io/apimachinery/pkg/watch/streamwatcher.go b/vendor/k8s.io/apimachinery/pkg/watch/streamwatcher.go
index 8af256eb1..4269a836a 100644
--- a/vendor/k8s.io/apimachinery/pkg/watch/streamwatcher.go
+++ b/vendor/k8s.io/apimachinery/pkg/watch/streamwatcher.go
@@ -113,7 +113,7 @@ func (sw *StreamWatcher) receive() {
case io.ErrUnexpectedEOF:
klog.V(1).Infof("Unexpected EOF during watch stream event decoding: %v", err)
default:
- if net.IsProbableEOF(err) {
+ if net.IsProbableEOF(err) || net.IsTimeout(err) {
klog.V(5).Infof("Unable to decode an event from the watch stream: %v", err)
} else {
sw.result <- Event{
diff --git a/vendor/k8s.io/apimachinery/pkg/watch/watch.go b/vendor/k8s.io/apimachinery/pkg/watch/watch.go
index 3945be3ae..988aba3ed 100644
--- a/vendor/k8s.io/apimachinery/pkg/watch/watch.go
+++ b/vendor/k8s.io/apimachinery/pkg/watch/watch.go
@@ -90,7 +90,7 @@ func (w emptyWatch) ResultChan() <-chan Event {
// FakeWatcher lets you test anything that consumes a watch.Interface; threadsafe.
type FakeWatcher struct {
result chan Event
- Stopped bool
+ stopped bool
sync.Mutex
}
@@ -110,24 +110,24 @@ func NewFakeWithChanSize(size int, blocking bool) *FakeWatcher {
func (f *FakeWatcher) Stop() {
f.Lock()
defer f.Unlock()
- if !f.Stopped {
+ if !f.stopped {
klog.V(4).Infof("Stopping fake watcher.")
close(f.result)
- f.Stopped = true
+ f.stopped = true
}
}
func (f *FakeWatcher) IsStopped() bool {
f.Lock()
defer f.Unlock()
- return f.Stopped
+ return f.stopped
}
// Reset prepares the watcher to be reused.
func (f *FakeWatcher) Reset() {
f.Lock()
defer f.Unlock()
- f.Stopped = false
+ f.stopped = false
f.result = make(chan Event)
}