Add support for Namespace as Kind

Add example for using namespaces
This commit is contained in:
derekwaynecarr
2015-01-19 16:50:00 -05:00
parent 151be7773c
commit 0bd0e12bbc
55 changed files with 1612 additions and 91 deletions

View File

@@ -118,7 +118,7 @@ type nodeStrategy struct {
// objects.
var Nodes RESTCreateStrategy = nodeStrategy{api.Scheme, api.SimpleNameGenerator}
// NamespaceScoped is false for services.
// NamespaceScoped is false for nodes.
func (nodeStrategy) NamespaceScoped() bool {
return false
}
@@ -134,3 +134,30 @@ func (nodeStrategy) Validate(obj runtime.Object) errors.ValidationErrorList {
node := obj.(*api.Node)
return validation.ValidateMinion(node)
}
// namespaceStrategy implements behavior for nodes
type namespaceStrategy struct {
runtime.ObjectTyper
api.NameGenerator
}
// Namespaces is the default logic that applies when creating and updating Namespace
// objects.
var Namespaces RESTCreateStrategy = namespaceStrategy{api.Scheme, api.SimpleNameGenerator}
// NamespaceScoped is false for namespaces.
func (namespaceStrategy) NamespaceScoped() bool {
return false
}
// ResetBeforeCreate clears fields that are not allowed to be set by end users on creation.
func (namespaceStrategy) ResetBeforeCreate(obj runtime.Object) {
_ = obj.(*api.Namespace)
// Namespace allow *all* fields, including status, to be set.
}
// Validate validates a new namespace.
func (namespaceStrategy) Validate(obj runtime.Object) errors.ValidationErrorList {
namespace := obj.(*api.Namespace)
return validation.ValidateNamespace(namespace)
}