2016-02-22 16:14:25 +00:00
|
|
|
/*
|
2016-06-03 00:25:58 +00:00
|
|
|
Copyright 2016 The Kubernetes Authors.
|
2016-02-22 16:14:25 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
2017-01-11 14:09:48 +00:00
|
|
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
2017-06-23 20:56:37 +00:00
|
|
|
"k8s.io/client-go/informers"
|
|
|
|
clientset "k8s.io/client-go/kubernetes"
|
2016-02-22 16:14:25 +00:00
|
|
|
"k8s.io/kubernetes/pkg/quota"
|
|
|
|
"k8s.io/kubernetes/pkg/quota/generic"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NewRegistry returns a registry that knows how to deal with core kubernetes resources
|
2016-10-14 17:44:20 +00:00
|
|
|
// If an informer factory is provided, evaluators will use them.
|
|
|
|
func NewRegistry(kubeClient clientset.Interface, f informers.SharedInformerFactory) quota.Registry {
|
|
|
|
pod := NewPodEvaluator(kubeClient, f)
|
2017-07-19 19:52:39 +00:00
|
|
|
service := NewServiceEvaluator(kubeClient, f)
|
|
|
|
replicationController := NewReplicationControllerEvaluator(kubeClient, f)
|
|
|
|
resourceQuota := NewResourceQuotaEvaluator(kubeClient, f)
|
|
|
|
secret := NewSecretEvaluator(kubeClient, f)
|
|
|
|
configMap := NewConfigMapEvaluator(kubeClient, f)
|
2016-11-06 17:38:27 +00:00
|
|
|
persistentVolumeClaim := NewPersistentVolumeClaimEvaluator(kubeClient, f)
|
2016-02-22 16:14:25 +00:00
|
|
|
return &generic.GenericRegistry{
|
2016-11-21 02:55:31 +00:00
|
|
|
InternalEvaluators: map[schema.GroupKind]quota.Evaluator{
|
2016-02-22 16:14:25 +00:00
|
|
|
pod.GroupKind(): pod,
|
|
|
|
service.GroupKind(): service,
|
|
|
|
replicationController.GroupKind(): replicationController,
|
|
|
|
secret.GroupKind(): secret,
|
2016-02-29 17:02:05 +00:00
|
|
|
configMap.GroupKind(): configMap,
|
2016-02-22 16:14:25 +00:00
|
|
|
resourceQuota.GroupKind(): resourceQuota,
|
|
|
|
persistentVolumeClaim.GroupKind(): persistentVolumeClaim,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|