mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +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) {
|
func SetDefaults_NodeResourcesBalancedAllocationArgs(obj *v1beta2.NodeResourcesBalancedAllocationArgs) {
|
||||||
if len(obj.Resources) == 0 {
|
if len(obj.Resources) == 0 {
|
||||||
obj.Resources = append(obj.Resources,
|
obj.Resources = defaultResourceSpec
|
||||||
v1beta2.ResourceSpec{Name: string(v1.ResourceCPU), Weight: 1},
|
return
|
||||||
v1beta2.ResourceSpec{Name: string(v1.ResourceMemory), Weight: 1},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
// If the weight is not set or it is explicitly set to 0, then apply the default weight(1) instead.
|
// 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 {
|
for i := range obj.Resources {
|
||||||
|
@ -213,10 +213,8 @@ func SetDefaults_VolumeBindingArgs(obj *v1beta3.VolumeBindingArgs) {
|
|||||||
|
|
||||||
func SetDefaults_NodeResourcesBalancedAllocationArgs(obj *v1beta3.NodeResourcesBalancedAllocationArgs) {
|
func SetDefaults_NodeResourcesBalancedAllocationArgs(obj *v1beta3.NodeResourcesBalancedAllocationArgs) {
|
||||||
if len(obj.Resources) == 0 {
|
if len(obj.Resources) == 0 {
|
||||||
obj.Resources = append(obj.Resources,
|
obj.Resources = defaultResourceSpec
|
||||||
v1beta3.ResourceSpec{Name: string(v1.ResourceCPU), Weight: 1},
|
return
|
||||||
v1beta3.ResourceSpec{Name: string(v1.ResourceMemory), Weight: 1},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
// If the weight is not set or it is explicitly set to 0, then apply the default weight(1) instead.
|
// 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 {
|
for i := range obj.Resources {
|
||||||
|
Loading…
Reference in New Issue
Block a user