2016-07-27 14:29:31 +00:00
|
|
|
/*
|
|
|
|
Copyright 2016 The Kubernetes Authors.
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2016-09-23 19:10:47 +00:00
|
|
|
package rest
|
2016-07-27 14:29:31 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"k8s.io/kubernetes/pkg/api/rest"
|
|
|
|
"k8s.io/kubernetes/pkg/apis/autoscaling"
|
|
|
|
autoscalingapiv1 "k8s.io/kubernetes/pkg/apis/autoscaling/v1"
|
|
|
|
"k8s.io/kubernetes/pkg/genericapiserver"
|
2016-09-21 13:01:02 +00:00
|
|
|
horizontalpodautoscaleretcd "k8s.io/kubernetes/pkg/registry/autoscaling/horizontalpodautoscaler/etcd"
|
2016-12-01 02:09:56 +00:00
|
|
|
"k8s.io/kubernetes/pkg/registry/generic"
|
2016-07-27 14:29:31 +00:00
|
|
|
)
|
|
|
|
|
2016-09-23 19:10:47 +00:00
|
|
|
type RESTStorageProvider struct{}
|
2016-07-27 14:29:31 +00:00
|
|
|
|
2016-12-01 02:09:56 +00:00
|
|
|
func (p RESTStorageProvider) NewRESTStorage(apiResourceConfigSource genericapiserver.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (genericapiserver.APIGroupInfo, bool) {
|
2016-07-27 14:29:31 +00:00
|
|
|
apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(autoscaling.GroupName)
|
|
|
|
|
|
|
|
if apiResourceConfigSource.AnyResourcesForVersionEnabled(autoscalingapiv1.SchemeGroupVersion) {
|
|
|
|
apiGroupInfo.VersionedResourcesStorageMap[autoscalingapiv1.SchemeGroupVersion.Version] = p.v1Storage(apiResourceConfigSource, restOptionsGetter)
|
|
|
|
apiGroupInfo.GroupMeta.GroupVersion = autoscalingapiv1.SchemeGroupVersion
|
|
|
|
}
|
|
|
|
|
|
|
|
return apiGroupInfo, true
|
|
|
|
}
|
|
|
|
|
2016-12-01 02:09:56 +00:00
|
|
|
func (p RESTStorageProvider) v1Storage(apiResourceConfigSource genericapiserver.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) map[string]rest.Storage {
|
2016-07-27 14:29:31 +00:00
|
|
|
version := autoscalingapiv1.SchemeGroupVersion
|
|
|
|
|
|
|
|
storage := map[string]rest.Storage{}
|
|
|
|
if apiResourceConfigSource.ResourceEnabled(version.WithResource("horizontalpodautoscalers")) {
|
2016-12-01 02:09:56 +00:00
|
|
|
hpaStorage, hpaStatusStorage := horizontalpodautoscaleretcd.NewREST(restOptionsGetter)
|
2016-07-27 14:29:31 +00:00
|
|
|
storage["horizontalpodautoscalers"] = hpaStorage
|
|
|
|
storage["horizontalpodautoscalers/status"] = hpaStatusStorage
|
|
|
|
}
|
|
|
|
return storage
|
|
|
|
}
|
2016-10-27 18:24:11 +00:00
|
|
|
|
|
|
|
func (p RESTStorageProvider) GroupName() string {
|
|
|
|
return autoscaling.GroupName
|
|
|
|
}
|