// NamespaceFromContext returns the namespace from the context, or the default
// namespace.
339648
func NamespaceFromContext(ctx context.Context) string {
	if ns, ok := ctx.Value(namespaceKey).(string); ok {
		return ns
	}
	return DefaultNamespace
}
129505
func WithNamespace(parent context.Context, namespace string) context.Context {
	return WithValue(parent, namespaceKey, namespace)
}
1235524
func (nr *nameResolver) popContext() {
	nr.contextStack = nr.contextStack[:len(nr.contextStack)-1]
}
733612
func WithNamespace(ctx context.Context, namespace string) context.Context {
	ctx = context.WithValue(ctx, namespaceKey{}, namespace) // set our key for namespace

	// also store on the grpc headers so it gets picked up by any clients that
	// are using this.
	return withGRPCNamespaceHeader(ctx, namespace)
}
1118985
func (m *MockCoreV1Interface) Namespaces() v11.NamespaceInterface {
	ret := m.ctrl.Call(m, "Namespaces")
	ret0, _ := ret[0].(v11.NamespaceInterface)
	return ret0
}
466753
func (r *RepoStatus) GetContext() string {
	if r == nil || r.Context == nil {
		return ""
	}
	return *r.Context
}
1210732
func HTMLFromContext(ctx context.Context) template.HTML {
	var h template.HTML
	ci, ok := FromContext(ctx)
	if ok {
		return ci.HTML()
	}
	return h
}
961365
func Namespace(name string, s func()) error {
	defer func() {
		namespace = ""
	}()

	namespace = applyNamespace(name)
	s()
	return nil
}
200375
func MetadataFromContext(ctx context.Context) (Metadata, error) {
	value := ctx.Value(metadataKey)
	if value != nil {
		metadata, ok := value.(Metadata)
		if ok {
			return metadata, nil
		}
	}
	return nil, errors.New("context contains no metadata")
}
952236
func WithNamespace(namespace string) SharedInformerOption {
	return func(factory *sharedInformerFactory) *sharedInformerFactory {
		factory.namespace = namespace
		return factory
	}
}
471521
func NewNamespace(ns ...string) Namespace {
	n := make([]NamespaceElement, len(ns))
	for i, ns := range ns {
		n[i] = NamespaceElement{Value: ns}
	}
	return n
}
654047
func SpanFromContext(ctx context.Context) (sp opentracing.Span) {
	if sp = opentracing.SpanFromContext(ctx); sp == nil {
		return noopSpan()
	}
	return sp
}
455239
func DefaultContext() *Context {
	globalLock.Lock()
	defer globalLock.Unlock()
	if globalCtx == nil {
		var err error
		if globalCtx, err = NewContext(); err != nil {
			panic(err)
		}
	}
	return globalCtx
}
774062
func (dns *dnsControl) GetNamespaceByName(name string) (*api.Namespace, error) {
	os := dns.nsLister.List()
	for _, o := range os {
		ns, ok := o.(*api.Namespace)
		if !ok {
			continue
		}
		if name == ns.ObjectMeta.Name {
			return ns, nil
		}
	}
	return nil, fmt.Errorf("namespace not found")
}
1111328
func GetContext(ctx context.Context) context.Context {
	if ctx != nil {
		return ctx
	}
	return context.Background()
}
579453
func (sd *RelationalStoreDefinition) Context() string {
	if sd.Name != "" {
		return fmt.Sprintf("RelationalStore %#v", sd.Name)
	}
	return "unnamed RelationalStore"
}
411679
func GroupFromContext(ctx context.Context) *Group {
	c, _ := ctx.Value(groupKey).(*Group)
	return c
}