func ValidNamespace(ctx Context, resource *ObjectMeta) bool {
	ns, ok := NamespaceFrom(ctx)
	if len(resource.Namespace) == 0 {
		resource.Namespace = ns
	}
	return ns == resource.Namespace && ok
}
ValidNamespace returns false if the namespace on the context differs from the resource.  If the resource has no namespace, it is set to the value in the context.
package api
import (
	stderrs "errors"
	"github.com/GoogleCloudPlatform/kubernetes/pkg/auth/user"
	"golang.org/x/net/context"
)
type Context interface {
	Value(key interface{}) interface{}
}
type key int
const namespaceKey key = 0
const userKey key = 1
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
}