// WriteNamespaces will writes namespaces list into graph.
//
// Deprecated: see Config.WriteNamespaces
778863
func WriteNamespaces(w quad.Writer, n *voc.Namespaces) error {
	return global.WriteNamespaces(w, n)
}
560391
func Networks(namespace Namespace, networks networkMap, servicesNetworks map[string]struct{}) (map[string]types.NetworkCreate, []string) {
	if networks == nil {
		networks = make(map[string]composetypes.NetworkConfig)
	}

	externalNetworks := []string{}
	result := make(map[string]types.NetworkCreate)
	for internalName := range servicesNetworks {
		network := networks[internalName]
		if network.External.External {
			externalNetworks = append(externalNetworks, network.Name)
			continue
		}

		createOpts := types.NetworkCreate{
			Labels:     AddStackLabel(namespace, network.Labels),
			Driver:     network.Driver,
			Options:    network.DriverOpts,
			Internal:   network.Internal,
			Attachable: network.Attachable,
		}

		if network.Ipam.Driver != "" || len(network.Ipam.Config) > 0 {
			createOpts.IPAM = &networktypes.IPAM{}
		}

		if network.Ipam.Driver != "" {
			createOpts.IPAM.Driver = network.Ipam.Driver
		}
		for _, ipamConfig := range network.Ipam.Config {
			config := networktypes.IPAMConfig{
				Subnet: ipamConfig.Subnet,
			}
			createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
		}

		networkName := namespace.Scope(internalName)
		if network.Name != "" {
			networkName = network.Name
		}
		result[networkName] = createOpts
	}

	return result, externalNetworks
}
275339
func deleteNamespaces(namespaces k8s.NamespaceListerDeleter, skip map[string]struct{}) error {
	namespacesList, err := namespaces.List(v1.ListOptions{})
	if err != nil {
		return errListNamespaces{origErr: err}
	}
	// TODO: delete concurrently https://github.com/deis/k8s-claimer/issues/49
	var errs []error
	for _, namespace := range namespacesList.Items {
		_, inSkip := skip[namespace.Name]
		_, isDefault := skipDeleteNamespaces[namespace.Name]
		if !isDefault && !inSkip {
			if err := namespaces.Delete(namespace.Name, &v1.DeleteOptions{}); err != nil {
				errs = append(errs, err)
			}
		}
	}
	if len(errs) > 0 {
		return errDeleteNamespaces{origErrs: errs}
	}
	return nil
}
300417
func (c *Client) SetNamespace(namespace string) {
	c.modifyLock.Lock()
	defer c.modifyLock.Unlock()
	c.setNamespace(namespace)
}
245853
func ToNamespace(n core.Namespace) []*NamespaceElement {
	elements := make([]*NamespaceElement, 0, len(n))
	for _, value := range n {
		ne := &NamespaceElement{
			Value:       value.Value,
			Description: value.Description,
			Name:        value.Name,
		}
		elements = append(elements, ne)
	}
	return elements
}
60687
func (s *CloudWatchAlarmConfiguration) SetNamespace(v string) *CloudWatchAlarmConfiguration {
	s.Namespace = &v
	return s
}
1118985
func (m *MockCoreV1Interface) Namespaces() v11.NamespaceInterface {
	ret := m.ctrl.Call(m, "Namespaces")
	ret0, _ := ret[0].(v11.NamespaceInterface)
	return ret0
}
836327
func (s *ListGroupsInput) SetNamespace(v string) *ListGroupsInput {
	s.Namespace = &v
	return s
}
528125
func (d *namespacedResourcesDeleter) finalizeNamespace(namespace *v1.Namespace) (*v1.Namespace, error) {
	namespaceFinalize := v1.Namespace{}
	namespaceFinalize.ObjectMeta = namespace.ObjectMeta
	namespaceFinalize.Spec = namespace.Spec
	finalizerSet := sets.NewString()
	for i := range namespace.Spec.Finalizers {
		if namespace.Spec.Finalizers[i] != d.finalizerToken {
			finalizerSet.Insert(string(namespace.Spec.Finalizers[i]))
		}
	}
	namespaceFinalize.Spec.Finalizers = make([]v1.FinalizerName, 0, len(finalizerSet))
	for _, value := range finalizerSet.List() {
		namespaceFinalize.Spec.Finalizers = append(namespaceFinalize.Spec.Finalizers, v1.FinalizerName(value))
	}
	namespace, err := d.nsClient.Finalize(&namespaceFinalize)
	if err != nil {
		// it was removed already, so life is good
		if errors.IsNotFound(err) {
			return namespace, nil
		}
	}
	return namespace, err
}
330559
func (s *MetricAlarm) SetNamespace(v string) *MetricAlarm {
	s.Namespace = &v
	return s
}
170778
func (d *namespacedResourcesDeleter) deleteNamespace(namespace *v1.Namespace) error {
	var opts *metav1.DeleteOptions
	uid := namespace.UID
	if len(uid) > 0 {
		opts = &metav1.DeleteOptions{Preconditions: &metav1.Preconditions{UID: &uid}}
	}
	err := d.nsClient.Delete(namespace.Name, opts)
	if err != nil && !errors.IsNotFound(err) {
		return err
	}
	return nil
}
1007348
func (s *DeleteGroupInput) SetNamespace(v string) *DeleteGroupInput {
	s.Namespace = &v
	return s
}
248064
func (s *DeleteUserInput) SetNamespace(v string) *DeleteUserInput {
	s.Namespace = &v
	return s
}
961365
func Namespace(name string, s func()) error {
	defer func() {
		namespace = ""
	}()

	namespace = applyNamespace(name)
	s()
	return nil
}
349242
func (s *CreateGroupInput) SetNamespace(v string) *CreateGroupInput {
	s.Namespace = &v
	return s
}
1323338
func (r *Request) Namespace(s string) *Request {
	r.namespace = s
	return r
}
544964
func (c *Controller) RunKubernetesNamespaces(ch chan struct{}) {
	wait.Until(func() {
		// Loop the system namespace list, and create them if they do not exist
		for _, ns := range c.SystemNamespaces {
			if err := createNamespaceIfNeeded(c.NamespaceClient, ns); err != nil {
				runtime.HandleError(fmt.Errorf("unable to create required kubernetes system namespace %s: %v", ns, err))
			}
		}
	}, c.SystemNamespacesInterval, ch)
}