Merge pull request #50665 from xiangpengzhao/hardcode-to-const

Automatic merge from submit-queue (batch tested with PRs 50257, 50247, 50665, 50554, 51077)

Replace hard-code "cpu" and "memory" to consts

**What this PR does / why we need it**:
There are many places using hard coded "cpu" and "memory" as resource name. This PR replace them to consts.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:
/kind cleanup

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue
2017-08-23 02:35:09 -07:00
committed by GitHub
20 changed files with 116 additions and 119 deletions

View File

@@ -30,9 +30,8 @@ func TestResourceHelpers(t *testing.T) {
memoryLimit := resource.MustParse("10G")
resourceSpec := v1.ResourceRequirements{
Limits: v1.ResourceList{
"cpu": cpuLimit,
"memory": memoryLimit,
"kube.io/storage": memoryLimit,
v1.ResourceCPU: cpuLimit,
v1.ResourceMemory: memoryLimit,
},
}
if res := resourceSpec.Limits.Cpu(); res.Cmp(cpuLimit) != 0 {
@@ -43,8 +42,7 @@ func TestResourceHelpers(t *testing.T) {
}
resourceSpec = v1.ResourceRequirements{
Limits: v1.ResourceList{
"memory": memoryLimit,
"kube.io/storage": memoryLimit,
v1.ResourceMemory: memoryLimit,
},
}
if res := resourceSpec.Limits.Cpu(); res.Value() != 0 {