update dependencies (#6267)
Signed-off-by: hongming <coder.scala@gmail.com>
This commit is contained in:
165
vendor/k8s.io/apimachinery/pkg/api/meta/testrestmapper/test_restmapper.go
generated
vendored
Normal file
165
vendor/k8s.io/apimachinery/pkg/api/meta/testrestmapper/test_restmapper.go
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
Copyright 2018 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 testrestmapper
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
)
|
||||
|
||||
// TestOnlyStaticRESTMapper returns a union RESTMapper of all known types with priorities chosen in the following order:
|
||||
// 1. legacy kube group preferred version, extensions preferred version, metrics preferred version, legacy
|
||||
// kube any version, extensions any version, metrics any version, all other groups alphabetical preferred version,
|
||||
// all other groups alphabetical.
|
||||
//
|
||||
// TODO callers of this method should be updated to build their own specific restmapper based on their scheme for their tests
|
||||
// TODO the things being tested are related to whether various cases are handled, not tied to the particular types being checked.
|
||||
func TestOnlyStaticRESTMapper(scheme *runtime.Scheme, versionPatterns ...schema.GroupVersion) meta.RESTMapper {
|
||||
unionMapper := meta.MultiRESTMapper{}
|
||||
unionedGroups := sets.NewString()
|
||||
for _, enabledVersion := range scheme.PrioritizedVersionsAllGroups() {
|
||||
if !unionedGroups.Has(enabledVersion.Group) {
|
||||
unionedGroups.Insert(enabledVersion.Group)
|
||||
unionMapper = append(unionMapper, newRESTMapper(enabledVersion.Group, scheme))
|
||||
}
|
||||
}
|
||||
|
||||
if len(versionPatterns) != 0 {
|
||||
resourcePriority := []schema.GroupVersionResource{}
|
||||
kindPriority := []schema.GroupVersionKind{}
|
||||
for _, versionPriority := range versionPatterns {
|
||||
resourcePriority = append(resourcePriority, versionPriority.WithResource(meta.AnyResource))
|
||||
kindPriority = append(kindPriority, versionPriority.WithKind(meta.AnyKind))
|
||||
}
|
||||
|
||||
return meta.PriorityRESTMapper{Delegate: unionMapper, ResourcePriority: resourcePriority, KindPriority: kindPriority}
|
||||
}
|
||||
|
||||
prioritizedGroups := []string{"", "extensions", "metrics"}
|
||||
resourcePriority, kindPriority := prioritiesForGroups(scheme, prioritizedGroups...)
|
||||
|
||||
prioritizedGroupsSet := sets.NewString(prioritizedGroups...)
|
||||
remainingGroups := sets.String{}
|
||||
for _, enabledVersion := range scheme.PrioritizedVersionsAllGroups() {
|
||||
if !prioritizedGroupsSet.Has(enabledVersion.Group) {
|
||||
remainingGroups.Insert(enabledVersion.Group)
|
||||
}
|
||||
}
|
||||
|
||||
remainingResourcePriority, remainingKindPriority := prioritiesForGroups(scheme, remainingGroups.List()...)
|
||||
resourcePriority = append(resourcePriority, remainingResourcePriority...)
|
||||
kindPriority = append(kindPriority, remainingKindPriority...)
|
||||
|
||||
return meta.PriorityRESTMapper{Delegate: unionMapper, ResourcePriority: resourcePriority, KindPriority: kindPriority}
|
||||
}
|
||||
|
||||
// prioritiesForGroups returns the resource and kind priorities for a PriorityRESTMapper, preferring the preferred version of each group first,
|
||||
// then any non-preferred version of the group second.
|
||||
func prioritiesForGroups(scheme *runtime.Scheme, groups ...string) ([]schema.GroupVersionResource, []schema.GroupVersionKind) {
|
||||
resourcePriority := []schema.GroupVersionResource{}
|
||||
kindPriority := []schema.GroupVersionKind{}
|
||||
|
||||
for _, group := range groups {
|
||||
availableVersions := scheme.PrioritizedVersionsForGroup(group)
|
||||
if len(availableVersions) > 0 {
|
||||
resourcePriority = append(resourcePriority, availableVersions[0].WithResource(meta.AnyResource))
|
||||
kindPriority = append(kindPriority, availableVersions[0].WithKind(meta.AnyKind))
|
||||
}
|
||||
}
|
||||
for _, group := range groups {
|
||||
resourcePriority = append(resourcePriority, schema.GroupVersionResource{Group: group, Version: meta.AnyVersion, Resource: meta.AnyResource})
|
||||
kindPriority = append(kindPriority, schema.GroupVersionKind{Group: group, Version: meta.AnyVersion, Kind: meta.AnyKind})
|
||||
}
|
||||
|
||||
return resourcePriority, kindPriority
|
||||
}
|
||||
|
||||
func newRESTMapper(group string, scheme *runtime.Scheme) meta.RESTMapper {
|
||||
mapper := meta.NewDefaultRESTMapper(scheme.PrioritizedVersionsForGroup(group))
|
||||
for _, gv := range scheme.PrioritizedVersionsForGroup(group) {
|
||||
for kind := range scheme.KnownTypes(gv) {
|
||||
if ignoredKinds.Has(kind) {
|
||||
continue
|
||||
}
|
||||
scope := meta.RESTScopeNamespace
|
||||
if rootScopedKinds[gv.WithKind(kind).GroupKind()] {
|
||||
scope = meta.RESTScopeRoot
|
||||
}
|
||||
mapper.Add(gv.WithKind(kind), scope)
|
||||
}
|
||||
}
|
||||
|
||||
return mapper
|
||||
}
|
||||
|
||||
// hardcoded is good enough for the test we're running
|
||||
var rootScopedKinds = map[schema.GroupKind]bool{
|
||||
{Group: "admission.k8s.io", Kind: "AdmissionReview"}: true,
|
||||
|
||||
{Group: "admissionregistration.k8s.io", Kind: "ValidatingWebhookConfiguration"}: true,
|
||||
{Group: "admissionregistration.k8s.io", Kind: "MutatingWebhookConfiguration"}: true,
|
||||
|
||||
{Group: "authentication.k8s.io", Kind: "TokenReview"}: true,
|
||||
|
||||
{Group: "authorization.k8s.io", Kind: "SubjectAccessReview"}: true,
|
||||
{Group: "authorization.k8s.io", Kind: "SelfSubjectAccessReview"}: true,
|
||||
{Group: "authorization.k8s.io", Kind: "SelfSubjectRulesReview"}: true,
|
||||
|
||||
{Group: "certificates.k8s.io", Kind: "CertificateSigningRequest"}: true,
|
||||
|
||||
{Group: "", Kind: "Node"}: true,
|
||||
{Group: "", Kind: "Namespace"}: true,
|
||||
{Group: "", Kind: "PersistentVolume"}: true,
|
||||
{Group: "", Kind: "ComponentStatus"}: true,
|
||||
|
||||
{Group: "rbac.authorization.k8s.io", Kind: "ClusterRole"}: true,
|
||||
{Group: "rbac.authorization.k8s.io", Kind: "ClusterRoleBinding"}: true,
|
||||
|
||||
{Group: "scheduling.k8s.io", Kind: "PriorityClass"}: true,
|
||||
|
||||
{Group: "storage.k8s.io", Kind: "StorageClass"}: true,
|
||||
{Group: "storage.k8s.io", Kind: "VolumeAttachment"}: true,
|
||||
|
||||
{Group: "apiextensions.k8s.io", Kind: "CustomResourceDefinition"}: true,
|
||||
|
||||
{Group: "apiserver.k8s.io", Kind: "AdmissionConfiguration"}: true,
|
||||
|
||||
{Group: "audit.k8s.io", Kind: "Event"}: true,
|
||||
{Group: "audit.k8s.io", Kind: "Policy"}: true,
|
||||
|
||||
{Group: "apiregistration.k8s.io", Kind: "APIService"}: true,
|
||||
|
||||
{Group: "metrics.k8s.io", Kind: "NodeMetrics"}: true,
|
||||
|
||||
{Group: "wardle.example.com", Kind: "Fischer"}: true,
|
||||
}
|
||||
|
||||
// hardcoded is good enough for the test we're running
|
||||
var ignoredKinds = sets.NewString(
|
||||
"ListOptions",
|
||||
"DeleteOptions",
|
||||
"Status",
|
||||
"PodLogOptions",
|
||||
"PodExecOptions",
|
||||
"PodAttachOptions",
|
||||
"PodPortForwardOptions",
|
||||
"PodProxyOptions",
|
||||
"NodeProxyOptions",
|
||||
"ServiceProxyOptions",
|
||||
)
|
||||
43
vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
generated
vendored
43
vendor/k8s.io/apimachinery/pkg/api/resource/generated.pb.go
generated
vendored
@@ -15,7 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto
|
||||
// source: k8s.io/apimachinery/pkg/api/resource/generated.proto
|
||||
|
||||
package resource
|
||||
|
||||
@@ -41,7 +41,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
func (m *Quantity) Reset() { *m = Quantity{} }
|
||||
func (*Quantity) ProtoMessage() {}
|
||||
func (*Quantity) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_612bba87bd70906c, []int{0}
|
||||
return fileDescriptor_7288c78ff45111e9, []int{0}
|
||||
}
|
||||
func (m *Quantity) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Quantity.Unmarshal(m, b)
|
||||
@@ -64,7 +64,7 @@ var xxx_messageInfo_Quantity proto.InternalMessageInfo
|
||||
func (m *QuantityValue) Reset() { *m = QuantityValue{} }
|
||||
func (*QuantityValue) ProtoMessage() {}
|
||||
func (*QuantityValue) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_612bba87bd70906c, []int{1}
|
||||
return fileDescriptor_7288c78ff45111e9, []int{1}
|
||||
}
|
||||
func (m *QuantityValue) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_QuantityValue.Unmarshal(m, b)
|
||||
@@ -90,25 +90,24 @@ func init() {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/api/resource/generated.proto", fileDescriptor_612bba87bd70906c)
|
||||
proto.RegisterFile("k8s.io/apimachinery/pkg/api/resource/generated.proto", fileDescriptor_7288c78ff45111e9)
|
||||
}
|
||||
|
||||
var fileDescriptor_612bba87bd70906c = []byte{
|
||||
// 254 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xf2, 0xcd, 0xb6, 0x28, 0xd6,
|
||||
0xcb, 0xcc, 0xd7, 0xcf, 0x2e, 0x4d, 0x4a, 0x2d, 0xca, 0x4b, 0x2d, 0x49, 0x2d, 0xd6, 0x2f, 0x4b,
|
||||
0xcd, 0x4b, 0xc9, 0x2f, 0xd2, 0x87, 0x4a, 0x24, 0x16, 0x64, 0xe6, 0x26, 0x26, 0x67, 0x64, 0xe6,
|
||||
0xa5, 0x16, 0x55, 0xea, 0x17, 0x64, 0xa7, 0x83, 0x04, 0xf4, 0x8b, 0x52, 0x8b, 0xf3, 0x4b, 0x8b,
|
||||
0x92, 0x53, 0xf5, 0xd3, 0x53, 0xf3, 0x52, 0x8b, 0x12, 0x4b, 0x52, 0x53, 0xf4, 0x0a, 0x8a, 0xf2,
|
||||
0x4b, 0xf2, 0x85, 0x54, 0x20, 0xba, 0xf4, 0x90, 0x75, 0xe9, 0x15, 0x64, 0xa7, 0x83, 0x04, 0xf4,
|
||||
0x60, 0xba, 0xa4, 0x74, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xd3,
|
||||
0xf3, 0xd3, 0xf3, 0xf5, 0xc1, 0x9a, 0x93, 0x4a, 0xd3, 0xc0, 0x3c, 0x30, 0x07, 0xcc, 0x82, 0x18,
|
||||
0xaa, 0x64, 0xc1, 0xc5, 0x11, 0x58, 0x9a, 0x98, 0x57, 0x92, 0x59, 0x52, 0x29, 0x24, 0xc6, 0xc5,
|
||||
0x56, 0x5c, 0x52, 0x94, 0x99, 0x97, 0x2e, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x19, 0x04, 0xe5, 0x59,
|
||||
0x89, 0xcc, 0x58, 0x20, 0xcf, 0xd0, 0xb1, 0x50, 0x9e, 0x61, 0xc2, 0x42, 0x79, 0x86, 0x05, 0x0b,
|
||||
0xe5, 0x19, 0x1a, 0xee, 0x28, 0x30, 0x28, 0xd9, 0x72, 0xf1, 0xc2, 0x74, 0x86, 0x25, 0xe6, 0x94,
|
||||
0xa6, 0x92, 0xa6, 0xdd, 0xc9, 0xeb, 0xc4, 0x43, 0x39, 0x86, 0x0b, 0x0f, 0xe5, 0x18, 0x6e, 0x3c,
|
||||
0x94, 0x63, 0x68, 0x78, 0x24, 0xc7, 0x78, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x37,
|
||||
0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0x43, 0x94, 0x0a, 0x31, 0x21,
|
||||
0x05, 0x08, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x70, 0x98, 0xa3, 0x69, 0x01, 0x00, 0x00,
|
||||
var fileDescriptor_7288c78ff45111e9 = []byte{
|
||||
// 234 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0xc9, 0xb6, 0x28, 0xd6,
|
||||
0xcb, 0xcc, 0xd7, 0x4f, 0x2c, 0xc8, 0xcc, 0x4d, 0x4c, 0xce, 0xc8, 0xcc, 0x4b, 0x2d, 0xaa, 0xd4,
|
||||
0x2f, 0xc8, 0x4e, 0x07, 0x09, 0xe8, 0x17, 0xa5, 0x16, 0xe7, 0x97, 0x16, 0x25, 0xa7, 0xea, 0xa7,
|
||||
0xa7, 0xe6, 0xa5, 0x16, 0x25, 0x96, 0xa4, 0xa6, 0xe8, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xa9,
|
||||
0x40, 0x74, 0xe9, 0x21, 0xeb, 0xd2, 0x2b, 0xc8, 0x4e, 0x07, 0x09, 0xe8, 0xc1, 0x74, 0x49, 0xe9,
|
||||
0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0xa7, 0xe7, 0xa7, 0xe7, 0xeb,
|
||||
0x83, 0x35, 0x27, 0x95, 0xa6, 0x81, 0x79, 0x60, 0x0e, 0x98, 0x05, 0x31, 0x54, 0xc9, 0x82, 0x8b,
|
||||
0x23, 0xb0, 0x34, 0x31, 0xaf, 0x24, 0xb3, 0xa4, 0x52, 0x48, 0x8c, 0x8b, 0xad, 0xb8, 0xa4, 0x28,
|
||||
0x33, 0x2f, 0x5d, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x08, 0xca, 0xb3, 0x12, 0x99, 0xb1, 0x40,
|
||||
0x9e, 0xa1, 0x63, 0xa1, 0x3c, 0xc3, 0x84, 0x85, 0xf2, 0x0c, 0x0b, 0x16, 0xca, 0x33, 0x34, 0xdc,
|
||||
0x51, 0x60, 0x50, 0xb2, 0xe5, 0xe2, 0x85, 0xe9, 0x0c, 0x4b, 0xcc, 0x29, 0x4d, 0x25, 0x4d, 0xbb,
|
||||
0x93, 0xd7, 0x89, 0x87, 0x72, 0x0c, 0x17, 0x1e, 0xca, 0x31, 0xdc, 0x78, 0x28, 0xc7, 0xd0, 0xf0,
|
||||
0x48, 0x8e, 0xf1, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x6f, 0x3c, 0x92, 0x63, 0x7c,
|
||||
0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x28, 0x15, 0x62, 0x42, 0x0a, 0x10, 0x00, 0x00,
|
||||
0xff, 0xff, 0x50, 0x91, 0xd0, 0x9c, 0x50, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
29
vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
29
vendor/k8s.io/apimachinery/pkg/api/resource/quantity.go
generated
vendored
@@ -25,6 +25,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
cbor "k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct"
|
||||
|
||||
inf "gopkg.in/inf.v0"
|
||||
)
|
||||
|
||||
@@ -683,6 +685,12 @@ func (q Quantity) MarshalJSON() ([]byte, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (q Quantity) MarshalCBOR() ([]byte, error) {
|
||||
// The call to String() should never return the string "<nil>" because the receiver's
|
||||
// address will never be nil.
|
||||
return cbor.Marshal(q.String())
|
||||
}
|
||||
|
||||
// ToUnstructured implements the value.UnstructuredConverter interface.
|
||||
func (q Quantity) ToUnstructured() interface{} {
|
||||
return q.String()
|
||||
@@ -711,6 +719,27 @@ func (q *Quantity) UnmarshalJSON(value []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *Quantity) UnmarshalCBOR(value []byte) error {
|
||||
var s *string
|
||||
if err := cbor.Unmarshal(value, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if s == nil {
|
||||
q.d.Dec = nil
|
||||
q.i = int64Amount{}
|
||||
return nil
|
||||
}
|
||||
|
||||
parsed, err := ParseQuantity(strings.TrimSpace(*s))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*q = parsed
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewDecimalQuantity returns a new Quantity representing the given
|
||||
// value in the given format.
|
||||
func NewDecimalQuantity(b inf.Dec, format Format) *Quantity {
|
||||
|
||||
11
vendor/k8s.io/apimachinery/pkg/api/validation/OWNERS
generated
vendored
Normal file
11
vendor/k8s.io/apimachinery/pkg/api/validation/OWNERS
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
# Disable inheritance as this is an api owners file
|
||||
options:
|
||||
no_parent_owners: true
|
||||
approvers:
|
||||
- api-approvers
|
||||
reviewers:
|
||||
- api-reviewers
|
||||
labels:
|
||||
- kind/api-change
|
||||
13
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/controller_ref.go
generated
vendored
13
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/controller_ref.go
generated
vendored
@@ -18,6 +18,7 @@ package v1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
// IsControlledBy checks if the object has a controllerRef set to the given owner
|
||||
@@ -36,10 +37,14 @@ func GetControllerOf(controllee Object) *OwnerReference {
|
||||
return nil
|
||||
}
|
||||
cp := *ref
|
||||
cp.Controller = ptr.To(*ref.Controller)
|
||||
if ref.BlockOwnerDeletion != nil {
|
||||
cp.BlockOwnerDeletion = ptr.To(*ref.BlockOwnerDeletion)
|
||||
}
|
||||
return &cp
|
||||
}
|
||||
|
||||
// GetControllerOf returns a pointer to the controllerRef if controllee has a controller
|
||||
// GetControllerOfNoCopy returns a pointer to the controllerRef if controllee has a controller
|
||||
func GetControllerOfNoCopy(controllee Object) *OwnerReference {
|
||||
refs := controllee.GetOwnerReferences()
|
||||
for i := range refs {
|
||||
@@ -52,14 +57,12 @@ func GetControllerOfNoCopy(controllee Object) *OwnerReference {
|
||||
|
||||
// NewControllerRef creates an OwnerReference pointing to the given owner.
|
||||
func NewControllerRef(owner Object, gvk schema.GroupVersionKind) *OwnerReference {
|
||||
blockOwnerDeletion := true
|
||||
isController := true
|
||||
return &OwnerReference{
|
||||
APIVersion: gvk.GroupVersion().String(),
|
||||
Kind: gvk.Kind,
|
||||
Name: owner.GetName(),
|
||||
UID: owner.GetUID(),
|
||||
BlockOwnerDeletion: &blockOwnerDeletion,
|
||||
Controller: &isController,
|
||||
BlockOwnerDeletion: ptr.To(true),
|
||||
Controller: ptr.To(true),
|
||||
}
|
||||
}
|
||||
|
||||
704
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go
generated
vendored
704
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.pb.go
generated
vendored
File diff suppressed because it is too large
Load Diff
45
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto
generated
vendored
45
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto
generated
vendored
@@ -34,6 +34,7 @@ message APIGroup {
|
||||
optional string name = 1;
|
||||
|
||||
// versions are the versions supported in this group.
|
||||
// +listType=atomic
|
||||
repeated GroupVersionForDiscovery versions = 2;
|
||||
|
||||
// preferredVersion is the version preferred by the API server, which
|
||||
@@ -49,6 +50,7 @@ message APIGroup {
|
||||
// For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP.
|
||||
// Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated ServerAddressByClientCIDR serverAddressByClientCIDRs = 4;
|
||||
}
|
||||
|
||||
@@ -56,6 +58,7 @@ message APIGroup {
|
||||
// /apis.
|
||||
message APIGroupList {
|
||||
// groups is a list of APIGroup.
|
||||
// +listType=atomic
|
||||
repeated APIGroup groups = 1;
|
||||
}
|
||||
|
||||
@@ -88,9 +91,11 @@ message APIResource {
|
||||
optional Verbs verbs = 4;
|
||||
|
||||
// shortNames is a list of suggested short names of the resource.
|
||||
// +listType=atomic
|
||||
repeated string shortNames = 5;
|
||||
|
||||
// categories is a list of the grouped resources this resource belongs to (e.g. 'all')
|
||||
// +listType=atomic
|
||||
repeated string categories = 7;
|
||||
|
||||
// The hash value of the storage version, the version this resource is
|
||||
@@ -112,6 +117,7 @@ message APIResourceList {
|
||||
optional string groupVersion = 1;
|
||||
|
||||
// resources contains the name of the resources and if they are namespaced.
|
||||
// +listType=atomic
|
||||
repeated APIResource resources = 2;
|
||||
}
|
||||
|
||||
@@ -122,6 +128,7 @@ message APIResourceList {
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
message APIVersions {
|
||||
// versions are the api versions that are available.
|
||||
// +listType=atomic
|
||||
repeated string versions = 1;
|
||||
|
||||
// a map of client CIDR to server address that is serving this group.
|
||||
@@ -131,6 +138,7 @@ message APIVersions {
|
||||
// The server returns only those CIDRs that it thinks that the client can match.
|
||||
// For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP.
|
||||
// Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.
|
||||
// +listType=atomic
|
||||
repeated ServerAddressByClientCIDR serverAddressByClientCIDRs = 2;
|
||||
}
|
||||
|
||||
@@ -145,6 +153,7 @@ message ApplyOptions {
|
||||
// request. Valid values are:
|
||||
// - All: all dry run stages will be processed
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated string dryRun = 1;
|
||||
|
||||
// Force is going to "force" Apply requests. It means user will
|
||||
@@ -235,6 +244,7 @@ message CreateOptions {
|
||||
// request. Valid values are:
|
||||
// - All: all dry run stages will be processed
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated string dryRun = 1;
|
||||
|
||||
// fieldManager is a name associated with the actor or entity
|
||||
@@ -303,6 +313,7 @@ message DeleteOptions {
|
||||
// request. Valid values are:
|
||||
// - All: all dry run stages will be processed
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated string dryRun = 5;
|
||||
}
|
||||
|
||||
@@ -313,6 +324,25 @@ message Duration {
|
||||
optional int64 duration = 1;
|
||||
}
|
||||
|
||||
// FieldSelectorRequirement is a selector that contains values, a key, and an operator that
|
||||
// relates the key and values.
|
||||
message FieldSelectorRequirement {
|
||||
// key is the field selector key that the requirement applies to.
|
||||
optional string key = 1;
|
||||
|
||||
// operator represents a key's relationship to a set of values.
|
||||
// Valid operators are In, NotIn, Exists, DoesNotExist.
|
||||
// The list of operators may grow in the future.
|
||||
optional string operator = 2;
|
||||
|
||||
// values is an array of string values.
|
||||
// If the operator is In or NotIn, the values array must be non-empty.
|
||||
// If the operator is Exists or DoesNotExist, the values array must be empty.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated string values = 3;
|
||||
}
|
||||
|
||||
// FieldsV1 stores a set of fields in a data structure like a Trie, in JSON format.
|
||||
//
|
||||
// Each key is either a '.' representing the field itself, and will always map to an empty set,
|
||||
@@ -418,6 +448,7 @@ message LabelSelector {
|
||||
|
||||
// matchExpressions is a list of label selector requirements. The requirements are ANDed.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated LabelSelectorRequirement matchExpressions = 2;
|
||||
}
|
||||
|
||||
@@ -436,6 +467,7 @@ message LabelSelectorRequirement {
|
||||
// the values array must be empty. This array is replaced during a strategic
|
||||
// merge patch.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated string values = 3;
|
||||
}
|
||||
|
||||
@@ -447,7 +479,7 @@ message List {
|
||||
optional ListMeta metadata = 1;
|
||||
|
||||
// List of objects
|
||||
repeated k8s.io.apimachinery.pkg.runtime.RawExtension items = 2;
|
||||
repeated .k8s.io.apimachinery.pkg.runtime.RawExtension items = 2;
|
||||
}
|
||||
|
||||
// ListMeta describes metadata that synthetic resources must have, including lists and
|
||||
@@ -788,6 +820,8 @@ message ObjectMeta {
|
||||
// +optional
|
||||
// +patchMergeKey=uid
|
||||
// +patchStrategy=merge
|
||||
// +listType=map
|
||||
// +listMapKey=uid
|
||||
repeated OwnerReference ownerReferences = 13;
|
||||
|
||||
// Must be empty before the object is deleted from the registry. Each entry
|
||||
@@ -805,6 +839,7 @@ message ObjectMeta {
|
||||
// are not vulnerable to ordering changes in the list.
|
||||
// +optional
|
||||
// +patchStrategy=merge
|
||||
// +listType=set
|
||||
repeated string finalizers = 14;
|
||||
|
||||
// ManagedFields maps workflow-id and version to the set of fields
|
||||
@@ -816,6 +851,7 @@ message ObjectMeta {
|
||||
// workflow used when modifying the object.
|
||||
//
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated ManagedFieldsEntry managedFields = 17;
|
||||
}
|
||||
|
||||
@@ -890,6 +926,7 @@ message PatchOptions {
|
||||
// request. Valid values are:
|
||||
// - All: all dry run stages will be processed
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated string dryRun = 1;
|
||||
|
||||
// Force is going to "force" Apply requests. It means user will
|
||||
@@ -943,6 +980,7 @@ message Preconditions {
|
||||
// For example: "/healthz", "/apis".
|
||||
message RootPaths {
|
||||
// paths are the paths available at root.
|
||||
// +listType=atomic
|
||||
repeated string paths = 1;
|
||||
}
|
||||
|
||||
@@ -985,6 +1023,7 @@ message Status {
|
||||
// is not guaranteed to conform to any schema except that defined by
|
||||
// the reason type.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
optional StatusDetails details = 5;
|
||||
|
||||
// Suggested HTTP return code for this status, 0 if not set.
|
||||
@@ -1049,6 +1088,7 @@ message StatusDetails {
|
||||
// The Causes array includes more details associated with the StatusReason
|
||||
// failure. Not all StatusReasons may provide detailed causes.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated StatusCause causes = 4;
|
||||
|
||||
// If specified, the time in seconds before the operation should be retried. Some errors may indicate
|
||||
@@ -1135,6 +1175,7 @@ message UpdateOptions {
|
||||
// request. Valid values are:
|
||||
// - All: all dry run stages will be processed
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
repeated string dryRun = 1;
|
||||
|
||||
// fieldManager is a name associated with the actor or entity
|
||||
@@ -1187,6 +1228,6 @@ message WatchEvent {
|
||||
// * If Type is Deleted: the state of the object immediately before deletion.
|
||||
// * If Type is Error: *Status is recommended; other types may make sense
|
||||
// depending on context.
|
||||
optional k8s.io.apimachinery.pkg.runtime.RawExtension object = 2;
|
||||
optional .k8s.io.apimachinery.pkg.runtime.RawExtension object = 2;
|
||||
}
|
||||
|
||||
|
||||
83
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/helpers.go
generated
vendored
83
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/helpers.go
generated
vendored
@@ -24,8 +24,10 @@ import (
|
||||
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
cbor "k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct"
|
||||
"k8s.io/apimachinery/pkg/selection"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
utiljson "k8s.io/apimachinery/pkg/util/json"
|
||||
)
|
||||
|
||||
// LabelSelectorAsSelector converts the LabelSelector api type into a struct that implements
|
||||
@@ -280,13 +282,20 @@ func (f FieldsV1) MarshalJSON() ([]byte, error) {
|
||||
if f.Raw == nil {
|
||||
return []byte("null"), nil
|
||||
}
|
||||
if f.getContentType() == fieldsV1InvalidOrValidCBORObject {
|
||||
var u map[string]interface{}
|
||||
if err := cbor.Unmarshal(f.Raw, &u); err != nil {
|
||||
return nil, fmt.Errorf("metav1.FieldsV1 cbor invalid: %w", err)
|
||||
}
|
||||
return utiljson.Marshal(u)
|
||||
}
|
||||
return f.Raw, nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements json.Unmarshaler
|
||||
func (f *FieldsV1) UnmarshalJSON(b []byte) error {
|
||||
if f == nil {
|
||||
return errors.New("metav1.Fields: UnmarshalJSON on nil pointer")
|
||||
return errors.New("metav1.FieldsV1: UnmarshalJSON on nil pointer")
|
||||
}
|
||||
if !bytes.Equal(b, []byte("null")) {
|
||||
f.Raw = append(f.Raw[0:0], b...)
|
||||
@@ -296,3 +305,75 @@ func (f *FieldsV1) UnmarshalJSON(b []byte) error {
|
||||
|
||||
var _ json.Marshaler = FieldsV1{}
|
||||
var _ json.Unmarshaler = &FieldsV1{}
|
||||
|
||||
func (f FieldsV1) MarshalCBOR() ([]byte, error) {
|
||||
if f.Raw == nil {
|
||||
return cbor.Marshal(nil)
|
||||
}
|
||||
if f.getContentType() == fieldsV1InvalidOrValidJSONObject {
|
||||
var u map[string]interface{}
|
||||
if err := utiljson.Unmarshal(f.Raw, &u); err != nil {
|
||||
return nil, fmt.Errorf("metav1.FieldsV1 json invalid: %w", err)
|
||||
}
|
||||
return cbor.Marshal(u)
|
||||
}
|
||||
return f.Raw, nil
|
||||
}
|
||||
|
||||
var cborNull = []byte{0xf6}
|
||||
|
||||
func (f *FieldsV1) UnmarshalCBOR(b []byte) error {
|
||||
if f == nil {
|
||||
return errors.New("metav1.FieldsV1: UnmarshalCBOR on nil pointer")
|
||||
}
|
||||
if !bytes.Equal(b, cborNull) {
|
||||
f.Raw = append(f.Raw[0:0], b...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
const (
|
||||
// fieldsV1InvalidOrEmpty indicates that a FieldsV1 either contains no raw bytes or its raw
|
||||
// bytes don't represent an allowable value in any supported encoding.
|
||||
fieldsV1InvalidOrEmpty = iota
|
||||
|
||||
// fieldsV1InvalidOrValidJSONObject indicates that a FieldV1 either contains raw bytes that
|
||||
// are a valid JSON encoding of an allowable value or don't represent an allowable value in
|
||||
// any supported encoding.
|
||||
fieldsV1InvalidOrValidJSONObject
|
||||
|
||||
// fieldsV1InvalidOrValidCBORObject indicates that a FieldV1 either contains raw bytes that
|
||||
// are a valid CBOR encoding of an allowable value or don't represent an allowable value in
|
||||
// any supported encoding.
|
||||
fieldsV1InvalidOrValidCBORObject
|
||||
)
|
||||
|
||||
// getContentType returns one of fieldsV1InvalidOrEmpty, fieldsV1InvalidOrValidJSONObject,
|
||||
// fieldsV1InvalidOrValidCBORObject based on the value of Raw.
|
||||
//
|
||||
// Raw can be encoded in JSON or CBOR and is only valid if it is empty, null, or an object (map)
|
||||
// value. It is invalid if it contains a JSON string, number, boolean, or array. If Raw is nonempty
|
||||
// and represents an allowable value, then the initial byte unambiguously distinguishes a
|
||||
// JSON-encoded value from a CBOR-encoded value.
|
||||
//
|
||||
// A valid JSON-encoded value can begin with any of the four JSON whitespace characters, the first
|
||||
// character 'n' of null, or '{' (0x09, 0x0a, 0x0d, 0x20, 0x6e, or 0x7b, respectively). A valid
|
||||
// CBOR-encoded value can begin with the null simple value, an initial byte with major type "map",
|
||||
// or, if a tag-enclosed map, an initial byte with major type "tag" (0xf6, 0xa0...0xbf, or
|
||||
// 0xc6...0xdb). The two sets of valid initial bytes don't intersect.
|
||||
func (f FieldsV1) getContentType() int {
|
||||
if len(f.Raw) > 0 {
|
||||
p := f.Raw[0]
|
||||
switch p {
|
||||
case 'n', '{', '\t', '\r', '\n', ' ':
|
||||
return fieldsV1InvalidOrValidJSONObject
|
||||
case 0xf6: // null
|
||||
return fieldsV1InvalidOrValidCBORObject
|
||||
default:
|
||||
if p >= 0xa0 && p <= 0xbf /* map */ || p >= 0xc6 && p <= 0xdb /* tag */ {
|
||||
return fieldsV1InvalidOrValidCBORObject
|
||||
}
|
||||
}
|
||||
}
|
||||
return fieldsV1InvalidOrEmpty
|
||||
}
|
||||
|
||||
28
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go
generated
vendored
28
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/micro_time.go
generated
vendored
@@ -19,6 +19,8 @@ package v1
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
cbor "k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct"
|
||||
)
|
||||
|
||||
const RFC3339Micro = "2006-01-02T15:04:05.000000Z07:00"
|
||||
@@ -129,6 +131,25 @@ func (t *MicroTime) UnmarshalJSON(b []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *MicroTime) UnmarshalCBOR(b []byte) error {
|
||||
var s *string
|
||||
if err := cbor.Unmarshal(b, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
if s == nil {
|
||||
t.Time = time.Time{}
|
||||
return nil
|
||||
}
|
||||
|
||||
parsed, err := time.Parse(RFC3339Micro, *s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t.Time = parsed.Local()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalQueryParameter converts from a URL query parameter value to an object
|
||||
func (t *MicroTime) UnmarshalQueryParameter(str string) error {
|
||||
if len(str) == 0 {
|
||||
@@ -160,6 +181,13 @@ func (t MicroTime) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(t.UTC().Format(RFC3339Micro))
|
||||
}
|
||||
|
||||
func (t MicroTime) MarshalCBOR() ([]byte, error) {
|
||||
if t.IsZero() {
|
||||
return cbor.Marshal(nil)
|
||||
}
|
||||
return cbor.Marshal(t.UTC().Format(RFC3339Micro))
|
||||
}
|
||||
|
||||
// OpenAPISchemaType is used by the kube-openapi generator when constructing
|
||||
// the OpenAPI spec of this type.
|
||||
//
|
||||
|
||||
29
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
generated
vendored
29
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
generated
vendored
@@ -19,6 +19,8 @@ package v1
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
cbor "k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct"
|
||||
)
|
||||
|
||||
// Time is a wrapper around time.Time which supports correct
|
||||
@@ -116,6 +118,25 @@ func (t *Time) UnmarshalJSON(b []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *Time) UnmarshalCBOR(b []byte) error {
|
||||
var s *string
|
||||
if err := cbor.Unmarshal(b, &s); err != nil {
|
||||
return err
|
||||
}
|
||||
if s == nil {
|
||||
t.Time = time.Time{}
|
||||
return nil
|
||||
}
|
||||
|
||||
parsed, err := time.Parse(time.RFC3339, *s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
t.Time = parsed.Local()
|
||||
return nil
|
||||
}
|
||||
|
||||
// UnmarshalQueryParameter converts from a URL query parameter value to an object
|
||||
func (t *Time) UnmarshalQueryParameter(str string) error {
|
||||
if len(str) == 0 {
|
||||
@@ -151,6 +172,14 @@ func (t Time) MarshalJSON() ([]byte, error) {
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
func (t Time) MarshalCBOR() ([]byte, error) {
|
||||
if t.IsZero() {
|
||||
return cbor.Marshal(nil)
|
||||
}
|
||||
|
||||
return cbor.Marshal(t.UTC().Format(time.RFC3339))
|
||||
}
|
||||
|
||||
// ToUnstructured implements the value.UnstructuredConverter interface.
|
||||
func (t Time) ToUnstructured() interface{} {
|
||||
if t.IsZero() {
|
||||
|
||||
62
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types.go
generated
vendored
62
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types.go
generated
vendored
@@ -236,6 +236,8 @@ type ObjectMeta struct {
|
||||
// +optional
|
||||
// +patchMergeKey=uid
|
||||
// +patchStrategy=merge
|
||||
// +listType=map
|
||||
// +listMapKey=uid
|
||||
OwnerReferences []OwnerReference `json:"ownerReferences,omitempty" patchStrategy:"merge" patchMergeKey:"uid" protobuf:"bytes,13,rep,name=ownerReferences"`
|
||||
|
||||
// Must be empty before the object is deleted from the registry. Each entry
|
||||
@@ -253,6 +255,7 @@ type ObjectMeta struct {
|
||||
// are not vulnerable to ordering changes in the list.
|
||||
// +optional
|
||||
// +patchStrategy=merge
|
||||
// +listType=set
|
||||
Finalizers []string `json:"finalizers,omitempty" patchStrategy:"merge" protobuf:"bytes,14,rep,name=finalizers"`
|
||||
|
||||
// Tombstone: ClusterName was a legacy field that was always cleared by
|
||||
@@ -268,6 +271,7 @@ type ObjectMeta struct {
|
||||
// workflow used when modifying the object.
|
||||
//
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
ManagedFields []ManagedFieldsEntry `json:"managedFields,omitempty" protobuf:"bytes,17,rep,name=managedFields"`
|
||||
}
|
||||
|
||||
@@ -428,6 +432,15 @@ type ListOptions struct {
|
||||
SendInitialEvents *bool `json:"sendInitialEvents,omitempty" protobuf:"varint,11,opt,name=sendInitialEvents"`
|
||||
}
|
||||
|
||||
const (
|
||||
// InitialEventsAnnotationKey the name of the key
|
||||
// under which an annotation marking the end of
|
||||
// a watchlist stream is stored.
|
||||
//
|
||||
// The annotation is added to a "Bookmark" event.
|
||||
InitialEventsAnnotationKey = "k8s.io/initial-events-end"
|
||||
)
|
||||
|
||||
// resourceVersionMatch specifies how the resourceVersion parameter is applied. resourceVersionMatch
|
||||
// may only be set if resourceVersion is also set.
|
||||
//
|
||||
@@ -531,6 +544,7 @@ type DeleteOptions struct {
|
||||
// request. Valid values are:
|
||||
// - All: all dry run stages will be processed
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
DryRun []string `json:"dryRun,omitempty" protobuf:"bytes,5,rep,name=dryRun"`
|
||||
}
|
||||
|
||||
@@ -556,6 +570,7 @@ type CreateOptions struct {
|
||||
// request. Valid values are:
|
||||
// - All: all dry run stages will be processed
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
DryRun []string `json:"dryRun,omitempty" protobuf:"bytes,1,rep,name=dryRun"`
|
||||
// +k8s:deprecated=includeUninitialized,protobuf=2
|
||||
|
||||
@@ -600,6 +615,7 @@ type PatchOptions struct {
|
||||
// request. Valid values are:
|
||||
// - All: all dry run stages will be processed
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
DryRun []string `json:"dryRun,omitempty" protobuf:"bytes,1,rep,name=dryRun"`
|
||||
|
||||
// Force is going to "force" Apply requests. It means user will
|
||||
@@ -651,6 +667,7 @@ type ApplyOptions struct {
|
||||
// request. Valid values are:
|
||||
// - All: all dry run stages will be processed
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
DryRun []string `json:"dryRun,omitempty" protobuf:"bytes,1,rep,name=dryRun"`
|
||||
|
||||
// Force is going to "force" Apply requests. It means user will
|
||||
@@ -683,6 +700,7 @@ type UpdateOptions struct {
|
||||
// request. Valid values are:
|
||||
// - All: all dry run stages will be processed
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
DryRun []string `json:"dryRun,omitempty" protobuf:"bytes,1,rep,name=dryRun"`
|
||||
|
||||
// fieldManager is a name associated with the actor or entity
|
||||
@@ -751,6 +769,7 @@ type Status struct {
|
||||
// is not guaranteed to conform to any schema except that defined by
|
||||
// the reason type.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
Details *StatusDetails `json:"details,omitempty" protobuf:"bytes,5,opt,name=details"`
|
||||
// Suggested HTTP return code for this status, 0 if not set.
|
||||
// +optional
|
||||
@@ -784,6 +803,7 @@ type StatusDetails struct {
|
||||
// The Causes array includes more details associated with the StatusReason
|
||||
// failure. Not all StatusReasons may provide detailed causes.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
Causes []StatusCause `json:"causes,omitempty" protobuf:"bytes,4,rep,name=causes"`
|
||||
// If specified, the time in seconds before the operation should be retried. Some errors may indicate
|
||||
// the client must take an alternate action - for those errors this field may indicate how long to wait
|
||||
@@ -1047,6 +1067,7 @@ type List struct {
|
||||
type APIVersions struct {
|
||||
TypeMeta `json:",inline"`
|
||||
// versions are the api versions that are available.
|
||||
// +listType=atomic
|
||||
Versions []string `json:"versions" protobuf:"bytes,1,rep,name=versions"`
|
||||
// a map of client CIDR to server address that is serving this group.
|
||||
// This is to help clients reach servers in the most network-efficient way possible.
|
||||
@@ -1055,6 +1076,7 @@ type APIVersions struct {
|
||||
// The server returns only those CIDRs that it thinks that the client can match.
|
||||
// For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP.
|
||||
// Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.
|
||||
// +listType=atomic
|
||||
ServerAddressByClientCIDRs []ServerAddressByClientCIDR `json:"serverAddressByClientCIDRs" protobuf:"bytes,2,rep,name=serverAddressByClientCIDRs"`
|
||||
}
|
||||
|
||||
@@ -1065,6 +1087,7 @@ type APIVersions struct {
|
||||
type APIGroupList struct {
|
||||
TypeMeta `json:",inline"`
|
||||
// groups is a list of APIGroup.
|
||||
// +listType=atomic
|
||||
Groups []APIGroup `json:"groups" protobuf:"bytes,1,rep,name=groups"`
|
||||
}
|
||||
|
||||
@@ -1077,6 +1100,7 @@ type APIGroup struct {
|
||||
// name is the name of the group.
|
||||
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
|
||||
// versions are the versions supported in this group.
|
||||
// +listType=atomic
|
||||
Versions []GroupVersionForDiscovery `json:"versions" protobuf:"bytes,2,rep,name=versions"`
|
||||
// preferredVersion is the version preferred by the API server, which
|
||||
// probably is the storage version.
|
||||
@@ -1090,6 +1114,7 @@ type APIGroup struct {
|
||||
// For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP.
|
||||
// Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
ServerAddressByClientCIDRs []ServerAddressByClientCIDR `json:"serverAddressByClientCIDRs,omitempty" protobuf:"bytes,4,rep,name=serverAddressByClientCIDRs"`
|
||||
}
|
||||
|
||||
@@ -1134,8 +1159,10 @@ type APIResource struct {
|
||||
// update, patch, delete, deletecollection, and proxy)
|
||||
Verbs Verbs `json:"verbs" protobuf:"bytes,4,opt,name=verbs"`
|
||||
// shortNames is a list of suggested short names of the resource.
|
||||
// +listType=atomic
|
||||
ShortNames []string `json:"shortNames,omitempty" protobuf:"bytes,5,rep,name=shortNames"`
|
||||
// categories is a list of the grouped resources this resource belongs to (e.g. 'all')
|
||||
// +listType=atomic
|
||||
Categories []string `json:"categories,omitempty" protobuf:"bytes,7,rep,name=categories"`
|
||||
// The hash value of the storage version, the version this resource is
|
||||
// converted to when written to the data store. Value must be treated
|
||||
@@ -1168,6 +1195,7 @@ type APIResourceList struct {
|
||||
// groupVersion is the group and version this APIResourceList is for.
|
||||
GroupVersion string `json:"groupVersion" protobuf:"bytes,1,opt,name=groupVersion"`
|
||||
// resources contains the name of the resources and if they are namespaced.
|
||||
// +listType=atomic
|
||||
APIResources []APIResource `json:"resources" protobuf:"bytes,2,rep,name=resources"`
|
||||
}
|
||||
|
||||
@@ -1175,6 +1203,7 @@ type APIResourceList struct {
|
||||
// For example: "/healthz", "/apis".
|
||||
type RootPaths struct {
|
||||
// paths are the paths available at root.
|
||||
// +listType=atomic
|
||||
Paths []string `json:"paths" protobuf:"bytes,1,rep,name=paths"`
|
||||
}
|
||||
|
||||
@@ -1218,6 +1247,7 @@ type LabelSelector struct {
|
||||
MatchLabels map[string]string `json:"matchLabels,omitempty" protobuf:"bytes,1,rep,name=matchLabels"`
|
||||
// matchExpressions is a list of label selector requirements. The requirements are ANDed.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
MatchExpressions []LabelSelectorRequirement `json:"matchExpressions,omitempty" protobuf:"bytes,2,rep,name=matchExpressions"`
|
||||
}
|
||||
|
||||
@@ -1234,6 +1264,7 @@ type LabelSelectorRequirement struct {
|
||||
// the values array must be empty. This array is replaced during a strategic
|
||||
// merge patch.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
Values []string `json:"values,omitempty" protobuf:"bytes,3,rep,name=values"`
|
||||
}
|
||||
|
||||
@@ -1247,6 +1278,33 @@ const (
|
||||
LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist"
|
||||
)
|
||||
|
||||
// FieldSelectorRequirement is a selector that contains values, a key, and an operator that
|
||||
// relates the key and values.
|
||||
type FieldSelectorRequirement struct {
|
||||
// key is the field selector key that the requirement applies to.
|
||||
Key string `json:"key" protobuf:"bytes,1,opt,name=key"`
|
||||
// operator represents a key's relationship to a set of values.
|
||||
// Valid operators are In, NotIn, Exists, DoesNotExist.
|
||||
// The list of operators may grow in the future.
|
||||
Operator FieldSelectorOperator `json:"operator" protobuf:"bytes,2,opt,name=operator,casttype=FieldSelectorOperator"`
|
||||
// values is an array of string values.
|
||||
// If the operator is In or NotIn, the values array must be non-empty.
|
||||
// If the operator is Exists or DoesNotExist, the values array must be empty.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
Values []string `json:"values,omitempty" protobuf:"bytes,3,rep,name=values"`
|
||||
}
|
||||
|
||||
// A field selector operator is the set of operators that can be used in a selector requirement.
|
||||
type FieldSelectorOperator string
|
||||
|
||||
const (
|
||||
FieldSelectorOpIn FieldSelectorOperator = "In"
|
||||
FieldSelectorOpNotIn FieldSelectorOperator = "NotIn"
|
||||
FieldSelectorOpExists FieldSelectorOperator = "Exists"
|
||||
FieldSelectorOpDoesNotExist FieldSelectorOperator = "DoesNotExist"
|
||||
)
|
||||
|
||||
// ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource
|
||||
// that the fieldset applies to.
|
||||
type ManagedFieldsEntry struct {
|
||||
@@ -1335,8 +1393,10 @@ type Table struct {
|
||||
|
||||
// columnDefinitions describes each column in the returned items array. The number of cells per row
|
||||
// will always match the number of column definitions.
|
||||
// +listType=atomic
|
||||
ColumnDefinitions []TableColumnDefinition `json:"columnDefinitions"`
|
||||
// rows is the list of items in the table.
|
||||
// +listType=atomic
|
||||
Rows []TableRow `json:"rows"`
|
||||
}
|
||||
|
||||
@@ -1369,12 +1429,14 @@ type TableRow struct {
|
||||
// cells will be as wide as the column definitions array and may contain strings, numbers (float64 or
|
||||
// int64), booleans, simple maps, lists, or null. See the type field of the column definition for a
|
||||
// more detailed description.
|
||||
// +listType=atomic
|
||||
Cells []interface{} `json:"cells"`
|
||||
// conditions describe additional status of a row that are relevant for a human user. These conditions
|
||||
// apply to the row, not to the object, and will be specific to table output. The only defined
|
||||
// condition type is 'Completed', for a row that indicates a resource that has run to completion and
|
||||
// can be given less visual priority.
|
||||
// +optional
|
||||
// +listType=atomic
|
||||
Conditions []TableRowCondition `json:"conditions,omitempty"`
|
||||
// This field contains the requested additional information about each object based on the includeObject
|
||||
// policy when requesting the Table. If "None", this field is empty, if "Object" this will be the
|
||||
|
||||
11
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types_swagger_doc_generated.go
generated
vendored
11
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types_swagger_doc_generated.go
generated
vendored
@@ -135,6 +135,17 @@ func (DeleteOptions) SwaggerDoc() map[string]string {
|
||||
return map_DeleteOptions
|
||||
}
|
||||
|
||||
var map_FieldSelectorRequirement = map[string]string{
|
||||
"": "FieldSelectorRequirement is a selector that contains values, a key, and an operator that relates the key and values.",
|
||||
"key": "key is the field selector key that the requirement applies to.",
|
||||
"operator": "operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists, DoesNotExist. The list of operators may grow in the future.",
|
||||
"values": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty.",
|
||||
}
|
||||
|
||||
func (FieldSelectorRequirement) SwaggerDoc() map[string]string {
|
||||
return map_FieldSelectorRequirement
|
||||
}
|
||||
|
||||
var map_FieldsV1 = map[string]string{
|
||||
"": "FieldsV1 stores a set of fields in a data structure like a Trie, in JSON format.\n\nEach key is either a '.' representing the field itself, and will always map to an empty set, or a string representing a sub-field or item. The string will follow one of these four formats: 'f:<name>', where <name> is the name of a field in a struct, or key in a map 'v:<value>', where <value> is the exact json formatted value of a list item 'i:<index>', where <index> is position of a item in a list 'k:<keys>', where <keys> is a map of a list item's key fields to their unique values If a key maps to an empty Fields value, the field that key represents is part of the set.\n\nThe exact format is defined in sigs.k8s.io/structured-merge-diff",
|
||||
}
|
||||
|
||||
41
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/validation/validation.go
generated
vendored
41
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/validation/validation.go
generated
vendored
@@ -32,6 +32,10 @@ import (
|
||||
type LabelSelectorValidationOptions struct {
|
||||
// Allow invalid label value in selector
|
||||
AllowInvalidLabelValueInSelector bool
|
||||
|
||||
// Allows an operator that is not interpretable to pass validation. This is useful for cases where a broader check
|
||||
// can be performed, as in a *SubjectAccessReview
|
||||
AllowUnknownOperatorInRequirement bool
|
||||
}
|
||||
|
||||
// LabelSelectorHasInvalidLabelValue returns true if the given selector contains an invalid label value in a match expression.
|
||||
@@ -79,7 +83,9 @@ func ValidateLabelSelectorRequirement(sr metav1.LabelSelectorRequirement, opts L
|
||||
allErrs = append(allErrs, field.Forbidden(fldPath.Child("values"), "may not be specified when `operator` is 'Exists' or 'DoesNotExist'"))
|
||||
}
|
||||
default:
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("operator"), sr.Operator, "not a valid selector operator"))
|
||||
if !opts.AllowUnknownOperatorInRequirement {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("operator"), sr.Operator, "not a valid selector operator"))
|
||||
}
|
||||
}
|
||||
allErrs = append(allErrs, ValidateLabelName(sr.Key, fldPath.Child("key"))...)
|
||||
if !opts.AllowInvalidLabelValueInSelector {
|
||||
@@ -113,6 +119,39 @@ func ValidateLabels(labels map[string]string, fldPath *field.Path) field.ErrorLi
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// FieldSelectorValidationOptions is a struct that can be passed to ValidateFieldSelectorRequirement to record the validate options
|
||||
type FieldSelectorValidationOptions struct {
|
||||
// Allows an operator that is not interpretable to pass validation. This is useful for cases where a broader check
|
||||
// can be performed, as in a *SubjectAccessReview
|
||||
AllowUnknownOperatorInRequirement bool
|
||||
}
|
||||
|
||||
// ValidateLabelSelectorRequirement validates the requirement according to the opts and returns any validation errors.
|
||||
func ValidateFieldSelectorRequirement(requirement metav1.FieldSelectorRequirement, opts FieldSelectorValidationOptions, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
if len(requirement.Key) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("key"), "must be specified"))
|
||||
}
|
||||
|
||||
switch requirement.Operator {
|
||||
case metav1.FieldSelectorOpIn, metav1.FieldSelectorOpNotIn:
|
||||
if len(requirement.Values) == 0 {
|
||||
allErrs = append(allErrs, field.Required(fldPath.Child("values"), "must be specified when `operator` is 'In' or 'NotIn'"))
|
||||
}
|
||||
case metav1.FieldSelectorOpExists, metav1.FieldSelectorOpDoesNotExist:
|
||||
if len(requirement.Values) > 0 {
|
||||
allErrs = append(allErrs, field.Forbidden(fldPath.Child("values"), "may not be specified when `operator` is 'Exists' or 'DoesNotExist'"))
|
||||
}
|
||||
default:
|
||||
if !opts.AllowUnknownOperatorInRequirement {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("operator"), requirement.Operator, "not a valid selector operator"))
|
||||
}
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateDeleteOptions(options *metav1.DeleteOptions) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
//lint:file-ignore SA1019 Keep validation for deprecated OrphanDependents option until it's being removed
|
||||
|
||||
21
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.deepcopy.go
generated
vendored
21
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/zz_generated.deepcopy.go
generated
vendored
@@ -327,6 +327,27 @@ func (in *Duration) DeepCopy() *Duration {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FieldSelectorRequirement) DeepCopyInto(out *FieldSelectorRequirement) {
|
||||
*out = *in
|
||||
if in.Values != nil {
|
||||
in, out := &in.Values, &out.Values
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FieldSelectorRequirement.
|
||||
func (in *FieldSelectorRequirement) DeepCopy() *FieldSelectorRequirement {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(FieldSelectorRequirement)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *FieldsV1) DeepCopyInto(out *FieldsV1) {
|
||||
*out = *in
|
||||
|
||||
45
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.pb.go
generated
vendored
45
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.pb.go
generated
vendored
@@ -15,7 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.proto
|
||||
// source: k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.proto
|
||||
|
||||
package v1beta1
|
||||
|
||||
@@ -47,7 +47,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
func (m *PartialObjectMetadataList) Reset() { *m = PartialObjectMetadataList{} }
|
||||
func (*PartialObjectMetadataList) ProtoMessage() {}
|
||||
func (*PartialObjectMetadataList) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_90ec10f86b91f9a8, []int{0}
|
||||
return fileDescriptor_39237a8d8061b52f, []int{0}
|
||||
}
|
||||
func (m *PartialObjectMetadataList) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@@ -77,31 +77,30 @@ func init() {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.proto", fileDescriptor_90ec10f86b91f9a8)
|
||||
proto.RegisterFile("k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.proto", fileDescriptor_39237a8d8061b52f)
|
||||
}
|
||||
|
||||
var fileDescriptor_90ec10f86b91f9a8 = []byte{
|
||||
// 317 bytes of a gzipped FileDescriptorProto
|
||||
var fileDescriptor_39237a8d8061b52f = []byte{
|
||||
// 303 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x4b, 0xf3, 0x30,
|
||||
0x1c, 0xc6, 0x9b, 0xf7, 0x65, 0x30, 0x3a, 0x04, 0xd9, 0x69, 0xee, 0x90, 0x0d, 0x4f, 0xdb, 0xc1,
|
||||
0x84, 0x0d, 0x11, 0xc1, 0xdb, 0x6e, 0x82, 0x32, 0xd9, 0x51, 0x3c, 0x98, 0x76, 0x7f, 0xbb, 0x58,
|
||||
0xd3, 0x94, 0xe4, 0xdf, 0x81, 0x37, 0x3f, 0x82, 0x1f, 0x6b, 0xc7, 0x1d, 0x07, 0xc2, 0x70, 0xf5,
|
||||
0x8b, 0x48, 0xda, 0x2a, 0x32, 0x14, 0x7a, 0xeb, 0xf3, 0x94, 0xdf, 0x2f, 0x4f, 0x20, 0xfe, 0x2c,
|
||||
0x3e, 0xb7, 0x4c, 0x6a, 0x1e, 0x67, 0x01, 0x98, 0x04, 0x10, 0x2c, 0x5f, 0x42, 0x32, 0xd7, 0x86,
|
||||
0x57, 0x3f, 0x44, 0x2a, 0x95, 0x08, 0x17, 0x32, 0x01, 0xf3, 0xcc, 0xd3, 0x38, 0x72, 0x85, 0xe5,
|
||||
0x0a, 0x50, 0xf0, 0xe5, 0x28, 0x00, 0x14, 0x23, 0x1e, 0x41, 0x02, 0x46, 0x20, 0xcc, 0x59, 0x6a,
|
||||
0x34, 0xea, 0xf6, 0xb0, 0x44, 0xd9, 0x4f, 0x94, 0xa5, 0x71, 0xe4, 0x0a, 0xcb, 0x1c, 0xca, 0x2a,
|
||||
0xb4, 0x7b, 0x12, 0x49, 0x5c, 0x64, 0x01, 0x0b, 0xb5, 0xe2, 0x91, 0x8e, 0x34, 0x2f, 0x0c, 0x41,
|
||||
0xf6, 0x50, 0xa4, 0x22, 0x14, 0x5f, 0xa5, 0xb9, 0x7b, 0x5a, 0x67, 0xd4, 0xfe, 0x9e, 0xee, 0xd9,
|
||||
0x5f, 0x94, 0xc9, 0x12, 0x94, 0x0a, 0xb8, 0x0d, 0x17, 0xa0, 0xc4, 0x3e, 0x77, 0xfc, 0x46, 0xfc,
|
||||
0xa3, 0x1b, 0x61, 0x50, 0x8a, 0xa7, 0x69, 0xf0, 0x08, 0x21, 0x5e, 0x03, 0x8a, 0xb9, 0x40, 0x71,
|
||||
0x25, 0x2d, 0xb6, 0xef, 0xfc, 0xa6, 0xaa, 0x72, 0xe7, 0x5f, 0x9f, 0x0c, 0x5a, 0x63, 0xc6, 0xea,
|
||||
0x5c, 0x9c, 0x39, 0xda, 0x99, 0x26, 0x87, 0xab, 0x6d, 0xcf, 0xcb, 0xb7, 0xbd, 0xe6, 0x57, 0x33,
|
||||
0xfb, 0x36, 0xb6, 0xef, 0xfd, 0x86, 0x44, 0x50, 0xb6, 0x43, 0xfa, 0xff, 0x07, 0xad, 0xf1, 0x45,
|
||||
0x3d, 0xf5, 0xaf, 0x6b, 0x27, 0x07, 0xd5, 0x39, 0x8d, 0x4b, 0x67, 0x9c, 0x95, 0xe2, 0xc9, 0x74,
|
||||
0xb5, 0xa3, 0xde, 0x7a, 0x47, 0xbd, 0xcd, 0x8e, 0x7a, 0x2f, 0x39, 0x25, 0xab, 0x9c, 0x92, 0x75,
|
||||
0x4e, 0xc9, 0x26, 0xa7, 0xe4, 0x3d, 0xa7, 0xe4, 0xf5, 0x83, 0x7a, 0xb7, 0xc3, 0xda, 0xcf, 0xe0,
|
||||
0x33, 0x00, 0x00, 0xff, 0xff, 0x30, 0x97, 0x8b, 0x11, 0x4b, 0x02, 0x00, 0x00,
|
||||
0x84, 0x0d, 0x11, 0xc5, 0xdb, 0x6e, 0x82, 0x32, 0xd9, 0x51, 0x3c, 0x98, 0x76, 0x31, 0x8b, 0x35,
|
||||
0x4d, 0x69, 0xfe, 0x15, 0xbc, 0xf9, 0x11, 0xfc, 0x58, 0x3d, 0xee, 0x38, 0x10, 0x86, 0x8d, 0x5f,
|
||||
0x44, 0xd2, 0x56, 0x91, 0xa1, 0xd0, 0x5b, 0x9e, 0x07, 0x7e, 0xbf, 0x3c, 0x81, 0xf8, 0x67, 0xd1,
|
||||
0xa9, 0x21, 0x52, 0x53, 0x96, 0x48, 0xc5, 0xc2, 0x95, 0x8c, 0x79, 0xfa, 0x4c, 0x93, 0x48, 0xb8,
|
||||
0xc2, 0x50, 0xc5, 0x81, 0xd1, 0xa7, 0x49, 0xc0, 0x81, 0x4d, 0xa8, 0xe0, 0x31, 0x4f, 0x19, 0xf0,
|
||||
0x25, 0x49, 0x52, 0x0d, 0xba, 0x3b, 0xae, 0x50, 0xf2, 0x13, 0x25, 0x49, 0x24, 0x5c, 0x61, 0x88,
|
||||
0x43, 0x49, 0x8d, 0xf6, 0x8f, 0x84, 0x84, 0x55, 0x16, 0x90, 0x50, 0x2b, 0x2a, 0xb4, 0xd0, 0xb4,
|
||||
0x34, 0x04, 0xd9, 0x7d, 0x99, 0xca, 0x50, 0x9e, 0x2a, 0x73, 0xff, 0xb8, 0xc9, 0xa8, 0xdd, 0x3d,
|
||||
0xfd, 0x93, 0xbf, 0xa8, 0x34, 0x8b, 0x41, 0x2a, 0x4e, 0x4d, 0xb8, 0xe2, 0x8a, 0xed, 0x72, 0x87,
|
||||
0x6f, 0xc8, 0x3f, 0xb8, 0x66, 0x29, 0x48, 0xf6, 0x38, 0x0f, 0x1e, 0x78, 0x08, 0x57, 0x1c, 0xd8,
|
||||
0x92, 0x01, 0xbb, 0x94, 0x06, 0xba, 0xb7, 0x7e, 0x5b, 0xd5, 0xb9, 0xf7, 0x6f, 0x88, 0x46, 0x9d,
|
||||
0x29, 0x21, 0x4d, 0x1e, 0x4e, 0x1c, 0xed, 0x4c, 0xb3, 0xfd, 0x7c, 0x3b, 0xf0, 0xec, 0x76, 0xd0,
|
||||
0xfe, 0x6a, 0x16, 0xdf, 0xc6, 0xee, 0x9d, 0xdf, 0x92, 0xc0, 0x95, 0xe9, 0xa1, 0xe1, 0xff, 0x51,
|
||||
0x67, 0x7a, 0xde, 0x4c, 0xfd, 0xeb, 0xda, 0xd9, 0x5e, 0x7d, 0x4f, 0xeb, 0xc2, 0x19, 0x17, 0x95,
|
||||
0x78, 0x36, 0xcf, 0x0b, 0xec, 0xad, 0x0b, 0xec, 0x6d, 0x0a, 0xec, 0xbd, 0x58, 0x8c, 0x72, 0x8b,
|
||||
0xd1, 0xda, 0x62, 0xb4, 0xb1, 0x18, 0xbd, 0x5b, 0x8c, 0x5e, 0x3f, 0xb0, 0x77, 0x33, 0x6e, 0xfc,
|
||||
0x0d, 0x3e, 0x03, 0x00, 0x00, 0xff, 0xff, 0xfe, 0x0f, 0xd7, 0x36, 0x32, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *PartialObjectMetadataList) Marshal() (dAtA []byte, err error) {
|
||||
|
||||
4
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.proto
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/apis/meta/v1beta1/generated.proto
generated
vendored
@@ -33,9 +33,9 @@ message PartialObjectMetadataList {
|
||||
// Standard list metadata.
|
||||
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||
// +optional
|
||||
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 2;
|
||||
optional .k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 2;
|
||||
|
||||
// items contains each of the included items.
|
||||
repeated k8s.io.apimachinery.pkg.apis.meta.v1.PartialObjectMetadata items = 1;
|
||||
repeated .k8s.io.apimachinery.pkg.apis.meta.v1.PartialObjectMetadata items = 1;
|
||||
}
|
||||
|
||||
|
||||
20
vendor/k8s.io/apimachinery/pkg/labels/selector.go
generated
vendored
20
vendor/k8s.io/apimachinery/pkg/labels/selector.go
generated
vendored
@@ -45,6 +45,19 @@ var (
|
||||
// Requirements is AND of all requirements.
|
||||
type Requirements []Requirement
|
||||
|
||||
func (r Requirements) String() string {
|
||||
var sb strings.Builder
|
||||
|
||||
for i, requirement := range r {
|
||||
if i > 0 {
|
||||
sb.WriteString(", ")
|
||||
}
|
||||
sb.WriteString(requirement.String())
|
||||
}
|
||||
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
// Selector represents a label selector.
|
||||
type Selector interface {
|
||||
// Matches returns true if this selector matches the given set of labels.
|
||||
@@ -285,6 +298,13 @@ func (r *Requirement) Values() sets.String {
|
||||
return ret
|
||||
}
|
||||
|
||||
// ValuesUnsorted returns a copy of requirement values as passed to NewRequirement without sorting.
|
||||
func (r *Requirement) ValuesUnsorted() []string {
|
||||
ret := make([]string, 0, len(r.strValues))
|
||||
ret = append(ret, r.strValues...)
|
||||
return ret
|
||||
}
|
||||
|
||||
// Equal checks the equality of requirement.
|
||||
func (r Requirement) Equal(x Requirement) bool {
|
||||
if r.key != x.key {
|
||||
|
||||
100
vendor/k8s.io/apimachinery/pkg/runtime/extension.go
generated
vendored
100
vendor/k8s.io/apimachinery/pkg/runtime/extension.go
generated
vendored
@@ -18,16 +18,77 @@ package runtime
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
cbor "k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
)
|
||||
|
||||
// RawExtension intentionally avoids implementing value.UnstructuredConverter for now because the
|
||||
// signature of ToUnstructured does not allow returning an error value in cases where the conversion
|
||||
// is not possible (content type is unrecognized or bytes don't match content type).
|
||||
func rawToUnstructured(raw []byte, contentType string) (interface{}, error) {
|
||||
switch contentType {
|
||||
case ContentTypeJSON:
|
||||
var u interface{}
|
||||
if err := json.Unmarshal(raw, &u); err != nil {
|
||||
return nil, fmt.Errorf("failed to parse RawExtension bytes as JSON: %w", err)
|
||||
}
|
||||
return u, nil
|
||||
case ContentTypeCBOR:
|
||||
var u interface{}
|
||||
if err := cbor.Unmarshal(raw, &u); err != nil {
|
||||
return nil, fmt.Errorf("failed to parse RawExtension bytes as CBOR: %w", err)
|
||||
}
|
||||
return u, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("cannot convert RawExtension with unrecognized content type to unstructured")
|
||||
}
|
||||
}
|
||||
|
||||
func (re RawExtension) guessContentType() string {
|
||||
switch {
|
||||
case bytes.HasPrefix(re.Raw, cborSelfDescribed):
|
||||
return ContentTypeCBOR
|
||||
case len(re.Raw) > 0:
|
||||
switch re.Raw[0] {
|
||||
case '\t', '\r', '\n', ' ', '{', '[', 'n', 't', 'f', '"', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9':
|
||||
// Prefixes for the four whitespace characters, objects, arrays, strings, numbers, true, false, and null.
|
||||
return ContentTypeJSON
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (re *RawExtension) UnmarshalJSON(in []byte) error {
|
||||
if re == nil {
|
||||
return errors.New("runtime.RawExtension: UnmarshalJSON on nil pointer")
|
||||
}
|
||||
if !bytes.Equal(in, []byte("null")) {
|
||||
re.Raw = append(re.Raw[0:0], in...)
|
||||
if bytes.Equal(in, []byte("null")) {
|
||||
return nil
|
||||
}
|
||||
re.Raw = append(re.Raw[0:0], in...)
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
cborNull = []byte{0xf6}
|
||||
cborSelfDescribed = []byte{0xd9, 0xd9, 0xf7}
|
||||
)
|
||||
|
||||
func (re *RawExtension) UnmarshalCBOR(in []byte) error {
|
||||
if re == nil {
|
||||
return errors.New("runtime.RawExtension: UnmarshalCBOR on nil pointer")
|
||||
}
|
||||
if !bytes.Equal(in, cborNull) {
|
||||
if !bytes.HasPrefix(in, cborSelfDescribed) {
|
||||
// The self-described CBOR tag doesn't change the interpretation of the data
|
||||
// item it encloses, but it is useful as a magic number. Its encoding is
|
||||
// also what is used to implement the CBOR RecognizingDecoder.
|
||||
re.Raw = append(re.Raw[:0], cborSelfDescribed...)
|
||||
}
|
||||
re.Raw = append(re.Raw, in...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -46,6 +107,35 @@ func (re RawExtension) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
return []byte("null"), nil
|
||||
}
|
||||
// TODO: Check whether ContentType is actually JSON before returning it.
|
||||
return re.Raw, nil
|
||||
|
||||
contentType := re.guessContentType()
|
||||
if contentType == ContentTypeJSON {
|
||||
return re.Raw, nil
|
||||
}
|
||||
|
||||
u, err := rawToUnstructured(re.Raw, contentType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return json.Marshal(u)
|
||||
}
|
||||
|
||||
func (re RawExtension) MarshalCBOR() ([]byte, error) {
|
||||
if re.Raw == nil {
|
||||
if re.Object != nil {
|
||||
return cbor.Marshal(re.Object)
|
||||
}
|
||||
return cbor.Marshal(nil)
|
||||
}
|
||||
|
||||
contentType := re.guessContentType()
|
||||
if contentType == ContentTypeCBOR {
|
||||
return re.Raw, nil
|
||||
}
|
||||
|
||||
u, err := rawToUnstructured(re.Raw, contentType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cbor.Marshal(u)
|
||||
}
|
||||
|
||||
61
vendor/k8s.io/apimachinery/pkg/runtime/generated.pb.go
generated
vendored
61
vendor/k8s.io/apimachinery/pkg/runtime/generated.pb.go
generated
vendored
@@ -15,7 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/runtime/generated.proto
|
||||
// source: k8s.io/apimachinery/pkg/runtime/generated.proto
|
||||
|
||||
package runtime
|
||||
|
||||
@@ -45,7 +45,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
func (m *RawExtension) Reset() { *m = RawExtension{} }
|
||||
func (*RawExtension) ProtoMessage() {}
|
||||
func (*RawExtension) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_9d3c45d7f546725c, []int{0}
|
||||
return fileDescriptor_2e0e4b920403a48c, []int{0}
|
||||
}
|
||||
func (m *RawExtension) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@@ -73,7 +73,7 @@ var xxx_messageInfo_RawExtension proto.InternalMessageInfo
|
||||
func (m *TypeMeta) Reset() { *m = TypeMeta{} }
|
||||
func (*TypeMeta) ProtoMessage() {}
|
||||
func (*TypeMeta) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_9d3c45d7f546725c, []int{1}
|
||||
return fileDescriptor_2e0e4b920403a48c, []int{1}
|
||||
}
|
||||
func (m *TypeMeta) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@@ -101,7 +101,7 @@ var xxx_messageInfo_TypeMeta proto.InternalMessageInfo
|
||||
func (m *Unknown) Reset() { *m = Unknown{} }
|
||||
func (*Unknown) ProtoMessage() {}
|
||||
func (*Unknown) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_9d3c45d7f546725c, []int{2}
|
||||
return fileDescriptor_2e0e4b920403a48c, []int{2}
|
||||
}
|
||||
func (m *Unknown) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@@ -133,35 +133,34 @@ func init() {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/runtime/generated.proto", fileDescriptor_9d3c45d7f546725c)
|
||||
proto.RegisterFile("k8s.io/apimachinery/pkg/runtime/generated.proto", fileDescriptor_2e0e4b920403a48c)
|
||||
}
|
||||
|
||||
var fileDescriptor_9d3c45d7f546725c = []byte{
|
||||
// 380 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcf, 0xaa, 0x13, 0x31,
|
||||
0x14, 0xc6, 0x27, 0xb7, 0x85, 0x7b, 0x4d, 0x0b, 0x57, 0xe2, 0xc2, 0xd1, 0x45, 0xe6, 0xd2, 0x95,
|
||||
0x77, 0x61, 0x02, 0x17, 0x04, 0xb7, 0x9d, 0x52, 0x50, 0x44, 0x90, 0xe0, 0x1f, 0x70, 0x65, 0x3a,
|
||||
0x13, 0xa7, 0x61, 0xe8, 0xc9, 0x90, 0x66, 0x1c, 0xbb, 0xf3, 0x11, 0x7c, 0xac, 0x2e, 0xbb, 0xec,
|
||||
0xaa, 0xd8, 0xf1, 0x21, 0xdc, 0x4a, 0xd3, 0xb4, 0x56, 0x5d, 0x74, 0x97, 0x73, 0xbe, 0xef, 0xf7,
|
||||
0x9d, 0x73, 0x20, 0xf8, 0x45, 0xf9, 0x7c, 0xce, 0xb4, 0xe1, 0x65, 0x3d, 0x51, 0x16, 0x94, 0x53,
|
||||
0x73, 0xfe, 0x45, 0x41, 0x6e, 0x2c, 0x0f, 0x82, 0xac, 0xf4, 0x4c, 0x66, 0x53, 0x0d, 0xca, 0x2e,
|
||||
0x78, 0x55, 0x16, 0xdc, 0xd6, 0xe0, 0xf4, 0x4c, 0xf1, 0x42, 0x81, 0xb2, 0xd2, 0xa9, 0x9c, 0x55,
|
||||
0xd6, 0x38, 0x43, 0x92, 0x3d, 0xc0, 0x4e, 0x01, 0x56, 0x95, 0x05, 0x0b, 0xc0, 0xe3, 0xa7, 0x85,
|
||||
0x76, 0xd3, 0x7a, 0xc2, 0x32, 0x33, 0xe3, 0x85, 0x29, 0x0c, 0xf7, 0xdc, 0xa4, 0xfe, 0xec, 0x2b,
|
||||
0x5f, 0xf8, 0xd7, 0x3e, 0x6f, 0x70, 0x8b, 0xfb, 0x42, 0x36, 0xe3, 0xaf, 0x4e, 0xc1, 0x5c, 0x1b,
|
||||
0x20, 0x8f, 0x70, 0xc7, 0xca, 0x26, 0x46, 0x37, 0xe8, 0x49, 0x3f, 0xbd, 0x6c, 0x37, 0x49, 0x47,
|
||||
0xc8, 0x46, 0xec, 0x7a, 0x83, 0x4f, 0xf8, 0xea, 0xed, 0xa2, 0x52, 0xaf, 0x95, 0x93, 0xe4, 0x0e,
|
||||
0x63, 0x59, 0xe9, 0xf7, 0xca, 0xee, 0x20, 0xef, 0xbe, 0x97, 0x92, 0xe5, 0x26, 0x89, 0xda, 0x4d,
|
||||
0x82, 0x87, 0x6f, 0x5e, 0x06, 0x45, 0x9c, 0xb8, 0xc8, 0x0d, 0xee, 0x96, 0x1a, 0xf2, 0xf8, 0xc2,
|
||||
0xbb, 0xfb, 0xc1, 0xdd, 0x7d, 0xa5, 0x21, 0x17, 0x5e, 0x19, 0xfc, 0x42, 0xf8, 0xf2, 0x1d, 0x94,
|
||||
0x60, 0x1a, 0x20, 0x1f, 0xf0, 0x95, 0x0b, 0xd3, 0x7c, 0x7e, 0xef, 0xee, 0x96, 0x9d, 0xb9, 0x9d,
|
||||
0x1d, 0xd6, 0x4b, 0xef, 0x87, 0xf0, 0xe3, 0xc2, 0xe2, 0x18, 0x76, 0xb8, 0xf0, 0xe2, 0xff, 0x0b,
|
||||
0xc9, 0x10, 0x5f, 0x67, 0x06, 0x9c, 0x02, 0x37, 0x86, 0xcc, 0xe4, 0x1a, 0x8a, 0xb8, 0xe3, 0x97,
|
||||
0x7d, 0x18, 0xf2, 0xae, 0x47, 0x7f, 0xcb, 0xe2, 0x5f, 0x3f, 0x79, 0x86, 0x7b, 0xa1, 0xb5, 0x1b,
|
||||
0x1d, 0x77, 0x3d, 0xfe, 0x20, 0xe0, 0xbd, 0xd1, 0x1f, 0x49, 0x9c, 0xfa, 0xd2, 0xf1, 0x72, 0x4b,
|
||||
0xa3, 0xd5, 0x96, 0x46, 0xeb, 0x2d, 0x8d, 0xbe, 0xb5, 0x14, 0x2d, 0x5b, 0x8a, 0x56, 0x2d, 0x45,
|
||||
0xeb, 0x96, 0xa2, 0x1f, 0x2d, 0x45, 0xdf, 0x7f, 0xd2, 0xe8, 0x63, 0x72, 0xe6, 0xb7, 0xfc, 0x0e,
|
||||
0x00, 0x00, 0xff, 0xff, 0x1f, 0x32, 0xd5, 0x68, 0x68, 0x02, 0x00, 0x00,
|
||||
var fileDescriptor_2e0e4b920403a48c = []byte{
|
||||
// 365 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x4f, 0x6b, 0x22, 0x31,
|
||||
0x18, 0xc6, 0x27, 0x2a, 0xe8, 0x46, 0xc1, 0x25, 0x7b, 0xd8, 0xd9, 0x3d, 0x64, 0xc4, 0xd3, 0x7a,
|
||||
0xd8, 0x0c, 0x08, 0x85, 0x5e, 0x1d, 0xf1, 0x50, 0x4a, 0xa1, 0x84, 0xfe, 0x81, 0x9e, 0x1a, 0x67,
|
||||
0xd2, 0x31, 0x0c, 0x26, 0xc3, 0x18, 0x99, 0x7a, 0xeb, 0x47, 0xe8, 0xc7, 0xf2, 0xe8, 0xd1, 0x93,
|
||||
0xd4, 0xe9, 0x87, 0xe8, 0xb5, 0x18, 0xa3, 0xb5, 0xed, 0xc1, 0x5b, 0xde, 0xf7, 0x79, 0x7e, 0xcf,
|
||||
0xfb, 0xbe, 0x10, 0xe8, 0x27, 0xa7, 0x13, 0x22, 0x94, 0xcf, 0x52, 0x31, 0x66, 0xe1, 0x48, 0x48,
|
||||
0x9e, 0xcd, 0xfc, 0x34, 0x89, 0xfd, 0x6c, 0x2a, 0xb5, 0x18, 0x73, 0x3f, 0xe6, 0x92, 0x67, 0x4c,
|
||||
0xf3, 0x88, 0xa4, 0x99, 0xd2, 0x0a, 0x79, 0x5b, 0x80, 0x1c, 0x02, 0x24, 0x4d, 0x62, 0x62, 0x81,
|
||||
0xbf, 0xff, 0x63, 0xa1, 0x47, 0xd3, 0x21, 0x09, 0xd5, 0xd8, 0x8f, 0x55, 0xac, 0x7c, 0xc3, 0x0d,
|
||||
0xa7, 0x0f, 0xa6, 0x32, 0x85, 0x79, 0x6d, 0xf3, 0xda, 0x1d, 0xd8, 0xa0, 0x2c, 0x1f, 0x3c, 0x6a,
|
||||
0x2e, 0x27, 0x42, 0x49, 0xf4, 0x07, 0x96, 0x33, 0x96, 0xbb, 0xa0, 0x05, 0xfe, 0x35, 0x82, 0x6a,
|
||||
0xb1, 0xf2, 0xca, 0x94, 0xe5, 0x74, 0xd3, 0x6b, 0xdf, 0xc3, 0xda, 0xd5, 0x2c, 0xe5, 0x17, 0x5c,
|
||||
0x33, 0xd4, 0x85, 0x90, 0xa5, 0xe2, 0x86, 0x67, 0x1b, 0xc8, 0xb8, 0x7f, 0x04, 0x68, 0xbe, 0xf2,
|
||||
0x9c, 0x62, 0xe5, 0xc1, 0xde, 0xe5, 0x99, 0x55, 0xe8, 0x81, 0x0b, 0xb5, 0x60, 0x25, 0x11, 0x32,
|
||||
0x72, 0x4b, 0xc6, 0xdd, 0xb0, 0xee, 0xca, 0xb9, 0x90, 0x11, 0x35, 0x4a, 0xfb, 0x0d, 0xc0, 0xea,
|
||||
0xb5, 0x4c, 0xa4, 0xca, 0x25, 0xba, 0x85, 0x35, 0x6d, 0xa7, 0x99, 0xfc, 0x7a, 0xb7, 0x43, 0x8e,
|
||||
0xdc, 0x4e, 0x76, 0xeb, 0x05, 0x3f, 0x6d, 0xf8, 0x7e, 0x61, 0xba, 0x0f, 0xdb, 0x5d, 0x58, 0xfa,
|
||||
0x7e, 0x21, 0xea, 0xc1, 0x66, 0xa8, 0xa4, 0xe6, 0x52, 0x0f, 0x64, 0xa8, 0x22, 0x21, 0x63, 0xb7,
|
||||
0x6c, 0x96, 0xfd, 0x6d, 0xf3, 0x9a, 0xfd, 0xcf, 0x32, 0xfd, 0xea, 0x47, 0x27, 0xb0, 0x6e, 0x5b,
|
||||
0x9b, 0xd1, 0x6e, 0xc5, 0xe0, 0xbf, 0x2c, 0x5e, 0xef, 0x7f, 0x48, 0xf4, 0xd0, 0x17, 0x0c, 0xe6,
|
||||
0x6b, 0xec, 0x2c, 0xd6, 0xd8, 0x59, 0xae, 0xb1, 0xf3, 0x54, 0x60, 0x30, 0x2f, 0x30, 0x58, 0x14,
|
||||
0x18, 0x2c, 0x0b, 0x0c, 0x5e, 0x0a, 0x0c, 0x9e, 0x5f, 0xb1, 0x73, 0xe7, 0x1d, 0xf9, 0x2d, 0xef,
|
||||
0x01, 0x00, 0x00, 0xff, 0xff, 0x2a, 0x9b, 0x09, 0xb3, 0x4f, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *RawExtension) Marshal() (dAtA []byte, err error) {
|
||||
|
||||
12
vendor/k8s.io/apimachinery/pkg/runtime/helper.go
generated
vendored
12
vendor/k8s.io/apimachinery/pkg/runtime/helper.go
generated
vendored
@@ -236,10 +236,14 @@ func (e WithVersionEncoder) Encode(obj Object, stream io.Writer) error {
|
||||
gvk = preferredGVK
|
||||
}
|
||||
}
|
||||
kind.SetGroupVersionKind(gvk)
|
||||
err = e.Encoder.Encode(obj, stream)
|
||||
kind.SetGroupVersionKind(oldGVK)
|
||||
return err
|
||||
|
||||
// The gvk only needs to be set if not already as desired.
|
||||
if gvk != oldGVK {
|
||||
kind.SetGroupVersionKind(gvk)
|
||||
defer kind.SetGroupVersionKind(oldGVK)
|
||||
}
|
||||
|
||||
return e.Encoder.Encode(obj, stream)
|
||||
}
|
||||
|
||||
// WithoutVersionDecoder clears the group version kind of a deserialized object.
|
||||
|
||||
31
vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.pb.go
generated
vendored
31
vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.pb.go
generated
vendored
@@ -15,7 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/runtime/schema/generated.proto
|
||||
// source: k8s.io/apimachinery/pkg/runtime/schema/generated.proto
|
||||
|
||||
package schema
|
||||
|
||||
@@ -39,21 +39,20 @@ var _ = math.Inf
|
||||
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)
|
||||
proto.RegisterFile("k8s.io/apimachinery/pkg/runtime/schema/generated.proto", fileDescriptor_25f8f0eed21c6089)
|
||||
}
|
||||
|
||||
var fileDescriptor_0462724132518e0d = []byte{
|
||||
// 186 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0xce, 0xad, 0x8e, 0xc3, 0x30,
|
||||
0x0c, 0xc0, 0xf1, 0x84, 0x1e, 0x3c, 0x78, 0xc0, 0xb0, 0xec, 0x62, 0x7a, 0xf8, 0xf0, 0xa4, 0xf1,
|
||||
0xb1, 0xb4, 0xf5, 0xd2, 0x28, 0xca, 0x87, 0xd2, 0x64, 0xd2, 0xd8, 0x1e, 0x61, 0x8f, 0x55, 0x58,
|
||||
0x58, 0xb8, 0x66, 0x2f, 0x32, 0x29, 0x2d, 0x18, 0x1c, 0xf3, 0x5f, 0xd6, 0xcf, 0xf2, 0xd7, 0xd1,
|
||||
0xfc, 0x8d, 0x42, 0x7b, 0x34, 0xb9, 0xa5, 0xe8, 0x28, 0xd1, 0x88, 0x17, 0x72, 0xbd, 0x8f, 0xb8,
|
||||
0x2f, 0x64, 0xd0, 0x56, 0x76, 0x83, 0x76, 0x14, 0xaf, 0x18, 0x8c, 0xc2, 0x98, 0x5d, 0xd2, 0x96,
|
||||
0x70, 0xec, 0x06, 0xb2, 0x12, 0x15, 0x39, 0x8a, 0x32, 0x51, 0x2f, 0x42, 0xf4, 0xc9, 0x7f, 0x37,
|
||||
0x9b, 0x13, 0xef, 0x4e, 0x04, 0xa3, 0xc4, 0xee, 0xc4, 0xe6, 0x7e, 0x7e, 0x95, 0x4e, 0x43, 0x6e,
|
||||
0x45, 0xe7, 0x2d, 0x2a, 0xaf, 0x3c, 0x56, 0xde, 0xe6, 0x73, 0xad, 0x1a, 0x75, 0xda, 0xce, 0xfe,
|
||||
0x1f, 0xa6, 0x15, 0xd8, 0xbc, 0x02, 0x5b, 0x56, 0x60, 0xb7, 0x02, 0x7c, 0x2a, 0xc0, 0xe7, 0x02,
|
||||
0x7c, 0x29, 0xc0, 0x1f, 0x05, 0xf8, 0xfd, 0x09, 0xec, 0xd4, 0x7c, 0xf6, 0xf4, 0x2b, 0x00, 0x00,
|
||||
0xff, 0xff, 0x12, 0xb4, 0xae, 0x48, 0xf6, 0x00, 0x00, 0x00,
|
||||
var fileDescriptor_25f8f0eed21c6089 = []byte{
|
||||
// 170 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0xce, 0xa1, 0x0e, 0xc2, 0x30,
|
||||
0x10, 0xc6, 0xf1, 0xd6, 0x22, 0x91, 0x88, 0x93, 0x73, 0xdc, 0x39, 0x82, 0x46, 0xf3, 0x04, 0xb8,
|
||||
0x6e, 0x94, 0xae, 0x59, 0xba, 0x6b, 0xba, 0x4e, 0xe0, 0x78, 0x04, 0x1e, 0x6b, 0x72, 0x72, 0x92,
|
||||
0x95, 0x17, 0x21, 0x69, 0x11, 0x48, 0xdc, 0xfd, 0xc5, 0xef, 0xf2, 0x6d, 0x0e, 0xdd, 0x71, 0x40,
|
||||
0xcb, 0xa4, 0xbc, 0x75, 0xaa, 0x69, 0x6d, 0xaf, 0xc3, 0x9d, 0x7c, 0x67, 0x28, 0x8c, 0x7d, 0xb4,
|
||||
0x4e, 0xd3, 0xd0, 0xb4, 0xda, 0x29, 0x32, 0xba, 0xd7, 0x41, 0x45, 0x7d, 0x45, 0x1f, 0x38, 0xf2,
|
||||
0xb6, 0x2a, 0x0e, 0x7f, 0x1d, 0xfa, 0xce, 0xe0, 0xd7, 0x61, 0x71, 0xbb, 0xbd, 0xb1, 0xb1, 0x1d,
|
||||
0x6b, 0x6c, 0xd8, 0x91, 0x61, 0xc3, 0x94, 0x79, 0x3d, 0xde, 0x72, 0xe5, 0xc8, 0x57, 0x79, 0x7b,
|
||||
0x3a, 0x4f, 0x2b, 0x88, 0x79, 0x05, 0xb1, 0xac, 0x20, 0x1e, 0x09, 0xe4, 0x94, 0x40, 0xce, 0x09,
|
||||
0xe4, 0x92, 0x40, 0xbe, 0x12, 0xc8, 0xe7, 0x1b, 0xc4, 0xa5, 0xfa, 0x6f, 0xf4, 0x27, 0x00, 0x00,
|
||||
0xff, 0xff, 0x97, 0xb8, 0x4d, 0x1f, 0xdd, 0x00, 0x00, 0x00,
|
||||
}
|
||||
|
||||
36
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct/direct.go
generated
vendored
Normal file
36
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct/direct.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2024 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 direct provides functions for marshaling and unmarshaling between arbitrary Go values and
|
||||
// CBOR data, with behavior that is compatible with that of the CBOR serializer. In particular,
|
||||
// types that implement cbor.Marshaler and cbor.Unmarshaler should use these functions.
|
||||
package direct
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes"
|
||||
)
|
||||
|
||||
func Marshal(src interface{}) ([]byte, error) {
|
||||
return modes.Encode.Marshal(src)
|
||||
}
|
||||
|
||||
func Unmarshal(src []byte, dst interface{}) error {
|
||||
return modes.Decode.Unmarshal(src, dst)
|
||||
}
|
||||
|
||||
func Diagnose(src []byte) (string, error) {
|
||||
return modes.Diagnostic.Diagnose(src)
|
||||
}
|
||||
65
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/buffers.go
generated
vendored
Normal file
65
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/buffers.go
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright 2024 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 modes
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var buffers = BufferProvider{p: new(sync.Pool)}
|
||||
|
||||
type buffer struct {
|
||||
bytes.Buffer
|
||||
}
|
||||
|
||||
type pool interface {
|
||||
Get() interface{}
|
||||
Put(interface{})
|
||||
}
|
||||
|
||||
type BufferProvider struct {
|
||||
p pool
|
||||
}
|
||||
|
||||
func (b *BufferProvider) Get() *buffer {
|
||||
if buf, ok := b.p.Get().(*buffer); ok {
|
||||
return buf
|
||||
}
|
||||
return &buffer{}
|
||||
}
|
||||
|
||||
func (b *BufferProvider) Put(buf *buffer) {
|
||||
if buf.Cap() > 3*1024*1024 /* Default MaxRequestBodyBytes */ {
|
||||
// Objects in a sync.Pool are assumed to be fungible. This is not a good assumption
|
||||
// for pools of *bytes.Buffer because a *bytes.Buffer's underlying array grows as
|
||||
// needed to accommodate writes. In Kubernetes, apiservers tend to encode "small"
|
||||
// objects very frequently and much larger objects (especially large lists) only
|
||||
// occasionally. Under steady load, pooled buffers tend to be borrowed frequently
|
||||
// enough to prevent them from being released. Over time, each buffer is used to
|
||||
// encode a large object and its capacity increases accordingly. The result is that
|
||||
// practically all buffers in the pool retain much more capacity than needed to
|
||||
// encode most objects.
|
||||
|
||||
// As a basic mitigation for the worst case, buffers with more capacity than the
|
||||
// default max request body size are never returned to the pool.
|
||||
// TODO: Optimize for higher buffer utilization.
|
||||
return
|
||||
}
|
||||
buf.Reset()
|
||||
b.p.Put(buf)
|
||||
}
|
||||
422
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/custom.go
generated
vendored
Normal file
422
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/custom.go
generated
vendored
Normal file
@@ -0,0 +1,422 @@
|
||||
/*
|
||||
Copyright 2024 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 modes
|
||||
|
||||
import (
|
||||
"encoding"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"github.com/fxamacker/cbor/v2"
|
||||
)
|
||||
|
||||
// Returns a non-nil error if and only if the argument's type (or one of its component types, for
|
||||
// composite types) implements json.Marshaler or encoding.TextMarshaler without also implementing
|
||||
// cbor.Marshaler and likewise for the respective Unmarshaler interfaces.
|
||||
//
|
||||
// This is a temporary, graduation-blocking restriction and will be removed in favor of automatic
|
||||
// transcoding between CBOR and JSON/text for these types. This restriction allows CBOR to be
|
||||
// exercised for in-tree and unstructured types while mitigating the risk of mangling out-of-tree
|
||||
// types in client programs.
|
||||
func RejectCustomMarshalers(v interface{}) error {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
rv := reflect.ValueOf(v)
|
||||
if err := marshalerCache.getChecker(rv.Type()).check(rv, maxDepth); err != nil {
|
||||
return fmt.Errorf("unable to serialize %T: %w", v, err)
|
||||
}
|
||||
if err := unmarshalerCache.getChecker(rv.Type()).check(rv, maxDepth); err != nil {
|
||||
return fmt.Errorf("unable to serialize %T: %w", v, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Recursion depth is limited as a basic mitigation against cyclic objects. Objects created by the
|
||||
// decoder shouldn't be able to contain cycles, but practically any object can be passed to the
|
||||
// encoder.
|
||||
var errMaxDepthExceeded = errors.New("object depth exceeds limit (possible cycle?)")
|
||||
|
||||
// The JSON encoder begins detecting cycles after depth 1000. Use a generous limit here, knowing
|
||||
// that it can might deeply nested acyclic objects. The limit will be removed along with the rest of
|
||||
// this mechanism.
|
||||
const maxDepth = 2048
|
||||
|
||||
var marshalerCache = checkers{
|
||||
cborInterface: reflect.TypeFor[cbor.Marshaler](),
|
||||
nonCBORInterfaces: []reflect.Type{
|
||||
reflect.TypeFor[json.Marshaler](),
|
||||
reflect.TypeFor[encoding.TextMarshaler](),
|
||||
},
|
||||
}
|
||||
|
||||
var unmarshalerCache = checkers{
|
||||
cborInterface: reflect.TypeFor[cbor.Unmarshaler](),
|
||||
nonCBORInterfaces: []reflect.Type{
|
||||
reflect.TypeFor[json.Unmarshaler](),
|
||||
reflect.TypeFor[encoding.TextUnmarshaler](),
|
||||
},
|
||||
assumeAddressableValues: true,
|
||||
}
|
||||
|
||||
// checker wraps a function for dynamically checking a value of a specific type for custom JSON
|
||||
// behaviors not matched by a custom CBOR behavior.
|
||||
type checker struct {
|
||||
// check returns a non-nil error if the given value might be marshalled to or from CBOR
|
||||
// using the default behavior for its kind, but marshalled to or from JSON using custom
|
||||
// behavior.
|
||||
check func(rv reflect.Value, depth int) error
|
||||
|
||||
// safe returns true if all values of this type are safe from mismatched custom marshalers.
|
||||
safe func() bool
|
||||
}
|
||||
|
||||
// TODO: stale
|
||||
// Having a single addressable checker for comparisons lets us prune and collapse parts of the
|
||||
// object traversal that are statically known to be safe. Depending on the type, it may be
|
||||
// unnecessary to inspect each value of that type. For example, no value of the built-in type bool
|
||||
// can implement json.Marshaler (a named type whose underlying type is bool could, but it is a
|
||||
// distinct type from bool).
|
||||
var noop = checker{
|
||||
safe: func() bool {
|
||||
return true
|
||||
},
|
||||
check: func(rv reflect.Value, depth int) error {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
type checkers struct {
|
||||
m sync.Map // reflect.Type => *checker
|
||||
|
||||
cborInterface reflect.Type
|
||||
nonCBORInterfaces []reflect.Type
|
||||
|
||||
assumeAddressableValues bool
|
||||
}
|
||||
|
||||
func (cache *checkers) getChecker(rt reflect.Type) checker {
|
||||
if ptr, ok := cache.m.Load(rt); ok {
|
||||
return *ptr.(*checker)
|
||||
}
|
||||
|
||||
return cache.getCheckerInternal(rt, nil)
|
||||
}
|
||||
|
||||
// linked list node representing the path from a composite type to an element type
|
||||
type path struct {
|
||||
Type reflect.Type
|
||||
Parent *path
|
||||
}
|
||||
|
||||
func (p path) cyclic(rt reflect.Type) bool {
|
||||
for ancestor := &p; ancestor != nil; ancestor = ancestor.Parent {
|
||||
if ancestor.Type == rt {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (cache *checkers) getCheckerInternal(rt reflect.Type, parent *path) (c checker) {
|
||||
// Store a placeholder cache entry first to handle cyclic types.
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(1)
|
||||
defer wg.Done()
|
||||
c = checker{
|
||||
safe: func() bool {
|
||||
wg.Wait()
|
||||
return c.safe()
|
||||
},
|
||||
check: func(rv reflect.Value, depth int) error {
|
||||
wg.Wait()
|
||||
return c.check(rv, depth)
|
||||
},
|
||||
}
|
||||
if actual, loaded := cache.m.LoadOrStore(rt, &c); loaded {
|
||||
// Someone else stored an entry for this type, use it.
|
||||
return *actual.(*checker)
|
||||
}
|
||||
|
||||
// Take a nonreflective path for the unstructured container types. They're common and
|
||||
// usually nested inside one another.
|
||||
switch rt {
|
||||
case reflect.TypeFor[map[string]interface{}](), reflect.TypeFor[[]interface{}]():
|
||||
return checker{
|
||||
safe: func() bool {
|
||||
return false
|
||||
},
|
||||
check: func(rv reflect.Value, depth int) error {
|
||||
return checkUnstructuredValue(cache, rv.Interface(), depth)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// It's possible that one of the relevant interfaces is implemented on a type with a pointer
|
||||
// receiver, but that a particular value of that type is not addressable. For example:
|
||||
//
|
||||
// func (Foo) MarshalText() ([]byte, error) { ... }
|
||||
// func (*Foo) MarshalCBOR() ([]byte, error) { ... }
|
||||
//
|
||||
// Both methods are in the method set of *Foo, but the method set of Foo contains only
|
||||
// MarshalText.
|
||||
//
|
||||
// Both the unmarshaler and marshaler checks assume that methods implementing a JSON or text
|
||||
// interface with a pointer receiver are always accessible. Only the unmarshaler check
|
||||
// assumes that CBOR methods with pointer receivers are accessible.
|
||||
|
||||
if rt.Implements(cache.cborInterface) {
|
||||
return noop
|
||||
}
|
||||
for _, unsafe := range cache.nonCBORInterfaces {
|
||||
if rt.Implements(unsafe) {
|
||||
err := fmt.Errorf("%v implements %v without corresponding cbor interface", rt, unsafe)
|
||||
return checker{
|
||||
safe: func() bool {
|
||||
return false
|
||||
},
|
||||
check: func(reflect.Value, int) error {
|
||||
return err
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if cache.assumeAddressableValues && reflect.PointerTo(rt).Implements(cache.cborInterface) {
|
||||
return noop
|
||||
}
|
||||
for _, unsafe := range cache.nonCBORInterfaces {
|
||||
if reflect.PointerTo(rt).Implements(unsafe) {
|
||||
err := fmt.Errorf("%v implements %v without corresponding cbor interface", reflect.PointerTo(rt), unsafe)
|
||||
return checker{
|
||||
safe: func() bool {
|
||||
return false
|
||||
},
|
||||
check: func(reflect.Value, int) error {
|
||||
return err
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self := &path{Type: rt, Parent: parent}
|
||||
|
||||
switch rt.Kind() {
|
||||
case reflect.Array:
|
||||
ce := cache.getCheckerInternal(rt.Elem(), self)
|
||||
rtlen := rt.Len()
|
||||
if rtlen == 0 || (!self.cyclic(rt.Elem()) && ce.safe()) {
|
||||
return noop
|
||||
}
|
||||
return checker{
|
||||
safe: func() bool {
|
||||
return false
|
||||
},
|
||||
check: func(rv reflect.Value, depth int) error {
|
||||
if depth <= 0 {
|
||||
return errMaxDepthExceeded
|
||||
}
|
||||
for i := 0; i < rtlen; i++ {
|
||||
if err := ce.check(rv.Index(i), depth-1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
case reflect.Interface:
|
||||
// All interface values have to be checked because their dynamic type might
|
||||
// implement one of the interesting interfaces or be composed of another type that
|
||||
// does.
|
||||
return checker{
|
||||
safe: func() bool {
|
||||
return false
|
||||
},
|
||||
check: func(rv reflect.Value, depth int) error {
|
||||
if rv.IsNil() {
|
||||
return nil
|
||||
}
|
||||
// Unpacking interfaces must count against recursion depth,
|
||||
// consider this cycle:
|
||||
// > var i interface{}
|
||||
// > var p *interface{} = &i
|
||||
// > i = p
|
||||
// > rv := reflect.ValueOf(i)
|
||||
// > for {
|
||||
// > rv = rv.Elem()
|
||||
// > }
|
||||
if depth <= 0 {
|
||||
return errMaxDepthExceeded
|
||||
}
|
||||
rv = rv.Elem()
|
||||
return cache.getChecker(rv.Type()).check(rv, depth-1)
|
||||
},
|
||||
}
|
||||
|
||||
case reflect.Map:
|
||||
rtk := rt.Key()
|
||||
ck := cache.getCheckerInternal(rtk, self)
|
||||
rte := rt.Elem()
|
||||
ce := cache.getCheckerInternal(rte, self)
|
||||
if !self.cyclic(rtk) && !self.cyclic(rte) && ck.safe() && ce.safe() {
|
||||
return noop
|
||||
}
|
||||
return checker{
|
||||
safe: func() bool {
|
||||
return false
|
||||
},
|
||||
check: func(rv reflect.Value, depth int) error {
|
||||
if depth <= 0 {
|
||||
return errMaxDepthExceeded
|
||||
}
|
||||
iter := rv.MapRange()
|
||||
rvk := reflect.New(rtk).Elem()
|
||||
rve := reflect.New(rte).Elem()
|
||||
for iter.Next() {
|
||||
rvk.SetIterKey(iter)
|
||||
if err := ck.check(rvk, depth-1); err != nil {
|
||||
return err
|
||||
}
|
||||
rve.SetIterValue(iter)
|
||||
if err := ce.check(rve, depth-1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
case reflect.Pointer:
|
||||
ce := cache.getCheckerInternal(rt.Elem(), self)
|
||||
if !self.cyclic(rt.Elem()) && ce.safe() {
|
||||
return noop
|
||||
}
|
||||
return checker{
|
||||
safe: func() bool {
|
||||
return false
|
||||
},
|
||||
check: func(rv reflect.Value, depth int) error {
|
||||
if rv.IsNil() {
|
||||
return nil
|
||||
}
|
||||
if depth <= 0 {
|
||||
return errMaxDepthExceeded
|
||||
}
|
||||
return ce.check(rv.Elem(), depth-1)
|
||||
},
|
||||
}
|
||||
|
||||
case reflect.Slice:
|
||||
ce := cache.getCheckerInternal(rt.Elem(), self)
|
||||
if !self.cyclic(rt.Elem()) && ce.safe() {
|
||||
return noop
|
||||
}
|
||||
return checker{
|
||||
safe: func() bool {
|
||||
return false
|
||||
},
|
||||
check: func(rv reflect.Value, depth int) error {
|
||||
if depth <= 0 {
|
||||
return errMaxDepthExceeded
|
||||
}
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
if err := ce.check(rv.Index(i), depth-1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
case reflect.Struct:
|
||||
type field struct {
|
||||
Index int
|
||||
Checker checker
|
||||
}
|
||||
var fields []field
|
||||
for i := 0; i < rt.NumField(); i++ {
|
||||
f := rt.Field(i)
|
||||
cf := cache.getCheckerInternal(f.Type, self)
|
||||
if !self.cyclic(f.Type) && cf.safe() {
|
||||
continue
|
||||
}
|
||||
fields = append(fields, field{Index: i, Checker: cf})
|
||||
}
|
||||
if len(fields) == 0 {
|
||||
return noop
|
||||
}
|
||||
return checker{
|
||||
safe: func() bool {
|
||||
return false
|
||||
},
|
||||
check: func(rv reflect.Value, depth int) error {
|
||||
if depth <= 0 {
|
||||
return errMaxDepthExceeded
|
||||
}
|
||||
for _, fi := range fields {
|
||||
if err := fi.Checker.check(rv.Field(fi.Index), depth-1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
default:
|
||||
// Not a serializable composite type (funcs and channels are composite types but are
|
||||
// rejected by JSON and CBOR serialization).
|
||||
return noop
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func checkUnstructuredValue(cache *checkers, v interface{}, depth int) error {
|
||||
switch v := v.(type) {
|
||||
case nil, bool, int64, float64, string:
|
||||
return nil
|
||||
case []interface{}:
|
||||
if depth <= 0 {
|
||||
return errMaxDepthExceeded
|
||||
}
|
||||
for _, element := range v {
|
||||
if err := checkUnstructuredValue(cache, element, depth-1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
case map[string]interface{}:
|
||||
if depth <= 0 {
|
||||
return errMaxDepthExceeded
|
||||
}
|
||||
for _, element := range v {
|
||||
if err := checkUnstructuredValue(cache, element, depth-1); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
// Unmarshaling an unstructured doesn't use other dynamic types, but nothing
|
||||
// prevents inserting values with arbitrary dynamic types into unstructured content,
|
||||
// as long as they can be marshalled.
|
||||
rv := reflect.ValueOf(v)
|
||||
return cache.getChecker(rv.Type()).check(rv, depth)
|
||||
}
|
||||
}
|
||||
158
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/decode.go
generated
vendored
Normal file
158
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/decode.go
generated
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
Copyright 2024 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 modes
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/fxamacker/cbor/v2"
|
||||
)
|
||||
|
||||
var simpleValues *cbor.SimpleValueRegistry = func() *cbor.SimpleValueRegistry {
|
||||
var opts []func(*cbor.SimpleValueRegistry) error
|
||||
for sv := 0; sv <= 255; sv++ {
|
||||
// Reject simple values 0-19, 23, and 32-255. The simple values 24-31 are reserved
|
||||
// and considered ill-formed by the CBOR specification. We only accept false (20),
|
||||
// true (21), and null (22).
|
||||
switch sv {
|
||||
case 20: // false
|
||||
case 21: // true
|
||||
case 22: // null
|
||||
case 24, 25, 26, 27, 28, 29, 30, 31: // reserved
|
||||
default:
|
||||
opts = append(opts, cbor.WithRejectedSimpleValue(cbor.SimpleValue(sv)))
|
||||
}
|
||||
}
|
||||
simpleValues, err := cbor.NewSimpleValueRegistryFromDefaults(opts...)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return simpleValues
|
||||
}()
|
||||
|
||||
var Decode cbor.DecMode = func() cbor.DecMode {
|
||||
decode, err := cbor.DecOptions{
|
||||
// Maps with duplicate keys are well-formed but invalid according to the CBOR spec
|
||||
// and never acceptable. Unlike the JSON serializer, inputs containing duplicate map
|
||||
// keys are rejected outright and not surfaced as a strict decoding error.
|
||||
DupMapKey: cbor.DupMapKeyEnforcedAPF,
|
||||
|
||||
// For JSON parity, decoding an RFC3339 string into time.Time needs to be accepted
|
||||
// with or without tagging. If a tag number is present, it must be valid.
|
||||
TimeTag: cbor.DecTagOptional,
|
||||
|
||||
// Observed depth up to 16 in fuzzed batch/v1 CronJobList. JSON implementation limit
|
||||
// is 10000.
|
||||
MaxNestedLevels: 64,
|
||||
|
||||
MaxArrayElements: 1024,
|
||||
MaxMapPairs: 1024,
|
||||
|
||||
// Indefinite-length sequences aren't produced by this serializer, but other
|
||||
// implementations can.
|
||||
IndefLength: cbor.IndefLengthAllowed,
|
||||
|
||||
// Accept inputs that contain CBOR tags.
|
||||
TagsMd: cbor.TagsAllowed,
|
||||
|
||||
// Decode type 0 (unsigned integer) as int64.
|
||||
// TODO: IntDecConvertSignedOrFail errors on overflow, JSON will try to fall back to float64.
|
||||
IntDec: cbor.IntDecConvertSignedOrFail,
|
||||
|
||||
// Disable producing map[cbor.ByteString]interface{}, which is not acceptable for
|
||||
// decodes into interface{}.
|
||||
MapKeyByteString: cbor.MapKeyByteStringForbidden,
|
||||
|
||||
// Error on map keys that don't map to a field in the destination struct.
|
||||
ExtraReturnErrors: cbor.ExtraDecErrorUnknownField,
|
||||
|
||||
// Decode maps into concrete type map[string]interface{} when the destination is an
|
||||
// interface{}.
|
||||
DefaultMapType: reflect.TypeOf(map[string]interface{}(nil)),
|
||||
|
||||
// A CBOR text string whose content is not a valid UTF-8 sequence is well-formed but
|
||||
// invalid according to the CBOR spec. Reject invalid inputs. Encoders are
|
||||
// responsible for ensuring that all text strings they produce contain valid UTF-8
|
||||
// sequences and may use the byte string major type to encode strings that have not
|
||||
// been validated.
|
||||
UTF8: cbor.UTF8RejectInvalid,
|
||||
|
||||
// Never make a case-insensitive match between a map key and a struct field.
|
||||
FieldNameMatching: cbor.FieldNameMatchingCaseSensitive,
|
||||
|
||||
// Produce string concrete values when decoding a CBOR byte string into interface{}.
|
||||
DefaultByteStringType: reflect.TypeOf(""),
|
||||
|
||||
// Allow CBOR byte strings to be decoded into string destination values. If a byte
|
||||
// string is enclosed in an "expected later encoding" tag
|
||||
// (https://www.rfc-editor.org/rfc/rfc8949.html#section-3.4.5.2), then the text
|
||||
// encoding indicated by that tag (e.g. base64) will be applied to the contents of
|
||||
// the byte string.
|
||||
ByteStringToString: cbor.ByteStringToStringAllowedWithExpectedLaterEncoding,
|
||||
|
||||
// Allow CBOR byte strings to match struct fields when appearing as a map key.
|
||||
FieldNameByteString: cbor.FieldNameByteStringAllowed,
|
||||
|
||||
// When decoding an unrecognized tag to interface{}, return the decoded tag content
|
||||
// instead of the default, a cbor.Tag representing a (number, content) pair.
|
||||
UnrecognizedTagToAny: cbor.UnrecognizedTagContentToAny,
|
||||
|
||||
// Decode time tags to interface{} as strings containing RFC 3339 timestamps.
|
||||
TimeTagToAny: cbor.TimeTagToRFC3339Nano,
|
||||
|
||||
// For parity with JSON, strings can be decoded into time.Time if they are RFC 3339
|
||||
// timestamps.
|
||||
ByteStringToTime: cbor.ByteStringToTimeAllowed,
|
||||
|
||||
// Reject NaN and infinite floating-point values since they don't have a JSON
|
||||
// representation (RFC 8259 Section 6).
|
||||
NaN: cbor.NaNDecodeForbidden,
|
||||
Inf: cbor.InfDecodeForbidden,
|
||||
|
||||
// When unmarshaling a byte string into a []byte, assume that the byte string
|
||||
// contains base64-encoded bytes, unless explicitly counterindicated by an "expected
|
||||
// later encoding" tag. This is consistent with the because of unmarshaling a JSON
|
||||
// text into a []byte.
|
||||
ByteStringExpectedFormat: cbor.ByteStringExpectedBase64,
|
||||
|
||||
// Reject the arbitrary-precision integer tags because they can't be faithfully
|
||||
// roundtripped through the allowable Unstructured types.
|
||||
BignumTag: cbor.BignumTagForbidden,
|
||||
|
||||
// Reject anything other than the simple values true, false, and null.
|
||||
SimpleValues: simpleValues,
|
||||
|
||||
// Disable default recognition of types implementing encoding.BinaryUnmarshaler,
|
||||
// which is not recognized for JSON decoding.
|
||||
BinaryUnmarshaler: cbor.BinaryUnmarshalerNone,
|
||||
}.DecMode()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return decode
|
||||
}()
|
||||
|
||||
// DecodeLax is derived from Decode, but does not complain about unknown fields in the input.
|
||||
var DecodeLax cbor.DecMode = func() cbor.DecMode {
|
||||
opts := Decode.DecOptions()
|
||||
opts.ExtraReturnErrors &^= cbor.ExtraDecErrorUnknownField // clear bit
|
||||
dm, err := opts.DecMode()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return dm
|
||||
}()
|
||||
36
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/diagnostic.go
generated
vendored
Normal file
36
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/diagnostic.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2024 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 modes
|
||||
|
||||
import (
|
||||
"github.com/fxamacker/cbor/v2"
|
||||
)
|
||||
|
||||
var Diagnostic cbor.DiagMode = func() cbor.DiagMode {
|
||||
opts := Decode.DecOptions()
|
||||
diagnostic, err := cbor.DiagOptions{
|
||||
ByteStringText: true,
|
||||
|
||||
MaxNestedLevels: opts.MaxNestedLevels,
|
||||
MaxArrayElements: opts.MaxArrayElements,
|
||||
MaxMapPairs: opts.MaxMapPairs,
|
||||
}.DiagMode()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return diagnostic
|
||||
}()
|
||||
155
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/encode.go
generated
vendored
Normal file
155
vendor/k8s.io/apimachinery/pkg/runtime/serializer/cbor/internal/modes/encode.go
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
Copyright 2024 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 modes
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/fxamacker/cbor/v2"
|
||||
)
|
||||
|
||||
var Encode = EncMode{
|
||||
delegate: func() cbor.UserBufferEncMode {
|
||||
encode, err := cbor.EncOptions{
|
||||
// Map keys need to be sorted to have deterministic output, and this is the order
|
||||
// defined in RFC 8949 4.2.1 "Core Deterministic Encoding Requirements".
|
||||
Sort: cbor.SortBytewiseLexical,
|
||||
|
||||
// CBOR supports distinct types for IEEE-754 float16, float32, and float64. Store
|
||||
// floats in the smallest width that preserves value so that equivalent float32 and
|
||||
// float64 values encode to identical bytes, as they do in a JSON
|
||||
// encoding. Satisfies one of the "Core Deterministic Encoding Requirements".
|
||||
ShortestFloat: cbor.ShortestFloat16,
|
||||
|
||||
// Error on attempt to encode NaN and infinite values. This is what the JSON
|
||||
// serializer does.
|
||||
NaNConvert: cbor.NaNConvertReject,
|
||||
InfConvert: cbor.InfConvertReject,
|
||||
|
||||
// Error on attempt to encode math/big.Int values, which can't be faithfully
|
||||
// roundtripped through Unstructured in general (the dynamic numeric types allowed
|
||||
// in Unstructured are limited to float64 and int64).
|
||||
BigIntConvert: cbor.BigIntConvertReject,
|
||||
|
||||
// MarshalJSON for time.Time writes RFC3339 with nanos.
|
||||
Time: cbor.TimeRFC3339Nano,
|
||||
|
||||
// The decoder must be able to accept RFC3339 strings with or without tag 0 (e.g. by
|
||||
// the end of time.Time -> JSON -> Unstructured -> CBOR, the CBOR encoder has no
|
||||
// reliable way of knowing that a particular string originated from serializing a
|
||||
// time.Time), so producing tag 0 has little use.
|
||||
TimeTag: cbor.EncTagNone,
|
||||
|
||||
// Indefinite-length items have multiple encodings and aren't being used anyway, so
|
||||
// disable to avoid an opportunity for nondeterminism.
|
||||
IndefLength: cbor.IndefLengthForbidden,
|
||||
|
||||
// Preserve distinction between nil and empty for slices and maps.
|
||||
NilContainers: cbor.NilContainerAsNull,
|
||||
|
||||
// OK to produce tags.
|
||||
TagsMd: cbor.TagsAllowed,
|
||||
|
||||
// Use the same definition of "empty" as encoding/json.
|
||||
OmitEmpty: cbor.OmitEmptyGoValue,
|
||||
|
||||
// The CBOR types text string and byte string are structurally equivalent, with the
|
||||
// semantic difference that a text string whose content is an invalid UTF-8 sequence
|
||||
// is itself invalid. We reject all invalid text strings at decode time and do not
|
||||
// validate or sanitize all Go strings at encode time. Encoding Go strings to the
|
||||
// byte string type is comparable to the existing Protobuf behavior and cheaply
|
||||
// ensures that the output is valid CBOR.
|
||||
String: cbor.StringToByteString,
|
||||
|
||||
// Encode struct field names to the byte string type rather than the text string
|
||||
// type.
|
||||
FieldName: cbor.FieldNameToByteString,
|
||||
|
||||
// Marshal Go byte arrays to CBOR arrays of integers (as in JSON) instead of byte
|
||||
// strings.
|
||||
ByteArray: cbor.ByteArrayToArray,
|
||||
|
||||
// Marshal []byte to CBOR byte string enclosed in tag 22 (expected later base64
|
||||
// encoding, https://www.rfc-editor.org/rfc/rfc8949.html#section-3.4.5.2), to
|
||||
// interoperate with the existing JSON behavior. This indicates to the decoder that,
|
||||
// when decoding into a string (or unstructured), the resulting value should be the
|
||||
// base64 encoding of the original bytes. No base64 encoding or decoding needs to be
|
||||
// performed for []byte-to-CBOR-to-[]byte roundtrips.
|
||||
ByteSliceLaterFormat: cbor.ByteSliceLaterFormatBase64,
|
||||
|
||||
// Disable default recognition of types implementing encoding.BinaryMarshaler, which
|
||||
// is not recognized for JSON encoding.
|
||||
BinaryMarshaler: cbor.BinaryMarshalerNone,
|
||||
}.UserBufferEncMode()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return encode
|
||||
}(),
|
||||
}
|
||||
|
||||
var EncodeNondeterministic = EncMode{
|
||||
delegate: func() cbor.UserBufferEncMode {
|
||||
opts := Encode.options()
|
||||
opts.Sort = cbor.SortNone // TODO: Use cbor.SortFastShuffle after bump to v2.7.0.
|
||||
em, err := opts.UserBufferEncMode()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return em
|
||||
}(),
|
||||
}
|
||||
|
||||
type EncMode struct {
|
||||
delegate cbor.UserBufferEncMode
|
||||
}
|
||||
|
||||
func (em EncMode) options() cbor.EncOptions {
|
||||
return em.delegate.EncOptions()
|
||||
}
|
||||
|
||||
func (em EncMode) MarshalTo(v interface{}, w io.Writer) error {
|
||||
if buf, ok := w.(*buffer); ok {
|
||||
return em.delegate.MarshalToBuffer(v, &buf.Buffer)
|
||||
}
|
||||
|
||||
buf := buffers.Get()
|
||||
defer buffers.Put(buf)
|
||||
if err := em.delegate.MarshalToBuffer(v, &buf.Buffer); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if _, err := io.Copy(w, buf); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (em EncMode) Marshal(v interface{}) ([]byte, error) {
|
||||
buf := buffers.Get()
|
||||
defer buffers.Put(buf)
|
||||
|
||||
if err := em.MarshalTo(v, &buf.Buffer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
clone := make([]byte, buf.Len())
|
||||
copy(clone, buf.Bytes())
|
||||
|
||||
return clone, nil
|
||||
}
|
||||
1
vendor/k8s.io/apimachinery/pkg/runtime/types.go
generated
vendored
1
vendor/k8s.io/apimachinery/pkg/runtime/types.go
generated
vendored
@@ -46,6 +46,7 @@ const (
|
||||
ContentTypeJSON string = "application/json"
|
||||
ContentTypeYAML string = "application/yaml"
|
||||
ContentTypeProtobuf string = "application/vnd.kubernetes.protobuf"
|
||||
ContentTypeCBOR string = "application/cbor"
|
||||
)
|
||||
|
||||
// RawExtension is used to hold extensions in external versions.
|
||||
|
||||
18
vendor/k8s.io/apimachinery/pkg/util/framer/framer.go
generated
vendored
18
vendor/k8s.io/apimachinery/pkg/util/framer/framer.go
generated
vendored
@@ -147,7 +147,6 @@ func (r *jsonFrameReader) Read(data []byte) (int, error) {
|
||||
|
||||
// RawMessage#Unmarshal appends to data - we reset the slice down to 0 and will either see
|
||||
// data written to data, or be larger than data and a different array.
|
||||
n := len(data)
|
||||
m := json.RawMessage(data[:0])
|
||||
if err := r.decoder.Decode(&m); err != nil {
|
||||
return 0, err
|
||||
@@ -156,12 +155,19 @@ func (r *jsonFrameReader) Read(data []byte) (int, error) {
|
||||
// If capacity of data is less than length of the message, decoder will allocate a new slice
|
||||
// and set m to it, which means we need to copy the partial result back into data and preserve
|
||||
// the remaining result for subsequent reads.
|
||||
if len(m) > n {
|
||||
//nolint:staticcheck // SA4006,SA4010 underlying array of data is modified here.
|
||||
data = append(data[0:0], m[:n]...)
|
||||
r.remaining = m[n:]
|
||||
return n, io.ErrShortBuffer
|
||||
if len(m) > cap(data) {
|
||||
copy(data, m)
|
||||
r.remaining = m[len(data):]
|
||||
return len(data), io.ErrShortBuffer
|
||||
}
|
||||
|
||||
if len(m) > len(data) {
|
||||
// The bytes beyond len(data) were stored in data's underlying array, which we do
|
||||
// not own after this function returns.
|
||||
r.remaining = append([]byte(nil), m[len(data):]...)
|
||||
return len(data), io.ErrShortBuffer
|
||||
}
|
||||
|
||||
return len(m), nil
|
||||
}
|
||||
|
||||
|
||||
9
vendor/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go
generated
vendored
9
vendor/k8s.io/apimachinery/pkg/util/httpstream/httpstream.go
generated
vendored
@@ -116,6 +116,15 @@ func IsUpgradeFailure(err error) bool {
|
||||
return errors.As(err, &upgradeErr)
|
||||
}
|
||||
|
||||
// isHTTPSProxyError returns true if error is Gorilla/Websockets HTTPS Proxy dial error;
|
||||
// false otherwise (see https://github.com/kubernetes/kubernetes/issues/126134).
|
||||
func IsHTTPSProxyError(err error) bool {
|
||||
if err == nil {
|
||||
return false
|
||||
}
|
||||
return strings.Contains(err.Error(), "proxy: unknown scheme: https")
|
||||
}
|
||||
|
||||
// IsUpgradeRequest returns true if the given request is a connection upgrade request
|
||||
func IsUpgradeRequest(req *http.Request) bool {
|
||||
for _, h := range req.Header[http.CanonicalHeaderKey(HeaderConnection)] {
|
||||
|
||||
26
vendor/k8s.io/apimachinery/pkg/util/httpstream/wsstream/conn.go
generated
vendored
26
vendor/k8s.io/apimachinery/pkg/util/httpstream/wsstream/conn.go
generated
vendored
@@ -27,6 +27,7 @@ import (
|
||||
"golang.org/x/net/websocket"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/httpstream"
|
||||
"k8s.io/apimachinery/pkg/util/portforward"
|
||||
"k8s.io/apimachinery/pkg/util/remotecommand"
|
||||
"k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/klog/v2"
|
||||
@@ -106,6 +107,23 @@ func IsWebSocketRequestWithStreamCloseProtocol(req *http.Request) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsWebSocketRequestWithTunnelingProtocol returns true if the request contains headers
|
||||
// identifying that it is requesting a websocket upgrade with a tunneling protocol;
|
||||
// false otherwise.
|
||||
func IsWebSocketRequestWithTunnelingProtocol(req *http.Request) bool {
|
||||
if !IsWebSocketRequest(req) {
|
||||
return false
|
||||
}
|
||||
requestedProtocols := strings.TrimSpace(req.Header.Get(WebSocketProtocolHeader))
|
||||
for _, requestedProtocol := range strings.Split(requestedProtocols, ",") {
|
||||
if protocolSupportsWebsocketTunneling(strings.TrimSpace(requestedProtocol)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// IgnoreReceives reads from a WebSocket until it is closed, then returns. If timeout is set, the
|
||||
// read and write deadlines are pushed every time a new message is received.
|
||||
func IgnoreReceives(ws *websocket.Conn, timeout time.Duration) {
|
||||
@@ -301,6 +319,12 @@ func protocolSupportsStreamClose(protocol string) bool {
|
||||
return protocol == remotecommand.StreamProtocolV5Name
|
||||
}
|
||||
|
||||
// protocolSupportsWebsocketTunneling returns true if the passed protocol
|
||||
// is a tunneled Kubernetes spdy protocol; false otherwise.
|
||||
func protocolSupportsWebsocketTunneling(protocol string) bool {
|
||||
return strings.HasPrefix(protocol, portforward.WebsocketsSPDYTunnelingPrefix) && strings.HasSuffix(protocol, portforward.KubernetesSuffix)
|
||||
}
|
||||
|
||||
// handle implements a websocket handler.
|
||||
func (conn *Conn) handle(ws *websocket.Conn) {
|
||||
conn.initialize(ws)
|
||||
@@ -344,7 +368,7 @@ func (conn *Conn) handle(ws *websocket.Conn) {
|
||||
continue
|
||||
}
|
||||
if _, err := conn.channels[channel].DataFromSocket(data); err != nil {
|
||||
klog.Errorf("Unable to write frame to %d: %v\n%s", channel, err, string(data))
|
||||
klog.Errorf("Unable to write frame (%d bytes) to %d: %v", len(data), channel, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
47
vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
generated
vendored
47
vendor/k8s.io/apimachinery/pkg/util/intstr/generated.pb.go
generated
vendored
@@ -15,7 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto
|
||||
// source: k8s.io/apimachinery/pkg/util/intstr/generated.proto
|
||||
|
||||
package intstr
|
||||
|
||||
@@ -43,7 +43,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
func (m *IntOrString) Reset() { *m = IntOrString{} }
|
||||
func (*IntOrString) ProtoMessage() {}
|
||||
func (*IntOrString) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_94e046ae3ce6121c, []int{0}
|
||||
return fileDescriptor_771bacc35a5ec189, []int{0}
|
||||
}
|
||||
func (m *IntOrString) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@@ -73,30 +73,29 @@ func init() {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/util/intstr/generated.proto", fileDescriptor_94e046ae3ce6121c)
|
||||
proto.RegisterFile("k8s.io/apimachinery/pkg/util/intstr/generated.proto", fileDescriptor_771bacc35a5ec189)
|
||||
}
|
||||
|
||||
var fileDescriptor_94e046ae3ce6121c = []byte{
|
||||
// 292 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0xb1, 0x4a, 0x03, 0x31,
|
||||
0x1c, 0xc6, 0x13, 0x5b, 0x8b, 0x9e, 0xe0, 0x50, 0x1c, 0x8a, 0x43, 0x7a, 0x58, 0x90, 0x5b, 0x4c,
|
||||
0x56, 0x71, 0xec, 0x56, 0x10, 0x84, 0x56, 0x1c, 0xdc, 0xee, 0xda, 0x98, 0x86, 0x6b, 0x93, 0x90,
|
||||
0xfb, 0x9f, 0x70, 0x5b, 0x1f, 0x41, 0x37, 0x47, 0x1f, 0xe7, 0xc6, 0x8e, 0x1d, 0xa4, 0x78, 0xf1,
|
||||
0x2d, 0x9c, 0xe4, 0x72, 0x07, 0x3a, 0x3a, 0x25, 0xdf, 0xf7, 0xfd, 0x7e, 0x19, 0x12, 0xdc, 0xa6,
|
||||
0xd7, 0x19, 0x95, 0x9a, 0xa5, 0x79, 0xc2, 0xad, 0xe2, 0xc0, 0x33, 0xf6, 0xcc, 0xd5, 0x42, 0x5b,
|
||||
0xd6, 0x0e, 0xb1, 0x91, 0xeb, 0x78, 0xbe, 0x94, 0x8a, 0xdb, 0x82, 0x99, 0x54, 0xb0, 0x1c, 0xe4,
|
||||
0x8a, 0x49, 0x05, 0x19, 0x58, 0x26, 0xb8, 0xe2, 0x36, 0x06, 0xbe, 0xa0, 0xc6, 0x6a, 0xd0, 0xfd,
|
||||
0x51, 0x23, 0xd1, 0xbf, 0x12, 0x35, 0xa9, 0xa0, 0xb5, 0x44, 0x1b, 0xe9, 0xfc, 0x4a, 0x48, 0x58,
|
||||
0xe6, 0x09, 0x9d, 0xeb, 0x35, 0x13, 0x5a, 0x68, 0xe6, 0xdd, 0x24, 0x7f, 0xf2, 0xc9, 0x07, 0x7f,
|
||||
0x6b, 0xde, 0xbc, 0x78, 0xc5, 0xc1, 0xc9, 0x44, 0xc1, 0x9d, 0x9d, 0x81, 0x95, 0x4a, 0xf4, 0xa3,
|
||||
0xa0, 0x0b, 0x85, 0xe1, 0x03, 0x1c, 0xe2, 0xa8, 0x33, 0x3e, 0x2b, 0xf7, 0x43, 0xe4, 0xf6, 0xc3,
|
||||
0xee, 0x7d, 0x61, 0xf8, 0x77, 0x7b, 0x4e, 0x3d, 0xd1, 0xbf, 0x0c, 0x7a, 0x52, 0xc1, 0x43, 0xbc,
|
||||
0x1a, 0x1c, 0x84, 0x38, 0x3a, 0x1c, 0x9f, 0xb6, 0x6c, 0x6f, 0xe2, 0xdb, 0x69, 0xbb, 0xd6, 0x5c,
|
||||
0x06, 0xb6, 0xe6, 0x3a, 0x21, 0x8e, 0x8e, 0x7f, 0xb9, 0x99, 0x6f, 0xa7, 0xed, 0x7a, 0x73, 0xf4,
|
||||
0xf6, 0x3e, 0x44, 0x9b, 0x8f, 0x10, 0x8d, 0x27, 0x65, 0x45, 0xd0, 0xb6, 0x22, 0x68, 0x57, 0x11,
|
||||
0xb4, 0x71, 0x04, 0x97, 0x8e, 0xe0, 0xad, 0x23, 0x78, 0xe7, 0x08, 0xfe, 0x74, 0x04, 0xbf, 0x7c,
|
||||
0x11, 0xf4, 0x38, 0xfa, 0xc7, 0x17, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xdc, 0xc4, 0xf0, 0xa0,
|
||||
0x81, 0x01, 0x00, 0x00,
|
||||
var fileDescriptor_771bacc35a5ec189 = []byte{
|
||||
// 277 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0xce, 0xb6, 0x28, 0xd6,
|
||||
0xcb, 0xcc, 0xd7, 0x4f, 0x2c, 0xc8, 0xcc, 0x4d, 0x4c, 0xce, 0xc8, 0xcc, 0x4b, 0x2d, 0xaa, 0xd4,
|
||||
0x2f, 0xc8, 0x4e, 0xd7, 0x2f, 0x2d, 0xc9, 0xcc, 0xd1, 0xcf, 0xcc, 0x2b, 0x29, 0x2e, 0x29, 0xd2,
|
||||
0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0x4a, 0x2c, 0x49, 0x4d, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17,
|
||||
0x52, 0x86, 0x68, 0xd2, 0x43, 0xd6, 0xa4, 0x57, 0x90, 0x9d, 0xae, 0x07, 0xd2, 0xa4, 0x07, 0xd1,
|
||||
0x24, 0xa5, 0x9b, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x9e, 0x9f,
|
||||
0x9e, 0xaf, 0x0f, 0xd6, 0x9b, 0x54, 0x9a, 0x06, 0xe6, 0x81, 0x39, 0x60, 0x16, 0xc4, 0x4c, 0xa5,
|
||||
0x89, 0x8c, 0x5c, 0xdc, 0x9e, 0x79, 0x25, 0xfe, 0x45, 0xc1, 0x25, 0x45, 0x99, 0x79, 0xe9, 0x42,
|
||||
0x1a, 0x5c, 0x2c, 0x25, 0x95, 0x05, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xcc, 0x4e, 0x22, 0x27,
|
||||
0xee, 0xc9, 0x33, 0x3c, 0xba, 0x27, 0xcf, 0x12, 0x52, 0x59, 0x90, 0xfa, 0x0b, 0x4a, 0x07, 0x81,
|
||||
0x55, 0x08, 0xa9, 0x71, 0xb1, 0x65, 0xe6, 0x95, 0x84, 0x25, 0xe6, 0x48, 0x30, 0x29, 0x30, 0x6a,
|
||||
0xb0, 0x3a, 0xf1, 0x41, 0xd5, 0xb2, 0x79, 0x82, 0x45, 0x83, 0xa0, 0xb2, 0x20, 0x75, 0xc5, 0x25,
|
||||
0x45, 0x20, 0x75, 0xcc, 0x0a, 0x8c, 0x1a, 0x9c, 0x08, 0x75, 0xc1, 0x60, 0xd1, 0x20, 0xa8, 0xac,
|
||||
0x15, 0xc7, 0x8c, 0x05, 0xf2, 0x0c, 0x0d, 0x77, 0x14, 0x18, 0x9c, 0x3c, 0x4f, 0x3c, 0x94, 0x63,
|
||||
0xb8, 0xf0, 0x50, 0x8e, 0xe1, 0xc6, 0x43, 0x39, 0x86, 0x86, 0x47, 0x72, 0x8c, 0x27, 0x1e, 0xc9,
|
||||
0x31, 0x5e, 0x78, 0x24, 0xc7, 0x78, 0xe3, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e,
|
||||
0xcb, 0x31, 0x44, 0x29, 0x13, 0x11, 0x84, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x63, 0xa1, 0x0b,
|
||||
0x1e, 0x68, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *IntOrString) Marshal() (dAtA []byte, err error) {
|
||||
|
||||
26
vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go
generated
vendored
26
vendor/k8s.io/apimachinery/pkg/util/intstr/intstr.go
generated
vendored
@@ -25,6 +25,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
cbor "k8s.io/apimachinery/pkg/runtime/serializer/cbor/direct"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
@@ -92,6 +93,20 @@ func (intstr *IntOrString) UnmarshalJSON(value []byte) error {
|
||||
return json.Unmarshal(value, &intstr.IntVal)
|
||||
}
|
||||
|
||||
func (intstr *IntOrString) UnmarshalCBOR(value []byte) error {
|
||||
if err := cbor.Unmarshal(value, &intstr.StrVal); err == nil {
|
||||
intstr.Type = String
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := cbor.Unmarshal(value, &intstr.IntVal); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
intstr.Type = Int
|
||||
return nil
|
||||
}
|
||||
|
||||
// String returns the string value, or the Itoa of the int value.
|
||||
func (intstr *IntOrString) String() string {
|
||||
if intstr == nil {
|
||||
@@ -126,6 +141,17 @@ func (intstr IntOrString) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (intstr IntOrString) MarshalCBOR() ([]byte, error) {
|
||||
switch intstr.Type {
|
||||
case Int:
|
||||
return cbor.Marshal(intstr.IntVal)
|
||||
case String:
|
||||
return cbor.Marshal(intstr.StrVal)
|
||||
default:
|
||||
return nil, fmt.Errorf("impossible IntOrString.Type")
|
||||
}
|
||||
}
|
||||
|
||||
// OpenAPISchemaType is used by the kube-openapi generator when constructing
|
||||
// the OpenAPI spec of this type.
|
||||
//
|
||||
|
||||
2
vendor/k8s.io/apimachinery/pkg/util/managedfields/node.yaml
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/managedfields/node.yaml
generated
vendored
@@ -120,7 +120,7 @@ status:
|
||||
type: PIDPressure
|
||||
- lastHeartbeatTime: "2019-09-20T19:32:50Z"
|
||||
lastTransitionTime: "2019-07-09T16:17:49Z"
|
||||
message: kubelet is posting ready status. AppArmor enabled
|
||||
message: kubelet is posting ready status
|
||||
reason: KubeletReady
|
||||
status: "True"
|
||||
type: Ready
|
||||
|
||||
24
vendor/k8s.io/apimachinery/pkg/util/portforward/constants.go
generated
vendored
Normal file
24
vendor/k8s.io/apimachinery/pkg/util/portforward/constants.go
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
Copyright 2016 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 portforward
|
||||
|
||||
const (
|
||||
PortForwardV1Name = "portforward.k8s.io"
|
||||
WebsocketsSPDYTunnelingPrefix = "SPDY/3.1+"
|
||||
KubernetesSuffix = ".k8s.io"
|
||||
WebsocketsSPDYTunnelingPortForwardV1 = WebsocketsSPDYTunnelingPrefix + PortForwardV1Name
|
||||
)
|
||||
6
vendor/k8s.io/apimachinery/pkg/util/proxy/upgradeaware.go
generated
vendored
6
vendor/k8s.io/apimachinery/pkg/util/proxy/upgradeaware.go
generated
vendored
@@ -36,6 +36,7 @@ import (
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
|
||||
"github.com/mxk/go-flowrate/flowrate"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
@@ -336,6 +337,7 @@ func (h *UpgradeAwareHandler) tryUpgrade(w http.ResponseWriter, req *http.Reques
|
||||
clone.Host = h.Location.Host
|
||||
}
|
||||
clone.URL = &location
|
||||
klog.V(6).Infof("UpgradeAwareProxy: dialing for SPDY upgrade with headers: %v", clone.Header)
|
||||
backendConn, err = h.DialForUpgrade(clone)
|
||||
if err != nil {
|
||||
klog.V(6).Infof("Proxy connection error: %v", err)
|
||||
@@ -370,13 +372,13 @@ func (h *UpgradeAwareHandler) tryUpgrade(w http.ResponseWriter, req *http.Reques
|
||||
// hijacking should be the last step in the upgrade.
|
||||
requestHijacker, ok := w.(http.Hijacker)
|
||||
if !ok {
|
||||
klog.V(6).Infof("Unable to hijack response writer: %T", w)
|
||||
klog.Errorf("Unable to hijack response writer: %T", w)
|
||||
h.Responder.Error(w, req, fmt.Errorf("request connection cannot be hijacked: %T", w))
|
||||
return true
|
||||
}
|
||||
requestHijackedConn, _, err := requestHijacker.Hijack()
|
||||
if err != nil {
|
||||
klog.V(6).Infof("Unable to hijack response: %v", err)
|
||||
klog.Errorf("Unable to hijack response: %v", err)
|
||||
h.Responder.Error(w, req, fmt.Errorf("error hijacking connection: %v", err))
|
||||
return true
|
||||
}
|
||||
|
||||
135
vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go
generated
vendored
135
vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go
generated
vendored
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"runtime"
|
||||
@@ -35,7 +36,7 @@ var (
|
||||
)
|
||||
|
||||
// PanicHandlers is a list of functions which will be invoked when a panic happens.
|
||||
var PanicHandlers = []func(interface{}){logPanic}
|
||||
var PanicHandlers = []func(context.Context, interface{}){logPanic}
|
||||
|
||||
// HandleCrash simply catches a crash and logs an error. Meant to be called via
|
||||
// defer. Additional context-specific handlers can be provided, and will be
|
||||
@@ -43,23 +44,54 @@ var PanicHandlers = []func(interface{}){logPanic}
|
||||
// handlers and logging the panic message.
|
||||
//
|
||||
// E.g., you can provide one or more additional handlers for something like shutting down go routines gracefully.
|
||||
//
|
||||
// TODO(pohly): logcheck:context // HandleCrashWithContext should be used instead of HandleCrash in code which supports contextual logging.
|
||||
func HandleCrash(additionalHandlers ...func(interface{})) {
|
||||
if r := recover(); r != nil {
|
||||
for _, fn := range PanicHandlers {
|
||||
fn(r)
|
||||
}
|
||||
for _, fn := range additionalHandlers {
|
||||
fn(r)
|
||||
}
|
||||
if ReallyCrash {
|
||||
// Actually proceed to panic.
|
||||
panic(r)
|
||||
additionalHandlersWithContext := make([]func(context.Context, interface{}), len(additionalHandlers))
|
||||
for i, handler := range additionalHandlers {
|
||||
handler := handler // capture loop variable
|
||||
additionalHandlersWithContext[i] = func(_ context.Context, r interface{}) {
|
||||
handler(r)
|
||||
}
|
||||
}
|
||||
|
||||
handleCrash(context.Background(), r, additionalHandlersWithContext...)
|
||||
}
|
||||
}
|
||||
|
||||
// HandleCrashWithContext simply catches a crash and logs an error. Meant to be called via
|
||||
// defer. Additional context-specific handlers can be provided, and will be
|
||||
// called in case of panic. HandleCrash actually crashes, after calling the
|
||||
// handlers and logging the panic message.
|
||||
//
|
||||
// E.g., you can provide one or more additional handlers for something like shutting down go routines gracefully.
|
||||
//
|
||||
// The context is used to determine how to log.
|
||||
func HandleCrashWithContext(ctx context.Context, additionalHandlers ...func(context.Context, interface{})) {
|
||||
if r := recover(); r != nil {
|
||||
handleCrash(ctx, r, additionalHandlers...)
|
||||
}
|
||||
}
|
||||
|
||||
// handleCrash is the common implementation of HandleCrash and HandleCrash.
|
||||
// Having those call a common implementation ensures that the stack depth
|
||||
// is the same regardless through which path the handlers get invoked.
|
||||
func handleCrash(ctx context.Context, r any, additionalHandlers ...func(context.Context, interface{})) {
|
||||
for _, fn := range PanicHandlers {
|
||||
fn(ctx, r)
|
||||
}
|
||||
for _, fn := range additionalHandlers {
|
||||
fn(ctx, r)
|
||||
}
|
||||
if ReallyCrash {
|
||||
// Actually proceed to panic.
|
||||
panic(r)
|
||||
}
|
||||
}
|
||||
|
||||
// logPanic logs the caller tree when a panic occurs (except in the special case of http.ErrAbortHandler).
|
||||
func logPanic(r interface{}) {
|
||||
func logPanic(ctx context.Context, r interface{}) {
|
||||
if r == http.ErrAbortHandler {
|
||||
// honor the http.ErrAbortHandler sentinel panic value:
|
||||
// ErrAbortHandler is a sentinel panic value to abort a handler.
|
||||
@@ -73,10 +105,20 @@ func logPanic(r interface{}) {
|
||||
const size = 64 << 10
|
||||
stacktrace := make([]byte, size)
|
||||
stacktrace = stacktrace[:runtime.Stack(stacktrace, false)]
|
||||
|
||||
// We don't really know how many call frames to skip because the Go
|
||||
// panic handler is between us and the code where the panic occurred.
|
||||
// If it's one function (as in Go 1.21), then skipping four levels
|
||||
// gets us to the function which called the `defer HandleCrashWithontext(...)`.
|
||||
logger := klog.FromContext(ctx).WithCallDepth(4)
|
||||
|
||||
// For backwards compatibility, conversion to string
|
||||
// is handled here instead of defering to the logging
|
||||
// backend.
|
||||
if _, ok := r.(string); ok {
|
||||
klog.Errorf("Observed a panic: %s\n%s", r, stacktrace)
|
||||
logger.Error(nil, "Observed a panic", "panic", r, "stacktrace", string(stacktrace))
|
||||
} else {
|
||||
klog.Errorf("Observed a panic: %#v (%v)\n%s", r, r, stacktrace)
|
||||
logger.Error(nil, "Observed a panic", "panic", fmt.Sprintf("%v", r), "panicGoValue", fmt.Sprintf("%#v", r), "stacktrace", string(stacktrace))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,35 +126,76 @@ func logPanic(r interface{}) {
|
||||
// error occurs.
|
||||
// TODO(lavalamp): for testability, this and the below HandleError function
|
||||
// should be packaged up into a testable and reusable object.
|
||||
var ErrorHandlers = []func(error){
|
||||
var ErrorHandlers = []ErrorHandler{
|
||||
logError,
|
||||
(&rudimentaryErrorBackoff{
|
||||
lastErrorTime: time.Now(),
|
||||
// 1ms was the number folks were able to stomach as a global rate limit.
|
||||
// If you need to log errors more than 1000 times a second you
|
||||
// should probably consider fixing your code instead. :)
|
||||
minPeriod: time.Millisecond,
|
||||
}).OnError,
|
||||
func(_ context.Context, _ error, _ string, _ ...interface{}) {
|
||||
(&rudimentaryErrorBackoff{
|
||||
lastErrorTime: time.Now(),
|
||||
// 1ms was the number folks were able to stomach as a global rate limit.
|
||||
// If you need to log errors more than 1000 times a second you
|
||||
// should probably consider fixing your code instead. :)
|
||||
minPeriod: time.Millisecond,
|
||||
}).OnError()
|
||||
},
|
||||
}
|
||||
|
||||
type ErrorHandler func(ctx context.Context, err error, msg string, keysAndValues ...interface{})
|
||||
|
||||
// HandlerError is a method to invoke when a non-user facing piece of code cannot
|
||||
// return an error and needs to indicate it has been ignored. Invoking this method
|
||||
// is preferable to logging the error - the default behavior is to log but the
|
||||
// errors may be sent to a remote server for analysis.
|
||||
//
|
||||
// TODO(pohly): logcheck:context // HandleErrorWithContext should be used instead of HandleError in code which supports contextual logging.
|
||||
func HandleError(err error) {
|
||||
// this is sometimes called with a nil error. We probably shouldn't fail and should do nothing instead
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
handleError(context.Background(), err, "Unhandled Error")
|
||||
}
|
||||
|
||||
// HandlerErrorWithContext is a method to invoke when a non-user facing piece of code cannot
|
||||
// return an error and needs to indicate it has been ignored. Invoking this method
|
||||
// is preferable to logging the error - the default behavior is to log but the
|
||||
// errors may be sent to a remote server for analysis. The context is used to
|
||||
// determine how to log the error.
|
||||
//
|
||||
// If contextual logging is enabled, the default log output is equivalent to
|
||||
//
|
||||
// logr.FromContext(ctx).WithName("UnhandledError").Error(err, msg, keysAndValues...)
|
||||
//
|
||||
// Without contextual logging, it is equivalent to:
|
||||
//
|
||||
// klog.ErrorS(err, msg, keysAndValues...)
|
||||
//
|
||||
// In contrast to HandleError, passing nil for the error is still going to
|
||||
// trigger a log entry. Don't construct a new error or wrap an error
|
||||
// with fmt.Errorf. Instead, add additional information via the mssage
|
||||
// and key/value pairs.
|
||||
//
|
||||
// This variant should be used instead of HandleError because it supports
|
||||
// structured, contextual logging.
|
||||
func HandleErrorWithContext(ctx context.Context, err error, msg string, keysAndValues ...interface{}) {
|
||||
handleError(ctx, err, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// handleError is the common implementation of HandleError and HandleErrorWithContext.
|
||||
// Using this common implementation ensures that the stack depth
|
||||
// is the same regardless through which path the handlers get invoked.
|
||||
func handleError(ctx context.Context, err error, msg string, keysAndValues ...interface{}) {
|
||||
for _, fn := range ErrorHandlers {
|
||||
fn(err)
|
||||
fn(ctx, err, msg, keysAndValues...)
|
||||
}
|
||||
}
|
||||
|
||||
// logError prints an error with the call stack of the location it was reported
|
||||
func logError(err error) {
|
||||
klog.ErrorDepth(2, err)
|
||||
// logError prints an error with the call stack of the location it was reported.
|
||||
// It expects to be called as <caller> -> HandleError[WithContext] -> handleError -> logError.
|
||||
func logError(ctx context.Context, err error, msg string, keysAndValues ...interface{}) {
|
||||
logger := klog.FromContext(ctx).WithCallDepth(3)
|
||||
logger = klog.LoggerWithName(logger, "UnhandledError")
|
||||
logger.Error(err, msg, keysAndValues...) //nolint:logcheck // logcheck complains about unknown key/value pairs.
|
||||
}
|
||||
|
||||
type rudimentaryErrorBackoff struct {
|
||||
@@ -125,7 +208,7 @@ 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) {
|
||||
func (r *rudimentaryErrorBackoff) OnError() {
|
||||
now := time.Now() // start the timer before acquiring the lock
|
||||
r.lastErrorTimeLock.Lock()
|
||||
d := now.Sub(r.lastErrorTime)
|
||||
|
||||
2
vendor/k8s.io/apimachinery/pkg/util/sets/doc.go
generated
vendored
2
vendor/k8s.io/apimachinery/pkg/util/sets/doc.go
generated
vendored
@@ -16,4 +16,4 @@ limitations under the License.
|
||||
|
||||
// Package sets has generic set and specified sets. Generic set will
|
||||
// replace specified ones over time. And specific ones are deprecated.
|
||||
package sets
|
||||
package sets // import "k8s.io/apimachinery/pkg/util/sets"
|
||||
|
||||
53
vendor/k8s.io/apimachinery/pkg/util/sets/ordered.go
generated
vendored
53
vendor/k8s.io/apimachinery/pkg/util/sets/ordered.go
generated
vendored
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
Copyright 2022 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 sets
|
||||
|
||||
// ordered is a constraint that permits any ordered type: any type
|
||||
// that supports the operators < <= >= >.
|
||||
// If future releases of Go add new ordered types,
|
||||
// this constraint will be modified to include them.
|
||||
type ordered interface {
|
||||
integer | float | ~string
|
||||
}
|
||||
|
||||
// integer is a constraint that permits any integer type.
|
||||
// If future releases of Go add new predeclared integer types,
|
||||
// this constraint will be modified to include them.
|
||||
type integer interface {
|
||||
signed | unsigned
|
||||
}
|
||||
|
||||
// float is a constraint that permits any floating-point type.
|
||||
// If future releases of Go add new predeclared floating-point types,
|
||||
// this constraint will be modified to include them.
|
||||
type float interface {
|
||||
~float32 | ~float64
|
||||
}
|
||||
|
||||
// signed is a constraint that permits any signed integer type.
|
||||
// If future releases of Go add new predeclared signed integer types,
|
||||
// this constraint will be modified to include them.
|
||||
type signed interface {
|
||||
~int | ~int8 | ~int16 | ~int32 | ~int64
|
||||
}
|
||||
|
||||
// unsigned is a constraint that permits any unsigned integer type.
|
||||
// If future releases of Go add new predeclared unsigned integer types,
|
||||
// this constraint will be modified to include them.
|
||||
type unsigned interface {
|
||||
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
|
||||
}
|
||||
17
vendor/k8s.io/apimachinery/pkg/util/sets/set.go
generated
vendored
17
vendor/k8s.io/apimachinery/pkg/util/sets/set.go
generated
vendored
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package sets
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"sort"
|
||||
)
|
||||
|
||||
@@ -37,7 +38,7 @@ func New[T comparable](items ...T) Set[T] {
|
||||
// KeySet creates a Set from a keys of a map[comparable](? extends interface{}).
|
||||
// If the value passed in is not actually a map, this will panic.
|
||||
func KeySet[T comparable, V any](theMap map[T]V) Set[T] {
|
||||
ret := Set[T]{}
|
||||
ret := make(Set[T], len(theMap))
|
||||
for keyValue := range theMap {
|
||||
ret.Insert(keyValue)
|
||||
}
|
||||
@@ -67,14 +68,8 @@ func (s Set[T]) Delete(items ...T) Set[T] {
|
||||
// Clear empties the set.
|
||||
// It is preferable to replace the set with a newly constructed set,
|
||||
// but not all callers can do that (when there are other references to the map).
|
||||
// In some cases the set *won't* be fully cleared, e.g. a Set[float32] containing NaN
|
||||
// can't be cleared because NaN can't be removed.
|
||||
// For sets containing items of a type that is reflexive for ==,
|
||||
// this is optimized to a single call to runtime.mapclear().
|
||||
func (s Set[T]) Clear() Set[T] {
|
||||
for key := range s {
|
||||
delete(s, key)
|
||||
}
|
||||
clear(s)
|
||||
return s
|
||||
}
|
||||
|
||||
@@ -193,7 +188,7 @@ func (s1 Set[T]) Equal(s2 Set[T]) bool {
|
||||
return len(s1) == len(s2) && s1.IsSuperset(s2)
|
||||
}
|
||||
|
||||
type sortableSliceOfGeneric[T ordered] []T
|
||||
type sortableSliceOfGeneric[T cmp.Ordered] []T
|
||||
|
||||
func (g sortableSliceOfGeneric[T]) Len() int { return len(g) }
|
||||
func (g sortableSliceOfGeneric[T]) Less(i, j int) bool { return less[T](g[i], g[j]) }
|
||||
@@ -203,7 +198,7 @@ func (g sortableSliceOfGeneric[T]) Swap(i, j int) { g[i], g[j] = g[j], g[i]
|
||||
//
|
||||
// This is a separate function and not a method because not all types supported
|
||||
// by Generic are ordered and only those can be sorted.
|
||||
func List[T ordered](s Set[T]) []T {
|
||||
func List[T cmp.Ordered](s Set[T]) []T {
|
||||
res := make(sortableSliceOfGeneric[T], 0, len(s))
|
||||
for key := range s {
|
||||
res = append(res, key)
|
||||
@@ -236,6 +231,6 @@ func (s Set[T]) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func less[T ordered](lhs, rhs T) bool {
|
||||
func less[T cmp.Ordered](lhs, rhs T) bool {
|
||||
return lhs < rhs
|
||||
}
|
||||
|
||||
4
vendor/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
generated
vendored
4
vendor/k8s.io/apimachinery/pkg/util/strategicpatch/patch.go
generated
vendored
@@ -1361,6 +1361,10 @@ func mergeMap(original, patch map[string]interface{}, schema LookupPatchMeta, me
|
||||
// original. Otherwise, check if we want to preserve it or skip it.
|
||||
// Preserving the null value is useful when we want to send an explicit
|
||||
// delete to the API server.
|
||||
// In some cases, this may lead to inconsistent behavior with create.
|
||||
// ref: https://github.com/kubernetes/kubernetes/issues/123304
|
||||
// To avoid breaking compatibility,
|
||||
// we made corresponding changes on the client side to ensure that the create and patch behaviors are idempotent.
|
||||
if patchV == nil {
|
||||
delete(original, k)
|
||||
if mergeOptions.IgnoreUnmatchedNulls {
|
||||
|
||||
11
vendor/k8s.io/apimachinery/pkg/util/validation/OWNERS
generated
vendored
Normal file
11
vendor/k8s.io/apimachinery/pkg/util/validation/OWNERS
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
# Disable inheritance as this is an api owners file
|
||||
options:
|
||||
no_parent_owners: true
|
||||
approvers:
|
||||
- api-approvers
|
||||
reviewers:
|
||||
- api-reviewers
|
||||
labels:
|
||||
- kind/api-change
|
||||
56
vendor/k8s.io/apimachinery/pkg/util/validation/validation.go
generated
vendored
56
vendor/k8s.io/apimachinery/pkg/util/validation/validation.go
generated
vendored
@@ -19,10 +19,9 @@ package validation
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"net"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
netutils "k8s.io/utils/net"
|
||||
@@ -352,11 +351,12 @@ func IsValidPortName(port string) []string {
|
||||
}
|
||||
|
||||
// IsValidIP tests that the argument is a valid IP address.
|
||||
func IsValidIP(value string) []string {
|
||||
func IsValidIP(fldPath *field.Path, value string) field.ErrorList {
|
||||
var allErrors field.ErrorList
|
||||
if netutils.ParseIPSloppy(value) == nil {
|
||||
return []string{"must be a valid IP address, (e.g. 10.9.8.7 or 2001:db8::ffff)"}
|
||||
allErrors = append(allErrors, field.Invalid(fldPath, value, "must be a valid IP address, (e.g. 10.9.8.7 or 2001:db8::ffff)"))
|
||||
}
|
||||
return nil
|
||||
return allErrors
|
||||
}
|
||||
|
||||
// IsValidIPv4Address tests that the argument is a valid IPv4 address.
|
||||
@@ -379,6 +379,16 @@ func IsValidIPv6Address(fldPath *field.Path, value string) field.ErrorList {
|
||||
return allErrors
|
||||
}
|
||||
|
||||
// IsValidCIDR tests that the argument is a valid CIDR value.
|
||||
func IsValidCIDR(fldPath *field.Path, value string) field.ErrorList {
|
||||
var allErrors field.ErrorList
|
||||
_, _, err := netutils.ParseCIDRSloppy(value)
|
||||
if err != nil {
|
||||
allErrors = append(allErrors, field.Invalid(fldPath, value, "must be a valid CIDR value, (e.g. 10.9.8.0/24 or 2001:db8::/64)"))
|
||||
}
|
||||
return allErrors
|
||||
}
|
||||
|
||||
const percentFmt string = "[0-9]+%"
|
||||
const percentErrMsg string = "a valid percent string must be a numeric string followed by an ending '%'"
|
||||
|
||||
@@ -409,6 +419,9 @@ func IsHTTPHeaderName(value string) []string {
|
||||
const envVarNameFmt = "[-._a-zA-Z][-._a-zA-Z0-9]*"
|
||||
const envVarNameFmtErrMsg string = "a valid environment variable name must consist of alphabetic characters, digits, '_', '-', or '.', and must not start with a digit"
|
||||
|
||||
// TODO(hirazawaui): Rename this when the RelaxedEnvironmentVariableValidation gate is removed.
|
||||
const relaxedEnvVarNameFmtErrMsg string = "a valid environment variable name must consist only of printable ASCII characters other than '='"
|
||||
|
||||
var envVarNameRegexp = regexp.MustCompile("^" + envVarNameFmt + "$")
|
||||
|
||||
// IsEnvVarName tests if a string is a valid environment variable name.
|
||||
@@ -422,6 +435,24 @@ func IsEnvVarName(value string) []string {
|
||||
return errs
|
||||
}
|
||||
|
||||
// IsRelaxedEnvVarName tests if a string is a valid environment variable name.
|
||||
func IsRelaxedEnvVarName(value string) []string {
|
||||
var errs []string
|
||||
|
||||
if len(value) == 0 {
|
||||
errs = append(errs, "environment variable name "+EmptyError())
|
||||
}
|
||||
|
||||
for _, r := range value {
|
||||
if r > unicode.MaxASCII || !unicode.IsPrint(r) || r == '=' {
|
||||
errs = append(errs, relaxedEnvVarNameFmtErrMsg)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return errs
|
||||
}
|
||||
|
||||
const configMapKeyFmt = `[-._a-zA-Z0-9]+`
|
||||
const configMapKeyErrMsg string = "a valid config key must consist of alphanumeric characters, '-', '_' or '.'"
|
||||
|
||||
@@ -493,18 +524,3 @@ func hasChDirPrefix(value string) []string {
|
||||
}
|
||||
return errs
|
||||
}
|
||||
|
||||
// IsValidSocketAddr checks that string represents a valid socket address
|
||||
// as defined in RFC 789. (e.g 0.0.0.0:10254 or [::]:10254))
|
||||
func IsValidSocketAddr(value string) []string {
|
||||
var errs []string
|
||||
ip, port, err := net.SplitHostPort(value)
|
||||
if err != nil {
|
||||
errs = append(errs, "must be a valid socket address format, (e.g. 0.0.0.0:10254 or [::]:10254)")
|
||||
return errs
|
||||
}
|
||||
portInt, _ := strconv.Atoi(port)
|
||||
errs = append(errs, IsValidPortNum(portInt)...)
|
||||
errs = append(errs, IsValidIP(ip)...)
|
||||
return errs
|
||||
}
|
||||
|
||||
112
vendor/k8s.io/apimachinery/pkg/util/version/version.go
generated
vendored
112
vendor/k8s.io/apimachinery/pkg/util/version/version.go
generated
vendored
@@ -23,6 +23,8 @@ import (
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
apimachineryversion "k8s.io/apimachinery/pkg/version"
|
||||
)
|
||||
|
||||
// Version is an opaque representation of a version number
|
||||
@@ -31,6 +33,7 @@ type Version struct {
|
||||
semver bool
|
||||
preRelease string
|
||||
buildMetadata string
|
||||
info apimachineryversion.Info
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -145,6 +148,43 @@ func MustParseGeneric(str string) *Version {
|
||||
return v
|
||||
}
|
||||
|
||||
// Parse tries to do ParseSemantic first to keep more information.
|
||||
// If ParseSemantic fails, it would just do ParseGeneric.
|
||||
func Parse(str string) (*Version, error) {
|
||||
v, err := parse(str, true)
|
||||
if err != nil {
|
||||
return parse(str, false)
|
||||
}
|
||||
return v, err
|
||||
}
|
||||
|
||||
// MustParse is like Parse except that it panics on error
|
||||
func MustParse(str string) *Version {
|
||||
v, err := Parse(str)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// ParseMajorMinor parses a "generic" version string and returns a version with the major and minor version.
|
||||
func ParseMajorMinor(str string) (*Version, error) {
|
||||
v, err := ParseGeneric(str)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return MajorMinor(v.Major(), v.Minor()), nil
|
||||
}
|
||||
|
||||
// MustParseMajorMinor is like ParseMajorMinor except that it panics on error
|
||||
func MustParseMajorMinor(str string) *Version {
|
||||
v, err := ParseMajorMinor(str)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// ParseSemantic parses a version string that exactly obeys the syntax and semantics of
|
||||
// the "Semantic Versioning" specification (http://semver.org/) (although it ignores
|
||||
// leading and trailing whitespace, and allows the version to be preceded by "v"). For
|
||||
@@ -215,6 +255,32 @@ func (v *Version) WithMinor(minor uint) *Version {
|
||||
return &result
|
||||
}
|
||||
|
||||
// SubtractMinor returns the version with offset from the original minor, with the same major and no patch.
|
||||
// If -offset >= current minor, the minor would be 0.
|
||||
func (v *Version) OffsetMinor(offset int) *Version {
|
||||
var minor uint
|
||||
if offset >= 0 {
|
||||
minor = v.Minor() + uint(offset)
|
||||
} else {
|
||||
diff := uint(-offset)
|
||||
if diff < v.Minor() {
|
||||
minor = v.Minor() - diff
|
||||
}
|
||||
}
|
||||
return MajorMinor(v.Major(), minor)
|
||||
}
|
||||
|
||||
// SubtractMinor returns the version diff minor versions back, with the same major and no patch.
|
||||
// If diff >= current minor, the minor would be 0.
|
||||
func (v *Version) SubtractMinor(diff uint) *Version {
|
||||
return v.OffsetMinor(-int(diff))
|
||||
}
|
||||
|
||||
// AddMinor returns the version diff minor versions forward, with the same major and no patch.
|
||||
func (v *Version) AddMinor(diff uint) *Version {
|
||||
return v.OffsetMinor(int(diff))
|
||||
}
|
||||
|
||||
// WithPatch returns copy of the version object with requested patch number
|
||||
func (v *Version) WithPatch(patch uint) *Version {
|
||||
result := *v
|
||||
@@ -224,6 +290,9 @@ func (v *Version) WithPatch(patch uint) *Version {
|
||||
|
||||
// WithPreRelease returns copy of the version object with requested prerelease
|
||||
func (v *Version) WithPreRelease(preRelease string) *Version {
|
||||
if len(preRelease) == 0 {
|
||||
return v
|
||||
}
|
||||
result := *v
|
||||
result.components = []uint{v.Major(), v.Minor(), v.Patch()}
|
||||
result.preRelease = preRelease
|
||||
@@ -345,6 +414,17 @@ func onlyZeros(array []uint) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// EqualTo tests if a version is equal to a given version.
|
||||
func (v *Version) EqualTo(other *Version) bool {
|
||||
if v == nil {
|
||||
return other == nil
|
||||
}
|
||||
if other == nil {
|
||||
return false
|
||||
}
|
||||
return v.compareInternal(other) == 0
|
||||
}
|
||||
|
||||
// AtLeast tests if a version is at least equal to a given minimum version. If both
|
||||
// Versions are Semantic Versions, this will use the Semantic Version comparison
|
||||
// algorithm. Otherwise, it will compare only the numeric components, with non-present
|
||||
@@ -360,6 +440,11 @@ func (v *Version) LessThan(other *Version) bool {
|
||||
return v.compareInternal(other) == -1
|
||||
}
|
||||
|
||||
// GreaterThan tests if a version is greater than a given version.
|
||||
func (v *Version) GreaterThan(other *Version) bool {
|
||||
return v.compareInternal(other) == 1
|
||||
}
|
||||
|
||||
// Compare compares v against a version string (which will be parsed as either Semantic
|
||||
// or non-Semantic depending on v). On success it returns -1 if v is less than other, 1 if
|
||||
// it is greater than other, or 0 if they are equal.
|
||||
@@ -370,3 +455,30 @@ func (v *Version) Compare(other string) (int, error) {
|
||||
}
|
||||
return v.compareInternal(ov), nil
|
||||
}
|
||||
|
||||
// WithInfo returns copy of the version object with requested info
|
||||
func (v *Version) WithInfo(info apimachineryversion.Info) *Version {
|
||||
result := *v
|
||||
result.info = info
|
||||
return &result
|
||||
}
|
||||
|
||||
func (v *Version) Info() *apimachineryversion.Info {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
// in case info is empty, or the major and minor in info is different from the actual major and minor
|
||||
v.info.Major = itoa(v.Major())
|
||||
v.info.Minor = itoa(v.Minor())
|
||||
if v.info.GitVersion == "" {
|
||||
v.info.GitVersion = v.String()
|
||||
}
|
||||
return &v.info
|
||||
}
|
||||
|
||||
func itoa(i uint) string {
|
||||
if i == 0 {
|
||||
return ""
|
||||
}
|
||||
return strconv.Itoa(int(i))
|
||||
}
|
||||
|
||||
40
vendor/k8s.io/apimachinery/pkg/watch/watch.go
generated
vendored
40
vendor/k8s.io/apimachinery/pkg/watch/watch.go
generated
vendored
@@ -27,13 +27,25 @@ import (
|
||||
|
||||
// Interface can be implemented by anything that knows how to watch and report changes.
|
||||
type Interface interface {
|
||||
// Stop stops watching. Will close the channel returned by ResultChan(). Releases
|
||||
// any resources used by the watch.
|
||||
// Stop tells the producer that the consumer is done watching, so the
|
||||
// producer should stop sending events and close the result channel. The
|
||||
// consumer should keep watching for events until the result channel is
|
||||
// closed.
|
||||
//
|
||||
// Because some implementations may create channels when constructed, Stop
|
||||
// must always be called, even if the consumer has not yet called
|
||||
// ResultChan().
|
||||
//
|
||||
// Only the consumer should call Stop(), not the producer. If the producer
|
||||
// errors and needs to stop the watch prematurely, it should instead send
|
||||
// an error event and close the result channel.
|
||||
Stop()
|
||||
|
||||
// ResultChan returns a chan which will receive all the events. If an error occurs
|
||||
// or Stop() is called, the implementation will close this channel and
|
||||
// release any resources used by the watch.
|
||||
// ResultChan returns a channel which will receive events from the event
|
||||
// producer. If an error occurs or Stop() is called, the producer must
|
||||
// close this channel and release any resources used by the watch.
|
||||
// Closing the result channel tells the consumer that no more events will be
|
||||
// sent.
|
||||
ResultChan() <-chan Event
|
||||
}
|
||||
|
||||
@@ -322,3 +334,21 @@ func (pw *ProxyWatcher) ResultChan() <-chan Event {
|
||||
func (pw *ProxyWatcher) StopChan() <-chan struct{} {
|
||||
return pw.stopCh
|
||||
}
|
||||
|
||||
// MockWatcher implements watch.Interface with mockable functions.
|
||||
type MockWatcher struct {
|
||||
StopFunc func()
|
||||
ResultChanFunc func() <-chan Event
|
||||
}
|
||||
|
||||
var _ Interface = &MockWatcher{}
|
||||
|
||||
// Stop calls StopFunc
|
||||
func (mw MockWatcher) Stop() {
|
||||
mw.StopFunc()
|
||||
}
|
||||
|
||||
// ResultChan calls ResultChanFunc
|
||||
func (mw MockWatcher) ResultChan() <-chan Event {
|
||||
return mw.ResultChanFunc()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user