// TODO we need to remove the global mutable state from all roles / bindings so we know this function is safe to call
763784
func addDefaultMetadata(obj runtime.Object) {
	metadata, err := meta.Accessor(obj)
	if err != nil {
		// if this happens, then some static code is broken
		panic(err)
	}

	annotations := metadata.GetAnnotations()
	if annotations == nil {
		annotations = map[string]string{}
	}
	for k, v := range bootstrappolicy.Annotation {
		annotations[k] = v
	}
	metadata.SetAnnotations(annotations)
}
464791
func (s RoleBindingGeneratorV1) StructuredGenerate() (runtime.Object, error) {
	if err := s.validate(); err != nil {
		return nil, err
	}
	roleBinding := &rbacv1.RoleBinding{}
	roleBinding.Name = s.Name

	switch {
	case len(s.Role) > 0:
		roleBinding.RoleRef = rbacv1.RoleRef{
			APIGroup: rbacv1.GroupName,
			Kind:     "Role",
			Name:     s.Role,
		}
	case len(s.ClusterRole) > 0:
		roleBinding.RoleRef = rbacv1.RoleRef{
			APIGroup: rbacv1.GroupName,
			Kind:     "ClusterRole",
			Name:     s.ClusterRole,
		}
	}

	for _, user := range sets.NewString(s.Users...).List() {
		roleBinding.Subjects = append(roleBinding.Subjects, rbacv1.Subject{
			Kind:     rbacv1.UserKind,
			APIGroup: rbacv1.GroupName,
			Name:     user,
		})
	}
	for _, group := range sets.NewString(s.Groups...).List() {
		roleBinding.Subjects = append(roleBinding.Subjects, rbacv1.Subject{
			Kind:     rbacv1.GroupKind,
			APIGroup: rbacv1.GroupName,
			Name:     group,
		})
	}
	for _, sa := range sets.NewString(s.ServiceAccounts...).List() {
		tokens := strings.Split(sa, ":")
		if len(tokens) != 2 || tokens[1] == "" {
			return nil, fmt.Errorf("serviceaccount must be <namespace>:<name>")
		}
		roleBinding.Subjects = append(roleBinding.Subjects, rbacv1.Subject{
			Kind:      rbacv1.ServiceAccountKind,
			APIGroup:  "",
			Namespace: tokens[0],
			Name:      tokens[1],
		})
	}

	return roleBinding, nil
}
440893
func RoleToRBAC(obj *authorizationapi.Role) (*rbacv1.Role, error) {
	// do a deep copy here since conversion does not guarantee a new object.
	objCopy := obj.DeepCopy()

	convertedObjInternal := &rbac.Role{}
	if err := rbacconversion.Convert_authorization_Role_To_rbac_Role(objCopy, convertedObjInternal, nil); err != nil {
		return nil, err
	}

	convertedObj := &rbacv1.Role{}
	if err := rbacv1helpers.Convert_rbac_Role_To_v1_Role(convertedObjInternal, convertedObj, nil); err != nil {
		return nil, err
	}

	return convertedObj, nil
}
1040665
func golua_callpanicfunction(gostateindex uintptr, id uint) int {
	L1 := getGoState(gostateindex)
	f := L1.registry[id].(LuaGoFunction)
	return f(L1)
}
473323
func (v *version) Roles() RoleInformer {
	return &roleInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
849209
func (s *RoleService) UpdateRole(p *UpdateRoleParams) (*UpdateRoleResponse, error) {
	resp, err := s.cs.newRequest("updateRole", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r UpdateRoleResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
1178820
func (fs *KBFSOpsStandard) PushStatusChange() {
	fs.currentStatus.PushStatusChange()

	fs.log.CDebugf(nil, "Asking for an edit re-init after status change")
	fs.editActivity.Add(1)
	go fs.initTlfsForEditHistories()
}
1066140
func (tr *Repo) GetAllLoadedRoles() []*data.Role {
	var res []*data.Role
	if tr.Root == nil {
		// if root isn't loaded, we should consider we have no loaded roles because we can't
		// trust any other state that might be present
		return res
	}
	for name, rr := range tr.Root.Signed.Roles {
		res = append(res, &data.Role{
			RootRole: *rr,
			Name:     name,
		})
	}
	for _, delegate := range tr.Targets {
		for _, r := range delegate.Signed.Delegations.Roles {
			res = append(res, r)
		}
	}
	return res
}
906287
func (gd *GossipDelegate) LocalState(join bool) []byte {
	gd.updateSelfTs()

	// We send our local state of nodeMap
	// The receiver will decide which nodes to merge and which to ignore
	byteLocalState, err := gd.GetLocalStateInBytes()
	if err != nil {
		byteLocalState = []byte{}
	}
	gd.updateGossipTs()
	return byteLocalState
}
857470
func (e *RoleService) Put(role *Role) (data *Role, err error) {
	path := fmt.Sprintf("roles/%s", role.Name)
	//  err = e.client.magicRequestDecoder("PUT", path, role, nil)
	body, err := JSONReader(role)
	if err != nil {
		return
	}

	err = e.client.magicRequestDecoder(
		"PUT",
		path,
		body,
		&data,
	)
	return
}
973139
func NewRoles(in []string) (Roles, error) {
	var roles Roles
	for _, val := range in {
		role := Role(val)
		if err := role.Check(); err != nil {
			return nil, trace.Wrap(err)
		}
		roles = append(roles, role)
	}
	return roles, nil
}
545833
func (c *RolesStore) All(ctx context.Context) ([]chronograf.Role, error) {
	all, err := c.Ctrl.Roles(ctx, nil)
	if err != nil {
		return nil, err
	}

	return all.ToChronograf(), nil
}
632122
func (b PolicyBindings) MarshalJSON() ([]byte, error) {
	roles := make([]string, 0, len(b))
	for role, members := range b {
		if len(members) != 0 {
			roles = append(roles, role)
		}
	}
	sort.Strings(roles)

	bindings := make([]roleBinding, 0, len(roles))
	for _, role := range roles {
		members := make([]string, 0, len(b[role]))
		for k := range b[role] {
			members = append(members, k)
		}
		sort.Strings(members)
		bindings = append(bindings, roleBinding{
			Role:    role,
			Members: members,
		})
	}

	return json.Marshal(bindings)
}
332391
func (s *RolesStore) Update(ctx context.Context, u *chronograf.Role) error {
	return s.UpdateF(ctx, u)
}
619842
func (c *MutableTLSCreds) Role() string {
	c.Lock()
	defer c.Unlock()

	return c.subject.OrganizationalUnit[0]
}
32700
func (b *PolicyBindings) UnmarshalJSON(data []byte) error {
	bindings := []roleBinding{}
	if err := json.Unmarshal(data, &bindings); err != nil {
		return err
	}
	newOne := make(PolicyBindings, len(bindings))
	for _, item := range bindings {
		members := make(membersSet, len(item.Members))
		for _, member := range item.Members {
			members[member] = struct{}{}
		}
		newOne[item.Role] = members
	}
	*b = newOne
	return nil
}
106283
func (s *RolesStore) All(ctx context.Context) ([]chronograf.Role, error) {
	return s.AllF(ctx)
}