k8s.io/kubernetes@v1.29.3/pkg/apis/flowcontrol/fuzzer/fuzzer.go (about) 1 /* 2 Copyright 2022 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package fuzzer 18 19 import ( 20 fuzz "github.com/google/gofuzz" 21 22 runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" 23 "k8s.io/kubernetes/pkg/apis/flowcontrol" 24 "k8s.io/utils/ptr" 25 ) 26 27 // Funcs returns the fuzzer functions for the flowcontrol api group. 28 var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { 29 return []interface{}{ 30 func(obj *flowcontrol.LimitedPriorityLevelConfiguration, c fuzz.Continue) { 31 c.FuzzNoCustom(obj) // fuzz self without calling this function again 32 33 // NOTE: setting a zero value here will cause the roundtrip 34 // test (from internal to v1beta2, v1beta1) to fail 35 if obj.NominalConcurrencyShares == 0 { 36 obj.NominalConcurrencyShares = int32(1) 37 } 38 if obj.LendablePercent == nil { 39 obj.LendablePercent = ptr.To(int32(0)) 40 } 41 }, 42 func(obj *flowcontrol.ExemptPriorityLevelConfiguration, c fuzz.Continue) { 43 c.FuzzNoCustom(obj) // fuzz self without calling this function again 44 if obj.NominalConcurrencyShares == nil { 45 obj.NominalConcurrencyShares = ptr.To(int32(0)) 46 } 47 if obj.LendablePercent == nil { 48 obj.LendablePercent = ptr.To(int32(0)) 49 } 50 }, 51 } 52 }