// addSubjectsToNamespace adds the specified namespace to each subject
432073
func addSubjectsToNamespace(subjectRecordStore cache.Store, subjects []string, namespace string) {
	for _, subject := range subjects {
		var item *subjectRecord
		obj, exists, _ := subjectRecordStore.GetByKey(subject)
		if exists {
			item = obj.(*subjectRecord)
		} else {
			item = &subjectRecord{subject: subject, namespaces: sets.NewString()}
			subjectRecordStore.Add(item)
		}
		item.namespaces.Insert(namespace)
	}
}
986608
func ConvertToNamespace(obj interface{}) interface{} {
	namespace, ok := obj.(*v1.Namespace)
	if !ok {
		return nil
	}
	n := &types.Namespace{
		TypeMeta:   namespace.TypeMeta,
		ObjectMeta: namespace.ObjectMeta,
	}
	*namespace = v1.Namespace{}
	return n
}
1168468
func NewNamespacer(d discovery.DiscoveryInterface) (*namespaceViaDiscovery, error) {
	fallback, err := getDefaultNamespace()
	if err != nil {
		return nil, err
	}
	return &namespaceViaDiscovery{fallbackNamespace: fallback, disco: d}, nil
}
531699
func (s *DescribeScalingPoliciesInput) SetServiceNamespace(v string) *DescribeScalingPoliciesInput {
	s.ServiceNamespace = &v
	return s
}
278849
func (l *dynamicLister) Namespace(namespace string) NamespaceLister {
	return &dynamicNamespaceLister{indexer: l.indexer, namespace: namespace, gvr: l.gvr}
}
952236
func WithNamespace(namespace string) SharedInformerOption {
	return func(factory *sharedInformerFactory) *sharedInformerFactory {
		factory.namespace = namespace
		return factory
	}
}
873936
func (s *CertificateDetail) SetSubject(v string) *CertificateDetail {
	s.Subject = &v
	return s
}
225500
func (c *ServiceAccountsController) namespaceUpdated(oldObj interface{}, newObj interface{}) {
	newNamespace := newObj.(*v1.Namespace)
	c.queue.Add(newNamespace.Name)
}
58155
func (conn *FakeConnection) AddObject(name, path string, handler FakeHandler) {
	conn.objects[name+path] = &fakeObject{handler}
}
412942
func (s *RequestCertificateInput) SetSubjectAlternativeNames(v []*string) *RequestCertificateInput {
	s.SubjectAlternativeNames = v
	return s
}
1345198
func (k *kubernetesClient) createNamespace(name string) error {
	ns := &core.Namespace{ObjectMeta: v1.ObjectMeta{Name: name}}
	if err := k.ensureNamespaceAnnotations(ns); err != nil {
		return errors.Trace(err)
	}
	_, err := k.client().CoreV1().Namespaces().Create(ns)
	if k8serrors.IsAlreadyExists(err) {
		return errors.AlreadyExistsf("namespace %q", name)
	}
	return errors.Trace(err)
}
374180
func NewNamespace(name string) Namespace {
	return Namespace{
		Kind:    KindNamespace,
		Version: V2,
		Metadata: Metadata{
			Name: name,
		},
	}
}
1355177
func (c *Client) UpsertNamespace(ns services.Namespace) error {
	_, err := c.PostJSON(c.Endpoint("namespaces"), upsertNamespaceReq{Namespace: ns})
	return trace.Wrap(err)
}
425053
func (s *ServiceLastAccessed) SetServiceNamespace(v string) *ServiceLastAccessed {
	s.ServiceNamespace = &v
	return s
}
961365
func Namespace(name string, s func()) error {
	defer func() {
		namespace = ""
	}()

	namespace = applyNamespace(name)
	s()
	return nil
}
1365558
func IsSubjectNotFound(err error) bool {
	if err == nil {
		return false
	}

	if resErr, ok := err.(ResourceError); ok {
		return resErr.ErrorCode == subjectNotFoundCode
	}

	return false
}
1037672
func reapNamespacedBindings(removedSubject corev1.ObjectReference, c authv1client.AuthorizationV1Interface, out io.Writer) []error {
	errors := []error{}

	namespacedBindings, err := c.RoleBindings(metav1.NamespaceAll).List(metav1.ListOptions{})
	if err != nil {
		return []error{err}
	}
	for _, binding := range namespacedBindings.Items {
		retainedSubjects := []corev1.ObjectReference{}
		for _, subject := range binding.Subjects {
			if subject != removedSubject {
				retainedSubjects = append(retainedSubjects, subject)
			}
		}
		if len(retainedSubjects) != len(binding.Subjects) {
			updatedBinding := binding
			updatedBinding.Subjects = retainedSubjects
			coreSubjects, err := convertObjectReference(retainedSubjects)
			if err != nil {
				errors = append(errors, err)
				continue
			}
			updatedBinding.UserNames, updatedBinding.GroupNames = authorizationapi.StringSubjectsFor(binding.Namespace, coreSubjects)
			if _, err := c.RoleBindings(binding.Namespace).Update(&updatedBinding); err != nil && !kerrors.IsNotFound(err) {
				errors = append(errors, err)
			} else {
				fmt.Fprintf(out, "rolebinding.rbac.authorization.k8s.io/"+updatedBinding.Name+" updated\n")
			}
		}
	}
	return errors
}