mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	normalize to lower resource names
This commit is contained in:
		@@ -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 {
 | 
				
			|||||||
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
 | 
				
			|||||||
	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]
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user