...

Source file src/k8s.io/kube-aggregator/pkg/registry/apiservice/rest/storage_apiservice.go

Documentation: k8s.io/kube-aggregator/pkg/registry/apiservice/rest

     1  /*
     2  Copyright 2018 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package rest
    18  
    19  import (
    20  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  	"k8s.io/apiserver/pkg/registry/generic"
    22  	"k8s.io/apiserver/pkg/registry/rest"
    23  	genericapiserver "k8s.io/apiserver/pkg/server"
    24  	serverstorage "k8s.io/apiserver/pkg/server/storage"
    25  
    26  	"k8s.io/kube-aggregator/pkg/apis/apiregistration"
    27  	v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
    28  	aggregatorscheme "k8s.io/kube-aggregator/pkg/apiserver/scheme"
    29  	apiservicestorage "k8s.io/kube-aggregator/pkg/registry/apiservice/etcd"
    30  )
    31  
    32  // NewRESTStorage returns an APIGroupInfo object that will work against apiservice.
    33  func NewRESTStorage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter, shouldServeBeta bool) genericapiserver.APIGroupInfo {
    34  	apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(apiregistration.GroupName, aggregatorscheme.Scheme, metav1.ParameterCodec, aggregatorscheme.Codecs)
    35  
    36  	storage := map[string]rest.Storage{}
    37  
    38  	if resource := "apiservices"; apiResourceConfigSource.ResourceEnabled(v1.SchemeGroupVersion.WithResource(resource)) {
    39  		apiServiceREST := apiservicestorage.NewREST(aggregatorscheme.Scheme, restOptionsGetter)
    40  		storage[resource] = apiServiceREST
    41  		storage[resource+"/status"] = apiservicestorage.NewStatusREST(aggregatorscheme.Scheme, apiServiceREST)
    42  	}
    43  
    44  	if len(storage) > 0 {
    45  		apiGroupInfo.VersionedResourcesStorageMap["v1"] = storage
    46  	}
    47  
    48  	return apiGroupInfo
    49  }
    50  

View as plain text