mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-16 15:20:17 +00:00
Merge pull request #45088 from xilabao/add-validate-in-create-rolebinding
Automatic merge from submit-queue add validate in create rolebinding
This commit is contained in:
commit
08a030f464
@ -132,7 +132,7 @@ func (s ClusterRoleBindingGeneratorV1) StructuredGenerate() (runtime.Object, err
|
||||
}
|
||||
for _, sa := range sets.NewString(s.ServiceAccounts...).List() {
|
||||
tokens := strings.Split(sa, ":")
|
||||
if len(tokens) != 2 {
|
||||
if len(tokens) != 2 || tokens[0] == "" || tokens[1] == "" {
|
||||
return nil, fmt.Errorf("serviceaccount must be <namespace>:<name>")
|
||||
}
|
||||
clusterRoleBinding.Subjects = append(clusterRoleBinding.Subjects, rbac.Subject{
|
||||
|
@ -147,7 +147,7 @@ func (s RoleBindingGeneratorV1) StructuredGenerate() (runtime.Object, error) {
|
||||
}
|
||||
for _, sa := range sets.NewString(s.ServiceAccounts...).List() {
|
||||
tokens := strings.Split(sa, ":")
|
||||
if len(tokens) != 2 {
|
||||
if len(tokens) != 2 || tokens[1] == "" {
|
||||
return nil, fmt.Errorf("serviceaccount must be <namespace>:<name>")
|
||||
}
|
||||
roleBinding.Subjects = append(roleBinding.Subjects, rbac.Subject{
|
||||
|
Loading…
Reference in New Issue
Block a user