func UIDFrom(ctx Context) (types.UID, bool) {
	uid, ok := ctx.Value(uidKey).(types.UID)
	return uid, ok
}
UIDFrom returns the value of the uid key on the ctx
package api
import (
	stderrs "errors"
	"time"
	"golang.org/x/net/context"
	"k8s.io/kubernetes/pkg/auth/user"
	"k8s.io/kubernetes/pkg/types"
)
type Context interface {
	Value(key interface{}) interface{}
	Deadline() (deadline time.Time, ok bool)
	Done() <-chan struct{}
	Err() error
}
type key int
const (
	namespaceKey key = iota
	userKey
	uidKey
)
func NewContext() Context {
	return context.TODO()
}
func NewDefaultContext() Context {
	return WithNamespace(NewContext(), NamespaceDefault)
}
func WithValue(parent Context, key interface{}, val interface{}) Context {
	internalCtx, ok := parent.(context.Context)
	if !ok {
		panic(stderrs.New("Invalid context type"))
	}
	return context.WithValue(internalCtx, key, val)
}
func WithNamespace(parent Context, namespace string) Context {
	return WithValue(parent, namespaceKey, namespace)
}
func NamespaceFrom(ctx Context) (string, bool) {
	namespace, ok := ctx.Value(namespaceKey).(string)
	return namespace, ok
}
func NamespaceValue(ctx Context) string {
	namespace, _ := NamespaceFrom(ctx)
	return namespace
}
func ValidNamespace(ctx Context, resource *ObjectMeta) bool {
	ns, ok := NamespaceFrom(ctx)
	if len(resource.Namespace) == 0 {
		resource.Namespace = ns
	}
	return ns == resource.Namespace && ok
}
func WithNamespaceDefaultIfNone(parent Context) Context {
	namespace, ok := NamespaceFrom(parent)
	if !ok || len(namespace) == 0 {
		return WithNamespace(parent, NamespaceDefault)
	}
	return parent
}
func WithUser(parent Context, user user.Info) Context {
	return WithValue(parent, userKey, user)
}
func UserFrom(ctx Context) (user.Info, bool) {
	user, ok := ctx.Value(userKey).(user.Info)
	return user, ok
}
func WithUID(parent Context, uid types.UID) Context {
	return WithValue(parent, uidKey, uid)
}