...

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

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

     1  /*
     2  Copyright 2017 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 v1beta1
    18  
    19  import (
    20  	rbacv1beta1 "k8s.io/api/rbac/v1beta1"
    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 *rbacv1beta1.ClusterRoleBinding) {
    29  	if len(obj.RoleRef.APIGroup) == 0 {
    30  		obj.RoleRef.APIGroup = GroupName
    31  	}
    32  }
    33  func SetDefaults_RoleBinding(obj *rbacv1beta1.RoleBinding) {
    34  	if len(obj.RoleRef.APIGroup) == 0 {
    35  		obj.RoleRef.APIGroup = GroupName
    36  	}
    37  }
    38  func SetDefaults_Subject(obj *rbacv1beta1.Subject) {
    39  	if len(obj.APIGroup) == 0 {
    40  		switch obj.Kind {
    41  		case rbacv1beta1.ServiceAccountKind:
    42  			obj.APIGroup = ""
    43  		case rbacv1beta1.UserKind:
    44  			obj.APIGroup = GroupName
    45  		case rbacv1beta1.GroupKind:
    46  			obj.APIGroup = GroupName
    47  		}
    48  	}
    49  }
    50  

View as plain text