Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
Refactor if chain to case
Browse files Browse the repository at this point in the history
  • Loading branch information
errm committed Sep 18, 2018
1 parent d9104ed commit b2c595b
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,15 @@ func maxPods(instanceType *string) int {
func reservedCPU(instanceType *string) string {
cores := InstanceCores[*instanceType]
reserved := 0.0
for i := 0; i < cores; i++ {
if i < 1 {
for core := 1; core <= cores; core++ {
switch core {
case 1:
reserved += 60.0
} else if i < 2 {
case 2:
reserved += 10.0
} else if i < 4 {
case 3, 4:
reserved += 5.0
} else {
default:
reserved += 2.5
}
}
Expand All @@ -132,15 +133,16 @@ func reservedMemory(instanceType *string) string {
memory := InstanceMemory[*instanceType]
reserved := 0.0
for i := 0; i < memory; i++ {
if i < 4096 {
switch {
case i < 4096:
reserved += 0.25
} else if i < 8192 {
case i < 8192:
reserved += 0.2
} else if i < 16384 {
case i < 16384:
reserved += 0.1
} else if i < 131072 {
case i < 131072:
reserved += 0.06
} else {
default:
reserved += 0.02
}
}
Expand Down

0 comments on commit b2c595b

Please sign in to comment.