代码拉取完成,页面将自动刷新
package auth
import (
"k8s.io/api/rbac/v1"
)
func rbByOwner(obj interface{}) ([]string, error) {
rb, ok := obj.(*v1.RoleBinding)
if !ok {
return []string{}, nil
}
return getRBOwnerKey(rb), nil
}
func getRBOwnerKey(rb *v1.RoleBinding) []string {
var owners []string
for _, o := range rb.OwnerReferences {
owners = append(owners, string(o.UID))
}
return owners
}
func rbRoleSubjectKey(roleName string, subject v1.Subject) string {
return roleName + "." + subject.Kind + "." + subject.Name
}
func rbRoleSubjectKeys(roleName string, subjects []v1.Subject) []string {
var keys []string
for _, s := range subjects {
keys = append(keys, rbRoleSubjectKey(roleName, s))
}
return keys
}
func rbByRoleAndSubject(obj interface{}) ([]string, error) {
var subjects []v1.Subject
var roleName string
if rb, ok := obj.(*v1.ClusterRoleBinding); ok {
roleName = rb.RoleRef.Name
subjects = rb.Subjects
} else if rb, ok := obj.(*v1.RoleBinding); ok {
roleName = rb.RoleRef.Name
subjects = rb.Subjects
} else {
return []string{}, nil
}
return rbRoleSubjectKeys(roleName, subjects), nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。