mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Optimize code for SetDefaults_NodeResourcesBalancedAllocationArgs
This commit is contained in:
parent
df92c0a6fb
commit
8187c2da9e
@ -213,10 +213,8 @@ func SetDefaults_VolumeBindingArgs(obj *v1beta2.VolumeBindingArgs) {
|
||||
|
||||
func SetDefaults_NodeResourcesBalancedAllocationArgs(obj *v1beta2.NodeResourcesBalancedAllocationArgs) {
|
||||
if len(obj.Resources) == 0 {
|
||||
obj.Resources = append(obj.Resources,
|
||||
v1beta2.ResourceSpec{Name: string(v1.ResourceCPU), Weight: 1},
|
||||
v1beta2.ResourceSpec{Name: string(v1.ResourceMemory), Weight: 1},
|
||||
)
|
||||
obj.Resources = defaultResourceSpec
|
||||
return
|
||||
}
|
||||
// If the weight is not set or it is explicitly set to 0, then apply the default weight(1) instead.
|
||||
for i := range obj.Resources {
|
||||
|
@ -213,10 +213,8 @@ func SetDefaults_VolumeBindingArgs(obj *v1beta3.VolumeBindingArgs) {
|
||||
|
||||
func SetDefaults_NodeResourcesBalancedAllocationArgs(obj *v1beta3.NodeResourcesBalancedAllocationArgs) {
|
||||
if len(obj.Resources) == 0 {
|
||||
obj.Resources = append(obj.Resources,
|
||||
v1beta3.ResourceSpec{Name: string(v1.ResourceCPU), Weight: 1},
|
||||
v1beta3.ResourceSpec{Name: string(v1.ResourceMemory), Weight: 1},
|
||||
)
|
||||
obj.Resources = defaultResourceSpec
|
||||
return
|
||||
}
|
||||
// If the weight is not set or it is explicitly set to 0, then apply the default weight(1) instead.
|
||||
for i := range obj.Resources {
|
||||
|
Loading…
Reference in New Issue
Block a user