Update dependencies for k8s v1.29.0
This commit is contained in:
37
client/vendor/k8s.io/apimachinery/pkg/api/meta/conditions.go
generated
vendored
37
client/vendor/k8s.io/apimachinery/pkg/api/meta/conditions.go
generated
vendored
@@ -22,14 +22,15 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// SetStatusCondition sets the corresponding condition in conditions to newCondition.
|
||||
// SetStatusCondition sets the corresponding condition in conditions to newCondition and returns true
|
||||
// if the conditions are changed by this call.
|
||||
// conditions must be non-nil.
|
||||
// 1. if the condition of the specified type already exists (all fields of the existing condition are updated to
|
||||
// newCondition, LastTransitionTime is set to now if the new status differs from the old status)
|
||||
// 2. if a condition of the specified type does not exist (LastTransitionTime is set to now() if unset, and newCondition is appended)
|
||||
func SetStatusCondition(conditions *[]metav1.Condition, newCondition metav1.Condition) {
|
||||
func SetStatusCondition(conditions *[]metav1.Condition, newCondition metav1.Condition) (changed bool) {
|
||||
if conditions == nil {
|
||||
return
|
||||
return false
|
||||
}
|
||||
existingCondition := FindStatusCondition(*conditions, newCondition.Type)
|
||||
if existingCondition == nil {
|
||||
@@ -37,7 +38,7 @@ func SetStatusCondition(conditions *[]metav1.Condition, newCondition metav1.Cond
|
||||
newCondition.LastTransitionTime = metav1.NewTime(time.Now())
|
||||
}
|
||||
*conditions = append(*conditions, newCondition)
|
||||
return
|
||||
return true
|
||||
}
|
||||
|
||||
if existingCondition.Status != newCondition.Status {
|
||||
@@ -47,18 +48,31 @@ func SetStatusCondition(conditions *[]metav1.Condition, newCondition metav1.Cond
|
||||
} else {
|
||||
existingCondition.LastTransitionTime = metav1.NewTime(time.Now())
|
||||
}
|
||||
changed = true
|
||||
}
|
||||
|
||||
existingCondition.Reason = newCondition.Reason
|
||||
existingCondition.Message = newCondition.Message
|
||||
existingCondition.ObservedGeneration = newCondition.ObservedGeneration
|
||||
if existingCondition.Reason != newCondition.Reason {
|
||||
existingCondition.Reason = newCondition.Reason
|
||||
changed = true
|
||||
}
|
||||
if existingCondition.Message != newCondition.Message {
|
||||
existingCondition.Message = newCondition.Message
|
||||
changed = true
|
||||
}
|
||||
if existingCondition.ObservedGeneration != newCondition.ObservedGeneration {
|
||||
existingCondition.ObservedGeneration = newCondition.ObservedGeneration
|
||||
changed = true
|
||||
}
|
||||
|
||||
return changed
|
||||
}
|
||||
|
||||
// RemoveStatusCondition removes the corresponding conditionType from conditions.
|
||||
// RemoveStatusCondition removes the corresponding conditionType from conditions if present. Returns
|
||||
// true if it was present and got removed.
|
||||
// conditions must be non-nil.
|
||||
func RemoveStatusCondition(conditions *[]metav1.Condition, conditionType string) {
|
||||
func RemoveStatusCondition(conditions *[]metav1.Condition, conditionType string) (removed bool) {
|
||||
if conditions == nil || len(*conditions) == 0 {
|
||||
return
|
||||
return false
|
||||
}
|
||||
newConditions := make([]metav1.Condition, 0, len(*conditions)-1)
|
||||
for _, condition := range *conditions {
|
||||
@@ -67,7 +81,10 @@ func RemoveStatusCondition(conditions *[]metav1.Condition, conditionType string)
|
||||
}
|
||||
}
|
||||
|
||||
removed = len(*conditions) != len(newConditions)
|
||||
*conditions = newConditions
|
||||
|
||||
return removed
|
||||
}
|
||||
|
||||
// FindStatusCondition finds the conditionType in conditions.
|
||||
|
38
client/vendor/k8s.io/apimachinery/pkg/api/resource/amount.go
generated
vendored
38
client/vendor/k8s.io/apimachinery/pkg/api/resource/amount.go
generated
vendored
@@ -203,6 +203,44 @@ func (a *int64Amount) Sub(b int64Amount) bool {
|
||||
return a.Add(int64Amount{value: -b.value, scale: b.scale})
|
||||
}
|
||||
|
||||
// Mul multiplies the provided b to the current amount, or
|
||||
// returns false if overflow or underflow would result.
|
||||
func (a *int64Amount) Mul(b int64) bool {
|
||||
switch {
|
||||
case a.value == 0:
|
||||
return true
|
||||
case b == 0:
|
||||
a.value = 0
|
||||
a.scale = 0
|
||||
return true
|
||||
case a.scale == 0:
|
||||
c, ok := int64Multiply(a.value, b)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
a.value = c
|
||||
case a.scale > 0:
|
||||
c, ok := int64Multiply(a.value, b)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if _, ok = positiveScaleInt64(c, a.scale); !ok {
|
||||
return false
|
||||
}
|
||||
a.value = c
|
||||
default:
|
||||
c, ok := int64Multiply(a.value, b)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if _, ok = negativeScaleInt64(c, -a.scale); !ok {
|
||||
return false
|
||||
}
|
||||
a.value = c
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// AsScale adjusts this amount to set a minimum scale, rounding up, and returns true iff no precision
|
||||
// was lost. (1.1e5).AsScale(5) would return 1.1e5, but (1.1e5).AsScale(6) would return 1e6.
|
||||
func (a int64Amount) AsScale(scale Scale) (int64Amount, bool) {
|
||||
|
10
client/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
10
client/vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
@@ -592,6 +592,16 @@ func (q *Quantity) Sub(y Quantity) {
|
||||
q.ToDec().d.Dec.Sub(q.d.Dec, y.AsDec())
|
||||
}
|
||||
|
||||
// Mul multiplies the provided y to the current value.
|
||||
// It will return false if the result is inexact. Otherwise, it will return true.
|
||||
func (q *Quantity) Mul(y int64) bool {
|
||||
q.s = ""
|
||||
if q.d.Dec == nil && q.i.Mul(y) {
|
||||
return true
|
||||
}
|
||||
return q.ToDec().d.Dec.Mul(q.d.Dec, inf.NewDec(y, inf.Scale(0))).UnscaledBig().IsInt64()
|
||||
}
|
||||
|
||||
// Cmp returns 0 if the quantity is equal to y, -1 if the quantity is less than y, or 1 if the
|
||||
// quantity is greater than y.
|
||||
func (q *Quantity) Cmp(y Quantity) int {
|
||||
|
2
client/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/helpers.go
generated
vendored
2
client/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/helpers.go
generated
vendored
@@ -173,7 +173,7 @@ func NestedStringMap(obj map[string]interface{}, fields ...string) (map[string]s
|
||||
if str, ok := v.(string); ok {
|
||||
strMap[k] = str
|
||||
} else {
|
||||
return nil, false, fmt.Errorf("%v accessor error: contains non-string key in the map: %v is of the type %T, expected string", jsonPath(fields), v, v)
|
||||
return nil, false, fmt.Errorf("%v accessor error: contains non-string value in the map under key %q: %v is of the type %T, expected string", jsonPath(fields), k, v, v)
|
||||
}
|
||||
}
|
||||
return strMap, true, nil
|
||||
|
23
client/vendor/k8s.io/apimachinery/pkg/runtime/helper.go
generated
vendored
23
client/vendor/k8s.io/apimachinery/pkg/runtime/helper.go
generated
vendored
@@ -257,3 +257,26 @@ func (d WithoutVersionDecoder) Decode(data []byte, defaults *schema.GroupVersion
|
||||
}
|
||||
return obj, gvk, err
|
||||
}
|
||||
|
||||
type encoderWithAllocator struct {
|
||||
encoder EncoderWithAllocator
|
||||
memAllocator MemoryAllocator
|
||||
}
|
||||
|
||||
// NewEncoderWithAllocator returns a new encoder
|
||||
func NewEncoderWithAllocator(e EncoderWithAllocator, a MemoryAllocator) Encoder {
|
||||
return &encoderWithAllocator{
|
||||
encoder: e,
|
||||
memAllocator: a,
|
||||
}
|
||||
}
|
||||
|
||||
// Encode writes the provided object to the nested writer
|
||||
func (e *encoderWithAllocator) Encode(obj Object, w io.Writer) error {
|
||||
return e.encoder.EncodeWithAllocator(obj, w, e.memAllocator)
|
||||
}
|
||||
|
||||
// Identifier returns identifier of this encoder.
|
||||
func (e *encoderWithAllocator) Identifier() Identifier {
|
||||
return e.encoder.Identifier()
|
||||
}
|
||||
|
20
client/vendor/k8s.io/apimachinery/pkg/runtime/serializer/streaming/streaming.go
generated
vendored
20
client/vendor/k8s.io/apimachinery/pkg/runtime/serializer/streaming/streaming.go
generated
vendored
@@ -134,23 +134,3 @@ func (e *encoder) Encode(obj runtime.Object) error {
|
||||
e.buf.Reset()
|
||||
return err
|
||||
}
|
||||
|
||||
type encoderWithAllocator struct {
|
||||
writer io.Writer
|
||||
encoder runtime.EncoderWithAllocator
|
||||
memAllocator runtime.MemoryAllocator
|
||||
}
|
||||
|
||||
// NewEncoderWithAllocator returns a new streaming encoder
|
||||
func NewEncoderWithAllocator(w io.Writer, e runtime.EncoderWithAllocator, a runtime.MemoryAllocator) Encoder {
|
||||
return &encoderWithAllocator{
|
||||
writer: w,
|
||||
encoder: e,
|
||||
memAllocator: a,
|
||||
}
|
||||
}
|
||||
|
||||
// Encode writes the provided object to the nested writer
|
||||
func (e *encoderWithAllocator) Encode(obj runtime.Object) error {
|
||||
return e.encoder.EncodeWithAllocator(obj, e.writer, e.memAllocator)
|
||||
}
|
||||
|
13
client/vendor/k8s.io/apimachinery/pkg/util/cache/lruexpirecache.go
generated
vendored
13
client/vendor/k8s.io/apimachinery/pkg/util/cache/lruexpirecache.go
generated
vendored
@@ -136,6 +136,19 @@ func (c *LRUExpireCache) Remove(key interface{}) {
|
||||
delete(c.entries, key)
|
||||
}
|
||||
|
||||
// RemoveAll removes all keys that match predicate.
|
||||
func (c *LRUExpireCache) RemoveAll(predicate func(key any) bool) {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
|
||||
for key, element := range c.entries {
|
||||
if predicate(key) {
|
||||
c.evictionList.Remove(element)
|
||||
delete(c.entries, key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Keys returns all unexpired keys in the cache.
|
||||
//
|
||||
// Keep in mind that subsequent calls to Get() for any of the returned keys
|
||||
|
6
client/vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go
generated
vendored
6
client/vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go
generated
vendored
@@ -72,14 +72,14 @@ func FromString(val string) IntOrString {
|
||||
return IntOrString{Type: String, StrVal: val}
|
||||
}
|
||||
|
||||
// Parse the given string and try to convert it to an integer before
|
||||
// Parse the given string and try to convert it to an int32 integer before
|
||||
// setting it as a string value.
|
||||
func Parse(val string) IntOrString {
|
||||
i, err := strconv.Atoi(val)
|
||||
i, err := strconv.ParseInt(val, 10, 32)
|
||||
if err != nil {
|
||||
return FromString(val)
|
||||
}
|
||||
return FromInt(i)
|
||||
return FromInt32(int32(i))
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaller interface.
|
||||
|
9
client/vendor/k8s.io/apimachinery/pkg/util/managedfields/internal/structuredmerge.go
generated
vendored
9
client/vendor/k8s.io/apimachinery/pkg/util/managedfields/internal/structuredmerge.go
generated
vendored
@@ -25,6 +25,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/structured-merge-diff/v4/fieldpath"
|
||||
"sigs.k8s.io/structured-merge-diff/v4/merge"
|
||||
"sigs.k8s.io/structured-merge-diff/v4/typed"
|
||||
)
|
||||
|
||||
type structuredMergeManager struct {
|
||||
@@ -95,11 +96,11 @@ func (f *structuredMergeManager) Update(liveObj, newObj runtime.Object, managed
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to convert live object (%v) to proper version: %v", objectGVKNN(liveObj), err)
|
||||
}
|
||||
newObjTyped, err := f.typeConverter.ObjectToTyped(newObjVersioned)
|
||||
newObjTyped, err := f.typeConverter.ObjectToTyped(newObjVersioned, typed.AllowDuplicates)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to convert new object (%v) to smd typed: %v", objectGVKNN(newObjVersioned), err)
|
||||
}
|
||||
liveObjTyped, err := f.typeConverter.ObjectToTyped(liveObjVersioned)
|
||||
liveObjTyped, err := f.typeConverter.ObjectToTyped(liveObjVersioned, typed.AllowDuplicates)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to convert live object (%v) to smd typed: %v", objectGVKNN(liveObjVersioned), err)
|
||||
}
|
||||
@@ -139,11 +140,13 @@ func (f *structuredMergeManager) Apply(liveObj, patchObj runtime.Object, managed
|
||||
return nil, nil, fmt.Errorf("failed to convert live object (%v) to proper version: %v", objectGVKNN(liveObj), err)
|
||||
}
|
||||
|
||||
// Don't allow duplicates in the applied object.
|
||||
patchObjTyped, err := f.typeConverter.ObjectToTyped(patchObj)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to create typed patch object (%v): %v", objectGVKNN(patchObj), err)
|
||||
}
|
||||
liveObjTyped, err := f.typeConverter.ObjectToTyped(liveObjVersioned)
|
||||
|
||||
liveObjTyped, err := f.typeConverter.ObjectToTyped(liveObjVersioned, typed.AllowDuplicates)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to create typed live object (%v): %v", objectGVKNN(liveObjVersioned), err)
|
||||
}
|
||||
|
14
client/vendor/k8s.io/apimachinery/pkg/util/managedfields/internal/typeconverter.go
generated
vendored
14
client/vendor/k8s.io/apimachinery/pkg/util/managedfields/internal/typeconverter.go
generated
vendored
@@ -32,7 +32,7 @@ import (
|
||||
// TypeConverter allows you to convert from runtime.Object to
|
||||
// typed.TypedValue and the other way around.
|
||||
type TypeConverter interface {
|
||||
ObjectToTyped(runtime.Object) (*typed.TypedValue, error)
|
||||
ObjectToTyped(runtime.Object, ...typed.ValidationOptions) (*typed.TypedValue, error)
|
||||
TypedToObject(*typed.TypedValue) (runtime.Object, error)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ func NewTypeConverter(openapiSpec map[string]*spec.Schema, preserveUnknownFields
|
||||
return &typeConverter{parser: tr}, nil
|
||||
}
|
||||
|
||||
func (c *typeConverter) ObjectToTyped(obj runtime.Object) (*typed.TypedValue, error) {
|
||||
func (c *typeConverter) ObjectToTyped(obj runtime.Object, opts ...typed.ValidationOptions) (*typed.TypedValue, error) {
|
||||
gvk := obj.GetObjectKind().GroupVersionKind()
|
||||
t := c.parser[gvk]
|
||||
if t == nil {
|
||||
@@ -62,9 +62,9 @@ func (c *typeConverter) ObjectToTyped(obj runtime.Object) (*typed.TypedValue, er
|
||||
}
|
||||
switch o := obj.(type) {
|
||||
case *unstructured.Unstructured:
|
||||
return t.FromUnstructured(o.UnstructuredContent())
|
||||
return t.FromUnstructured(o.UnstructuredContent(), opts...)
|
||||
default:
|
||||
return t.FromStructured(obj)
|
||||
return t.FromStructured(obj, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,12 +84,12 @@ func NewDeducedTypeConverter() TypeConverter {
|
||||
}
|
||||
|
||||
// ObjectToTyped converts an object into a TypedValue with a "deduced type".
|
||||
func (deducedTypeConverter) ObjectToTyped(obj runtime.Object) (*typed.TypedValue, error) {
|
||||
func (deducedTypeConverter) ObjectToTyped(obj runtime.Object, opts ...typed.ValidationOptions) (*typed.TypedValue, error) {
|
||||
switch o := obj.(type) {
|
||||
case *unstructured.Unstructured:
|
||||
return typed.DeducedParseableType.FromUnstructured(o.UnstructuredContent())
|
||||
return typed.DeducedParseableType.FromUnstructured(o.UnstructuredContent(), opts...)
|
||||
default:
|
||||
return typed.DeducedParseableType.FromStructured(obj)
|
||||
return typed.DeducedParseableType.FromStructured(obj, opts...)
|
||||
}
|
||||
}
|
||||
|
||||
|
15
client/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go
generated
vendored
15
client/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go
generated
vendored
@@ -126,14 +126,17 @@ type rudimentaryErrorBackoff struct {
|
||||
// OnError will block if it is called more often than the embedded period time.
|
||||
// This will prevent overly tight hot error loops.
|
||||
func (r *rudimentaryErrorBackoff) OnError(error) {
|
||||
now := time.Now() // start the timer before acquiring the lock
|
||||
r.lastErrorTimeLock.Lock()
|
||||
defer r.lastErrorTimeLock.Unlock()
|
||||
d := time.Since(r.lastErrorTime)
|
||||
if d < r.minPeriod {
|
||||
// If the time moves backwards for any reason, do nothing
|
||||
time.Sleep(r.minPeriod - d)
|
||||
}
|
||||
d := now.Sub(r.lastErrorTime)
|
||||
r.lastErrorTime = time.Now()
|
||||
r.lastErrorTimeLock.Unlock()
|
||||
|
||||
// Do not sleep with the lock held because that causes all callers of HandleError to block.
|
||||
// We only want the current goroutine to block.
|
||||
// A negative or zero duration causes time.Sleep to return immediately.
|
||||
// If the time moves backwards for any reason, do nothing.
|
||||
time.Sleep(r.minPeriod - d)
|
||||
}
|
||||
|
||||
// GetCaller returns the caller of the function that calls it.
|
||||
|
89
client/vendor/k8s.io/apimachinery/pkg/util/strategicpatch/meta.go
generated
vendored
89
client/vendor/k8s.io/apimachinery/pkg/util/strategicpatch/meta.go
generated
vendored
@@ -20,12 +20,17 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/mergepatch"
|
||||
forkedjson "k8s.io/apimachinery/third_party/forked/golang/json"
|
||||
openapi "k8s.io/kube-openapi/pkg/util/proto"
|
||||
"k8s.io/kube-openapi/pkg/validation/spec"
|
||||
)
|
||||
|
||||
const patchMergeKey = "x-kubernetes-patch-merge-key"
|
||||
const patchStrategy = "x-kubernetes-patch-strategy"
|
||||
|
||||
type PatchMeta struct {
|
||||
patchStrategies []string
|
||||
patchMergeKey string
|
||||
@@ -148,6 +153,90 @@ func GetTagStructTypeOrDie(dataStruct interface{}) reflect.Type {
|
||||
return t
|
||||
}
|
||||
|
||||
type PatchMetaFromOpenAPIV3 struct {
|
||||
// SchemaList is required to resolve OpenAPI V3 references
|
||||
SchemaList map[string]*spec.Schema
|
||||
Schema *spec.Schema
|
||||
}
|
||||
|
||||
func (s PatchMetaFromOpenAPIV3) traverse(key string) (PatchMetaFromOpenAPIV3, error) {
|
||||
if s.Schema == nil {
|
||||
return PatchMetaFromOpenAPIV3{}, nil
|
||||
}
|
||||
if len(s.Schema.Properties) == 0 {
|
||||
return PatchMetaFromOpenAPIV3{}, fmt.Errorf("unable to find api field \"%s\"", key)
|
||||
}
|
||||
subschema, ok := s.Schema.Properties[key]
|
||||
if !ok {
|
||||
return PatchMetaFromOpenAPIV3{}, fmt.Errorf("unable to find api field \"%s\"", key)
|
||||
}
|
||||
return PatchMetaFromOpenAPIV3{SchemaList: s.SchemaList, Schema: &subschema}, nil
|
||||
}
|
||||
|
||||
func resolve(l *PatchMetaFromOpenAPIV3) error {
|
||||
if len(l.Schema.AllOf) > 0 {
|
||||
l.Schema = &l.Schema.AllOf[0]
|
||||
}
|
||||
if refString := l.Schema.Ref.String(); refString != "" {
|
||||
str := strings.TrimPrefix(refString, "#/components/schemas/")
|
||||
sch, ok := l.SchemaList[str]
|
||||
if ok {
|
||||
l.Schema = sch
|
||||
} else {
|
||||
return fmt.Errorf("unable to resolve %s in OpenAPI V3", refString)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s PatchMetaFromOpenAPIV3) LookupPatchMetadataForStruct(key string) (LookupPatchMeta, PatchMeta, error) {
|
||||
l, err := s.traverse(key)
|
||||
if err != nil {
|
||||
return l, PatchMeta{}, err
|
||||
}
|
||||
p := PatchMeta{}
|
||||
f, ok := l.Schema.Extensions[patchMergeKey]
|
||||
if ok {
|
||||
p.SetPatchMergeKey(f.(string))
|
||||
}
|
||||
g, ok := l.Schema.Extensions[patchStrategy]
|
||||
if ok {
|
||||
p.SetPatchStrategies(strings.Split(g.(string), ","))
|
||||
}
|
||||
|
||||
err = resolve(&l)
|
||||
return l, p, err
|
||||
}
|
||||
|
||||
func (s PatchMetaFromOpenAPIV3) LookupPatchMetadataForSlice(key string) (LookupPatchMeta, PatchMeta, error) {
|
||||
l, err := s.traverse(key)
|
||||
if err != nil {
|
||||
return l, PatchMeta{}, err
|
||||
}
|
||||
p := PatchMeta{}
|
||||
f, ok := l.Schema.Extensions[patchMergeKey]
|
||||
if ok {
|
||||
p.SetPatchMergeKey(f.(string))
|
||||
}
|
||||
g, ok := l.Schema.Extensions[patchStrategy]
|
||||
if ok {
|
||||
p.SetPatchStrategies(strings.Split(g.(string), ","))
|
||||
}
|
||||
if l.Schema.Items != nil {
|
||||
l.Schema = l.Schema.Items.Schema
|
||||
}
|
||||
err = resolve(&l)
|
||||
return l, p, err
|
||||
}
|
||||
|
||||
func (s PatchMetaFromOpenAPIV3) Name() string {
|
||||
schema := s.Schema
|
||||
if len(schema.Type) > 0 {
|
||||
return strings.Join(schema.Type, "")
|
||||
}
|
||||
return "Struct"
|
||||
}
|
||||
|
||||
type PatchMetaFromOpenAPI struct {
|
||||
Schema openapi.Schema
|
||||
}
|
||||
|
4
client/vendor/k8s.io/apimachinery/pkg/util/validation/field/errors.go
generated
vendored
4
client/vendor/k8s.io/apimachinery/pkg/util/validation/field/errors.go
generated
vendored
@@ -200,12 +200,12 @@ func Invalid(field *Path, value interface{}, detail string) *Error {
|
||||
// NotSupported returns a *Error indicating "unsupported value".
|
||||
// This is used to report unknown values for enumerated fields (e.g. a list of
|
||||
// valid values).
|
||||
func NotSupported(field *Path, value interface{}, validValues []string) *Error {
|
||||
func NotSupported[T ~string](field *Path, value interface{}, validValues []T) *Error {
|
||||
detail := ""
|
||||
if len(validValues) > 0 {
|
||||
quotedValues := make([]string, len(validValues))
|
||||
for i, v := range validValues {
|
||||
quotedValues[i] = strconv.Quote(v)
|
||||
quotedValues[i] = strconv.Quote(fmt.Sprint(v))
|
||||
}
|
||||
detail = "supported values: " + strings.Join(quotedValues, ", ")
|
||||
}
|
||||
|
38
client/vendor/k8s.io/apimachinery/pkg/util/wait/loop.go
generated
vendored
38
client/vendor/k8s.io/apimachinery/pkg/util/wait/loop.go
generated
vendored
@@ -40,6 +40,10 @@ func loopConditionUntilContext(ctx context.Context, t Timer, immediate, sliding
|
||||
var timeCh <-chan time.Time
|
||||
doneCh := ctx.Done()
|
||||
|
||||
if !sliding {
|
||||
timeCh = t.C()
|
||||
}
|
||||
|
||||
// if immediate is true the condition is
|
||||
// guaranteed to be executed at least once,
|
||||
// if we haven't requested immediate execution, delay once
|
||||
@@ -50,17 +54,27 @@ func loopConditionUntilContext(ctx context.Context, t Timer, immediate, sliding
|
||||
}(); err != nil || ok {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if sliding {
|
||||
timeCh = t.C()
|
||||
}
|
||||
|
||||
for {
|
||||
|
||||
// Wait for either the context to be cancelled or the next invocation be called
|
||||
select {
|
||||
case <-doneCh:
|
||||
return ctx.Err()
|
||||
case <-timeCh:
|
||||
}
|
||||
}
|
||||
|
||||
for {
|
||||
// checking ctx.Err() is slightly faster than checking a select
|
||||
// IMPORTANT: Because there is no channel priority selection in golang
|
||||
// it is possible for very short timers to "win" the race in the previous select
|
||||
// repeatedly even when the context has been canceled. We therefore must
|
||||
// explicitly check for context cancellation on every loop and exit if true to
|
||||
// guarantee that we don't invoke condition more than once after context has
|
||||
// been cancelled.
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -77,21 +91,5 @@ func loopConditionUntilContext(ctx context.Context, t Timer, immediate, sliding
|
||||
if sliding {
|
||||
t.Next()
|
||||
}
|
||||
|
||||
if timeCh == nil {
|
||||
timeCh = t.C()
|
||||
}
|
||||
|
||||
// NOTE: b/c there is no priority selection in golang
|
||||
// it is possible for this to race, meaning we could
|
||||
// trigger t.C and doneCh, and t.C select falls through.
|
||||
// In order to mitigate we re-check doneCh at the beginning
|
||||
// of every loop to guarantee at-most one extra execution
|
||||
// of condition.
|
||||
select {
|
||||
case <-doneCh:
|
||||
return ctx.Err()
|
||||
case <-timeCh:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user