Commit ac97e9fb authored by derekwaynecarr's avatar derekwaynecarr

normalize to lower resource names

parent f7831dcd
...@@ -19,6 +19,7 @@ package resourcequota ...@@ -19,6 +19,7 @@ package resourcequota
import ( import (
"fmt" "fmt"
"io" "io"
"strings"
"github.com/GoogleCloudPlatform/kubernetes/pkg/admission" "github.com/GoogleCloudPlatform/kubernetes/pkg/admission"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...@@ -60,10 +61,10 @@ func NewResourceQuota(client client.Interface) admission.Interface { ...@@ -60,10 +61,10 @@ func NewResourceQuota(client client.Interface) admission.Interface {
var resourceToResourceName = map[string]api.ResourceName{ var resourceToResourceName = map[string]api.ResourceName{
"pods": api.ResourcePods, "pods": api.ResourcePods,
"services": api.ResourceServices, "services": api.ResourceServices,
"replicationControllers": api.ResourceReplicationControllers, "replicationcontrollers": api.ResourceReplicationControllers,
"resourceQuotas": api.ResourceQuotas, "resourcequotas": api.ResourceQuotas,
"secrets": api.ResourceSecrets, "secrets": api.ResourceSecrets,
"persistentVolumeClaims": api.ResourcePersistentVolumeClaims, "persistentvolumeclaims": api.ResourcePersistentVolumeClaims,
} }
func (q *quota) Admit(a admission.Attributes) (err error) { func (q *quota) Admit(a admission.Attributes) (err error) {
...@@ -137,7 +138,9 @@ func IncrementUsage(a admission.Attributes, status *api.ResourceQuotaStatus, cli ...@@ -137,7 +138,9 @@ func IncrementUsage(a admission.Attributes, status *api.ResourceQuotaStatus, cli
obj := a.GetObject() obj := a.GetObject()
// handle max counts for each kind of resource (pods, services, replicationControllers, etc.) // handle max counts for each kind of resource (pods, services, replicationControllers, etc.)
if a.GetOperation() == "CREATE" { if a.GetOperation() == "CREATE" {
resourceName := resourceToResourceName[a.GetResource()] // TODO v1beta1 had camel case, v1beta3 went to all lower, we can remove this line when we deprecate v1beta1
resourceNormalized := strings.ToLower(a.GetResource())
resourceName := resourceToResourceName[resourceNormalized]
hard, hardFound := status.Hard[resourceName] hard, hardFound := status.Hard[resourceName]
if hardFound { if hardFound {
used, usedFound := status.Used[resourceName] used, usedFound := status.Used[resourceName]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment