k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/pkg/apis/abac/register.go (about)

     1  /*
     2  Copyright 2015 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 abac
    18  
    19  import (
    20  	"k8s.io/apimachinery/pkg/runtime"
    21  	"k8s.io/apimachinery/pkg/runtime/schema"
    22  	"k8s.io/apimachinery/pkg/runtime/serializer"
    23  )
    24  
    25  // GroupName is the API group for abac
    26  const GroupName = "abac.authorization.kubernetes.io"
    27  
    28  // SchemeGroupVersion is the API group version used to register abac internal
    29  var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal}
    30  
    31  // Scheme is the default instance of runtime.Scheme to which types in the abac API group are api.Registry.
    32  // TODO: remove this, abac should not have its own scheme.
    33  var Scheme = runtime.NewScheme()
    34  
    35  // Codecs provides access to encoding and decoding for the scheme
    36  var Codecs = serializer.NewCodecFactory(Scheme)
    37  
    38  func init() {
    39  	// TODO: delete this, abac should not have its own scheme.
    40  	addKnownTypes(Scheme)
    41  }
    42  
    43  var (
    44  	// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
    45  	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
    46  	// AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme
    47  	AddToScheme = SchemeBuilder.AddToScheme
    48  )
    49  
    50  func addKnownTypes(scheme *runtime.Scheme) error {
    51  	scheme.AddKnownTypes(SchemeGroupVersion,
    52  		&Policy{},
    53  	)
    54  	return nil
    55  }