kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/iam/v1beta1/register.go (about)

     1  /*
     2  Copyright 2023.
     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 v1beta1 contains API Schema definitions for the iam v1beta1 API group
    18  // +k8s:openapi-gen=true
    19  // +kubebuilder:object:generate=true
    20  // +groupName=iam.kubesphere.io
    21  package v1beta1
    22  
    23  import (
    24  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    25  	"k8s.io/apimachinery/pkg/runtime"
    26  	"k8s.io/apimachinery/pkg/runtime/schema"
    27  )
    28  
    29  var (
    30  	// SchemeGroupVersion is group version used to register these objects
    31  	SchemeGroupVersion = schema.GroupVersion{Group: "iam.kubesphere.io", Version: "v1beta1"}
    32  
    33  	// SchemeBuilder is used to add go types to the GroupVersionKind scheme
    34  	SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
    35  
    36  	// AddToScheme is required by pkg/client/...
    37  	AddToScheme = SchemeBuilder.AddToScheme
    38  )
    39  
    40  // Resource is required by pkg/client/listers/...
    41  func Resource(resource string) schema.GroupResource {
    42  	return SchemeGroupVersion.WithResource(resource).GroupResource()
    43  }
    44  
    45  // Adds the list of known types to the given scheme.
    46  func addKnownTypes(scheme *runtime.Scheme) error {
    47  	scheme.AddKnownTypes(SchemeGroupVersion,
    48  		&Category{},
    49  		&CategoryList{},
    50  		&Role{},
    51  		&RoleList{},
    52  		&ClusterRole{},
    53  		&ClusterRoleList{},
    54  		&WorkspaceRole{},
    55  		&WorkspaceRoleList{},
    56  		&GlobalRole{},
    57  		&GlobalRoleList{},
    58  		&RoleTemplate{},
    59  		&RoleTemplateList{},
    60  		&RoleBinding{},
    61  		&RoleBindingList{},
    62  		&ClusterRoleBinding{},
    63  		&ClusterRoleBindingList{},
    64  		&WorkspaceRoleBinding{},
    65  		&WorkspaceRoleBindingList{},
    66  		&GlobalRoleBinding{},
    67  		&GlobalRoleBindingList{},
    68  	)
    69  	metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
    70  	return nil
    71  }