mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-05-28 04:04:39 -04:00
385 lines
14 KiB
Go
385 lines
14 KiB
Go
//go:build !ignore_autogenerated
|
|
// +build !ignore_autogenerated
|
|
|
|
/*
|
|
Copyright 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.
|
|
*/
|
|
|
|
// Code generated by validation-gen. DO NOT EDIT.
|
|
|
|
package v1beta3
|
|
|
|
import (
|
|
context "context"
|
|
fmt "fmt"
|
|
|
|
flowcontrolv1beta3 "k8s.io/api/flowcontrol/v1beta3"
|
|
equality "k8s.io/apimachinery/pkg/api/equality"
|
|
operation "k8s.io/apimachinery/pkg/api/operation"
|
|
safe "k8s.io/apimachinery/pkg/api/safe"
|
|
validate "k8s.io/apimachinery/pkg/api/validate"
|
|
runtime "k8s.io/apimachinery/pkg/runtime"
|
|
field "k8s.io/apimachinery/pkg/util/validation/field"
|
|
)
|
|
|
|
func init() { localSchemeBuilder.Register(RegisterValidations) }
|
|
|
|
// RegisterValidations adds validation functions to the given scheme.
|
|
// Public to allow building arbitrary schemes.
|
|
func RegisterValidations(scheme *runtime.Scheme) error {
|
|
// type PriorityLevelConfiguration
|
|
scheme.AddValidationFunc(
|
|
(*flowcontrolv1beta3.PriorityLevelConfiguration)(nil),
|
|
func(ctx context.Context, op operation.Operation, obj, oldObj interface{}) field.ErrorList {
|
|
switch op.Request.SubresourcePath() {
|
|
case "/", "/status":
|
|
return Validate_PriorityLevelConfiguration(
|
|
ctx, op, nil, /* fldPath */
|
|
obj.(*flowcontrolv1beta3.PriorityLevelConfiguration),
|
|
safe.Cast[*flowcontrolv1beta3.PriorityLevelConfiguration](oldObj))
|
|
}
|
|
return field.ErrorList{
|
|
field.InternalError(nil, fmt.Errorf("no validation found for %T, subresource: %v", obj, op.Request.SubresourcePath())),
|
|
}
|
|
})
|
|
return nil
|
|
}
|
|
|
|
// Validate_LimitResponse validates an instance of LimitResponse according
|
|
// to declarative validation rules in the API schema.
|
|
func Validate_LimitResponse(
|
|
ctx context.Context, op operation.Operation, fldPath *field.Path,
|
|
obj, oldObj *flowcontrolv1beta3.LimitResponse) (errs field.ErrorList) {
|
|
|
|
if e := validate.Discriminated(ctx, op, fldPath, obj, oldObj, "queuing",
|
|
func(obj *flowcontrolv1beta3.LimitResponse) *flowcontrolv1beta3.QueuingConfiguration {
|
|
return obj.Queuing
|
|
},
|
|
func(obj *flowcontrolv1beta3.LimitResponse) flowcontrolv1beta3.LimitResponseType { return obj.Type }, validate.DirectEqualPtr,
|
|
func(ctx context.Context, op operation.Operation, fldPath *field.Path, obj, oldObj *flowcontrolv1beta3.QueuingConfiguration) field.ErrorList {
|
|
errs := field.ErrorList{}
|
|
errs = append(errs, validate.ForbiddenPointer(ctx, op, fldPath, obj, oldObj).MarkAlpha()...)
|
|
return errs
|
|
},
|
|
[]validate.DiscriminatedRule[*flowcontrolv1beta3.QueuingConfiguration, flowcontrolv1beta3.LimitResponseType]{
|
|
|
|
{
|
|
Value: "Queue",
|
|
Validation: func(ctx context.Context, op operation.Operation, fldPath *field.Path, obj, oldObj *flowcontrolv1beta3.QueuingConfiguration) field.ErrorList {
|
|
errs := field.ErrorList{}
|
|
earlyReturn := false
|
|
if e := validate.RequiredPointer(ctx, op, fldPath, obj, oldObj).MarkAlpha(); len(e) != 0 {
|
|
errs = append(errs, e...)
|
|
earlyReturn = true
|
|
}
|
|
if earlyReturn {
|
|
return errs
|
|
}
|
|
return errs
|
|
},
|
|
},
|
|
}); len(e) != 0 {
|
|
errs = append(errs, e...)
|
|
}
|
|
|
|
{ // field flowcontrolv1beta3.LimitResponse.Type
|
|
fn := func(
|
|
fldPath *field.Path,
|
|
obj, oldObj *flowcontrolv1beta3.LimitResponseType,
|
|
oldValueCorrelated bool) (errs field.ErrorList) {
|
|
// don't revalidate unchanged data
|
|
if oldValueCorrelated && op.Type == operation.Update {
|
|
if obj == oldObj || (obj != nil && oldObj != nil && *obj == *oldObj) {
|
|
return nil
|
|
}
|
|
}
|
|
// call field-attached validations
|
|
earlyReturn := false
|
|
if e := validate.RequiredValue(ctx, op, fldPath, obj, oldObj).MarkAlpha().MarkShortCircuit(); len(e) != 0 {
|
|
errs = append(errs, e...)
|
|
earlyReturn = true
|
|
}
|
|
if earlyReturn {
|
|
return // do not proceed
|
|
}
|
|
return
|
|
}
|
|
oldVal := safe.Field(oldObj,
|
|
func(oldObj *flowcontrolv1beta3.LimitResponse) *flowcontrolv1beta3.LimitResponseType {
|
|
return &oldObj.Type
|
|
})
|
|
errs = append(errs, fn(fldPath.Child("type"), &obj.Type, oldVal, oldObj != nil)...)
|
|
}
|
|
|
|
{ // field flowcontrolv1beta3.LimitResponse.Queuing
|
|
fn := func(
|
|
fldPath *field.Path,
|
|
obj, oldObj *flowcontrolv1beta3.QueuingConfiguration,
|
|
oldValueCorrelated bool) (errs field.ErrorList) {
|
|
// don't revalidate unchanged data
|
|
if oldValueCorrelated && op.Type == operation.Update {
|
|
if obj == oldObj || (obj != nil && oldObj != nil && *obj == *oldObj) {
|
|
return nil
|
|
}
|
|
}
|
|
// call field-attached validations
|
|
earlyReturn := false
|
|
if e := validate.OptionalPointer(ctx, op, fldPath, obj, oldObj).MarkAlpha().MarkShortCircuit(); len(e) != 0 {
|
|
earlyReturn = true
|
|
}
|
|
if earlyReturn {
|
|
return // do not proceed
|
|
}
|
|
return
|
|
}
|
|
oldVal := safe.Field(oldObj,
|
|
func(oldObj *flowcontrolv1beta3.LimitResponse) *flowcontrolv1beta3.QueuingConfiguration {
|
|
return oldObj.Queuing
|
|
})
|
|
errs = append(errs, fn(fldPath.Child("queuing"), obj.Queuing, oldVal, oldObj != nil)...)
|
|
}
|
|
|
|
return errs
|
|
}
|
|
|
|
// Validate_LimitedPriorityLevelConfiguration validates an instance of LimitedPriorityLevelConfiguration according
|
|
// to declarative validation rules in the API schema.
|
|
func Validate_LimitedPriorityLevelConfiguration(
|
|
ctx context.Context, op operation.Operation, fldPath *field.Path,
|
|
obj, oldObj *flowcontrolv1beta3.LimitedPriorityLevelConfiguration) (errs field.ErrorList) {
|
|
|
|
// field flowcontrolv1beta3.LimitedPriorityLevelConfiguration.NominalConcurrencyShares has no validation
|
|
|
|
{ // field flowcontrolv1beta3.LimitedPriorityLevelConfiguration.LimitResponse
|
|
fn := func(
|
|
fldPath *field.Path,
|
|
obj, oldObj *flowcontrolv1beta3.LimitResponse,
|
|
oldValueCorrelated bool) (errs field.ErrorList) {
|
|
// don't revalidate unchanged data
|
|
if oldValueCorrelated && op.Type == operation.Update {
|
|
if equality.Semantic.DeepEqual(obj, oldObj) {
|
|
return nil
|
|
}
|
|
}
|
|
// call the type's validation function
|
|
errs = append(errs, Validate_LimitResponse(ctx, op, fldPath, obj, oldObj)...)
|
|
return
|
|
}
|
|
oldVal := safe.Field(oldObj,
|
|
func(oldObj *flowcontrolv1beta3.LimitedPriorityLevelConfiguration) *flowcontrolv1beta3.LimitResponse {
|
|
return &oldObj.LimitResponse
|
|
})
|
|
errs = append(errs, fn(fldPath.Child("limitResponse"), &obj.LimitResponse, oldVal, oldObj != nil)...)
|
|
}
|
|
|
|
// field flowcontrolv1beta3.LimitedPriorityLevelConfiguration.LendablePercent has no validation
|
|
// field flowcontrolv1beta3.LimitedPriorityLevelConfiguration.BorrowingLimitPercent has no validation
|
|
return errs
|
|
}
|
|
|
|
// Validate_PriorityLevelConfiguration validates an instance of PriorityLevelConfiguration according
|
|
// to declarative validation rules in the API schema.
|
|
func Validate_PriorityLevelConfiguration(
|
|
ctx context.Context, op operation.Operation, fldPath *field.Path,
|
|
obj, oldObj *flowcontrolv1beta3.PriorityLevelConfiguration) (errs field.ErrorList) {
|
|
|
|
// field flowcontrolv1beta3.PriorityLevelConfiguration.TypeMeta has no validation
|
|
// field flowcontrolv1beta3.PriorityLevelConfiguration.ObjectMeta has no validation
|
|
|
|
{ // field flowcontrolv1beta3.PriorityLevelConfiguration.Spec
|
|
fn := func(
|
|
fldPath *field.Path,
|
|
obj, oldObj *flowcontrolv1beta3.PriorityLevelConfigurationSpec,
|
|
oldValueCorrelated bool) (errs field.ErrorList) {
|
|
// don't revalidate unchanged data
|
|
if oldValueCorrelated && op.Type == operation.Update {
|
|
if equality.Semantic.DeepEqual(obj, oldObj) {
|
|
return nil
|
|
}
|
|
}
|
|
// call the type's validation function
|
|
errs = append(errs, Validate_PriorityLevelConfigurationSpec(ctx, op, fldPath, obj, oldObj)...)
|
|
return
|
|
}
|
|
oldVal := safe.Field(oldObj,
|
|
func(oldObj *flowcontrolv1beta3.PriorityLevelConfiguration) *flowcontrolv1beta3.PriorityLevelConfigurationSpec {
|
|
return &oldObj.Spec
|
|
})
|
|
errs = append(errs, fn(fldPath.Child("spec"), &obj.Spec, oldVal, oldObj != nil)...)
|
|
}
|
|
|
|
// field flowcontrolv1beta3.PriorityLevelConfiguration.Status has no validation
|
|
return errs
|
|
}
|
|
|
|
// Validate_PriorityLevelConfigurationSpec validates an instance of PriorityLevelConfigurationSpec according
|
|
// to declarative validation rules in the API schema.
|
|
func Validate_PriorityLevelConfigurationSpec(
|
|
ctx context.Context, op operation.Operation, fldPath *field.Path,
|
|
obj, oldObj *flowcontrolv1beta3.PriorityLevelConfigurationSpec) (errs field.ErrorList) {
|
|
|
|
if e := validate.Discriminated(ctx, op, fldPath, obj, oldObj, "exempt",
|
|
func(obj *flowcontrolv1beta3.PriorityLevelConfigurationSpec) *flowcontrolv1beta3.ExemptPriorityLevelConfiguration {
|
|
return obj.Exempt
|
|
},
|
|
func(obj *flowcontrolv1beta3.PriorityLevelConfigurationSpec) flowcontrolv1beta3.PriorityLevelEnablement {
|
|
return obj.Type
|
|
}, validate.SemanticDeepEqual,
|
|
func(ctx context.Context, op operation.Operation, fldPath *field.Path, obj, oldObj *flowcontrolv1beta3.ExemptPriorityLevelConfiguration) field.ErrorList {
|
|
errs := field.ErrorList{}
|
|
errs = append(errs, validate.ForbiddenPointer(ctx, op, fldPath, obj, oldObj).MarkAlpha()...)
|
|
return errs
|
|
},
|
|
[]validate.DiscriminatedRule[*flowcontrolv1beta3.ExemptPriorityLevelConfiguration, flowcontrolv1beta3.PriorityLevelEnablement]{
|
|
|
|
{
|
|
Value: "Exempt",
|
|
Validation: func(ctx context.Context, op operation.Operation, fldPath *field.Path, obj, oldObj *flowcontrolv1beta3.ExemptPriorityLevelConfiguration) field.ErrorList {
|
|
errs := field.ErrorList{}
|
|
earlyReturn := false
|
|
if e := validate.OptionalPointer(ctx, op, fldPath, obj, oldObj).MarkAlpha(); len(e) != 0 {
|
|
earlyReturn = true
|
|
}
|
|
if earlyReturn {
|
|
return errs
|
|
}
|
|
return errs
|
|
},
|
|
},
|
|
}); len(e) != 0 {
|
|
errs = append(errs, e...)
|
|
}
|
|
if e := validate.Discriminated(ctx, op, fldPath, obj, oldObj, "limited",
|
|
func(obj *flowcontrolv1beta3.PriorityLevelConfigurationSpec) *flowcontrolv1beta3.LimitedPriorityLevelConfiguration {
|
|
return obj.Limited
|
|
},
|
|
func(obj *flowcontrolv1beta3.PriorityLevelConfigurationSpec) flowcontrolv1beta3.PriorityLevelEnablement {
|
|
return obj.Type
|
|
}, validate.SemanticDeepEqual,
|
|
func(ctx context.Context, op operation.Operation, fldPath *field.Path, obj, oldObj *flowcontrolv1beta3.LimitedPriorityLevelConfiguration) field.ErrorList {
|
|
errs := field.ErrorList{}
|
|
errs = append(errs, validate.ForbiddenPointer(ctx, op, fldPath, obj, oldObj).MarkAlpha()...)
|
|
return errs
|
|
},
|
|
[]validate.DiscriminatedRule[*flowcontrolv1beta3.LimitedPriorityLevelConfiguration, flowcontrolv1beta3.PriorityLevelEnablement]{
|
|
|
|
{
|
|
Value: "Limited",
|
|
Validation: func(ctx context.Context, op operation.Operation, fldPath *field.Path, obj, oldObj *flowcontrolv1beta3.LimitedPriorityLevelConfiguration) field.ErrorList {
|
|
errs := field.ErrorList{}
|
|
earlyReturn := false
|
|
if e := validate.RequiredPointer(ctx, op, fldPath, obj, oldObj).MarkAlpha(); len(e) != 0 {
|
|
errs = append(errs, e...)
|
|
earlyReturn = true
|
|
}
|
|
if earlyReturn {
|
|
return errs
|
|
}
|
|
return errs
|
|
},
|
|
},
|
|
}); len(e) != 0 {
|
|
errs = append(errs, e...)
|
|
}
|
|
|
|
{ // field flowcontrolv1beta3.PriorityLevelConfigurationSpec.Type
|
|
fn := func(
|
|
fldPath *field.Path,
|
|
obj, oldObj *flowcontrolv1beta3.PriorityLevelEnablement,
|
|
oldValueCorrelated bool) (errs field.ErrorList) {
|
|
// don't revalidate unchanged data
|
|
if oldValueCorrelated && op.Type == operation.Update {
|
|
if obj == oldObj || (obj != nil && oldObj != nil && *obj == *oldObj) {
|
|
return nil
|
|
}
|
|
}
|
|
// call field-attached validations
|
|
earlyReturn := false
|
|
if e := validate.RequiredValue(ctx, op, fldPath, obj, oldObj).MarkAlpha().MarkShortCircuit(); len(e) != 0 {
|
|
errs = append(errs, e...)
|
|
earlyReturn = true
|
|
}
|
|
if earlyReturn {
|
|
return // do not proceed
|
|
}
|
|
return
|
|
}
|
|
oldVal := safe.Field(oldObj,
|
|
func(oldObj *flowcontrolv1beta3.PriorityLevelConfigurationSpec) *flowcontrolv1beta3.PriorityLevelEnablement {
|
|
return &oldObj.Type
|
|
})
|
|
errs = append(errs, fn(fldPath.Child("type"), &obj.Type, oldVal, oldObj != nil)...)
|
|
}
|
|
|
|
{ // field flowcontrolv1beta3.PriorityLevelConfigurationSpec.Limited
|
|
fn := func(
|
|
fldPath *field.Path,
|
|
obj, oldObj *flowcontrolv1beta3.LimitedPriorityLevelConfiguration,
|
|
oldValueCorrelated bool) (errs field.ErrorList) {
|
|
// don't revalidate unchanged data
|
|
if oldValueCorrelated && op.Type == operation.Update {
|
|
if equality.Semantic.DeepEqual(obj, oldObj) {
|
|
return nil
|
|
}
|
|
}
|
|
// call field-attached validations
|
|
earlyReturn := false
|
|
if e := validate.OptionalPointer(ctx, op, fldPath, obj, oldObj).MarkAlpha().MarkShortCircuit(); len(e) != 0 {
|
|
earlyReturn = true
|
|
}
|
|
if earlyReturn {
|
|
return // do not proceed
|
|
}
|
|
// call the type's validation function
|
|
errs = append(errs, Validate_LimitedPriorityLevelConfiguration(ctx, op, fldPath, obj, oldObj)...)
|
|
return
|
|
}
|
|
oldVal := safe.Field(oldObj,
|
|
func(oldObj *flowcontrolv1beta3.PriorityLevelConfigurationSpec) *flowcontrolv1beta3.LimitedPriorityLevelConfiguration {
|
|
return oldObj.Limited
|
|
})
|
|
errs = append(errs, fn(fldPath.Child("limited"), obj.Limited, oldVal, oldObj != nil)...)
|
|
}
|
|
|
|
{ // field flowcontrolv1beta3.PriorityLevelConfigurationSpec.Exempt
|
|
fn := func(
|
|
fldPath *field.Path,
|
|
obj, oldObj *flowcontrolv1beta3.ExemptPriorityLevelConfiguration,
|
|
oldValueCorrelated bool) (errs field.ErrorList) {
|
|
// don't revalidate unchanged data
|
|
if oldValueCorrelated && op.Type == operation.Update {
|
|
if equality.Semantic.DeepEqual(obj, oldObj) {
|
|
return nil
|
|
}
|
|
}
|
|
// call field-attached validations
|
|
earlyReturn := false
|
|
if e := validate.OptionalPointer(ctx, op, fldPath, obj, oldObj).MarkAlpha().MarkShortCircuit(); len(e) != 0 {
|
|
earlyReturn = true
|
|
}
|
|
if earlyReturn {
|
|
return // do not proceed
|
|
}
|
|
return
|
|
}
|
|
oldVal := safe.Field(oldObj,
|
|
func(oldObj *flowcontrolv1beta3.PriorityLevelConfigurationSpec) *flowcontrolv1beta3.ExemptPriorityLevelConfiguration {
|
|
return oldObj.Exempt
|
|
})
|
|
errs = append(errs, fn(fldPath.Child("exempt"), obj.Exempt, oldVal, oldObj != nil)...)
|
|
}
|
|
|
|
return errs
|
|
}
|