k8s.io/kubernetes@v1.29.3/pkg/registry/flowcontrol/ensurer/prioritylevelconfiguration.go (about) 1 /* 2 Copyright 2021 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 ensurer 18 19 import ( 20 flowcontrolv1 "k8s.io/api/flowcontrol/v1" 21 "k8s.io/apimachinery/pkg/api/equality" 22 flowcontrolclient "k8s.io/client-go/kubernetes/typed/flowcontrol/v1" 23 flowcontrollisters "k8s.io/client-go/listers/flowcontrol/v1" 24 flowcontrolapisv1 "k8s.io/kubernetes/pkg/apis/flowcontrol/v1" 25 ) 26 27 func NewPriorityLevelConfigurationOps(client flowcontrolclient.PriorityLevelConfigurationInterface, lister flowcontrollisters.PriorityLevelConfigurationLister) ObjectOps[*flowcontrolv1.PriorityLevelConfiguration] { 28 return NewObjectOps[*flowcontrolv1.PriorityLevelConfiguration](client, lister, (*flowcontrolv1.PriorityLevelConfiguration).DeepCopy, 29 plcReplaceSpec, plcSpecEqualish) 30 } 31 32 func plcReplaceSpec(into, from *flowcontrolv1.PriorityLevelConfiguration) *flowcontrolv1.PriorityLevelConfiguration { 33 copy := into.DeepCopy() 34 copy.Spec = *from.Spec.DeepCopy() 35 return copy 36 } 37 38 func plcSpecEqualish(expected, actual *flowcontrolv1.PriorityLevelConfiguration) bool { 39 copiedExpected := expected.DeepCopy() 40 flowcontrolapisv1.SetObjectDefaults_PriorityLevelConfiguration(copiedExpected) 41 if expected.Name == flowcontrolv1.PriorityLevelConfigurationNameExempt { 42 if actual.Spec.Exempt == nil { 43 return false 44 } 45 copiedExpected.Spec.Exempt.NominalConcurrencyShares = actual.Spec.Exempt.NominalConcurrencyShares 46 copiedExpected.Spec.Exempt.LendablePercent = actual.Spec.Exempt.LendablePercent 47 } 48 return equality.Semantic.DeepEqual(copiedExpected.Spec, actual.Spec) 49 }