...

Source file src/k8s.io/kubernetes/pkg/registry/rbac/clusterrole/storage/storage.go

Documentation: k8s.io/kubernetes/pkg/registry/rbac/clusterrole/storage

     1  /*
     2  Copyright 2016 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 storage
    18  
    19  import (
    20  	"k8s.io/apimachinery/pkg/runtime"
    21  	"k8s.io/apiserver/pkg/registry/generic"
    22  	genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
    23  	"k8s.io/apiserver/pkg/registry/rest"
    24  	"k8s.io/kubernetes/pkg/apis/rbac"
    25  	"k8s.io/kubernetes/pkg/registry/rbac/clusterrole"
    26  )
    27  
    28  // REST implements a RESTStorage for ClusterRole
    29  type REST struct {
    30  	*genericregistry.Store
    31  }
    32  
    33  // NewREST returns a RESTStorage object that will work against ClusterRole objects.
    34  func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
    35  	store := &genericregistry.Store{
    36  		NewFunc:                   func() runtime.Object { return &rbac.ClusterRole{} },
    37  		NewListFunc:               func() runtime.Object { return &rbac.ClusterRoleList{} },
    38  		DefaultQualifiedResource:  rbac.Resource("clusterroles"),
    39  		SingularQualifiedResource: rbac.Resource("clusterrole"),
    40  
    41  		CreateStrategy: clusterrole.Strategy,
    42  		UpdateStrategy: clusterrole.Strategy,
    43  		DeleteStrategy: clusterrole.Strategy,
    44  
    45  		// TODO: define table converter that exposes more than name/creation timestamp?
    46  		TableConvertor: rest.NewDefaultTableConvertor(rbac.Resource("clusterroles")),
    47  	}
    48  	options := &generic.StoreOptions{RESTOptions: optsGetter}
    49  	if err := store.CompleteWithOptions(options); err != nil {
    50  		return nil, err
    51  	}
    52  
    53  	return &REST{store}, nil
    54  }
    55  

View as plain text