...

Source file src/k8s.io/kubernetes/pkg/apis/rbac/v1alpha1/defaults.go

Documentation: k8s.io/kubernetes/pkg/apis/rbac/v1alpha1

     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 v1alpha1
    18  
    19  import (
    20  	rbacv1alpha1 "k8s.io/api/rbac/v1alpha1"
    21  	"k8s.io/apimachinery/pkg/runtime"
    22  )
    23  
    24  func addDefaultingFuncs(scheme *runtime.Scheme) error {
    25  	return RegisterDefaults(scheme)
    26  }
    27  
    28  func SetDefaults_ClusterRoleBinding(obj *rbacv1alpha1.ClusterRoleBinding) {
    29  	if len(obj.RoleRef.APIGroup) == 0 {
    30  		obj.RoleRef.APIGroup = GroupName
    31  	}
    32  }
    33  func SetDefaults_RoleBinding(obj *rbacv1alpha1.RoleBinding) {
    34  	if len(obj.RoleRef.APIGroup) == 0 {
    35  		obj.RoleRef.APIGroup = GroupName
    36  	}
    37  }
    38  func SetDefaults_Subject(obj *rbacv1alpha1.Subject) {
    39  	if len(obj.APIVersion) == 0 {
    40  		switch obj.Kind {
    41  		case rbacv1alpha1.ServiceAccountKind:
    42  			obj.APIVersion = "v1"
    43  		case rbacv1alpha1.UserKind:
    44  			obj.APIVersion = SchemeGroupVersion.String()
    45  		case rbacv1alpha1.GroupKind:
    46  			obj.APIVersion = SchemeGroupVersion.String()
    47  		}
    48  	}
    49  }
    50  

View as plain text