Pod Templates
This commit is contained in:
parent
27a5a151c0
commit
aca6a3bdaf
|
|
@ -34,7 +34,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func validateObject(obj runtime.Object) (errors []error) {
|
func validateObject(obj runtime.Object) (errors []error) {
|
||||||
ctx := api.NewDefaultContext()
|
|
||||||
switch t := obj.(type) {
|
switch t := obj.(type) {
|
||||||
case *api.ReplicationController:
|
case *api.ReplicationController:
|
||||||
if t.Namespace == "" {
|
if t.Namespace == "" {
|
||||||
|
|
@ -49,7 +48,6 @@ func validateObject(obj runtime.Object) (errors []error) {
|
||||||
if t.Namespace == "" {
|
if t.Namespace == "" {
|
||||||
t.Namespace = api.NamespaceDefault
|
t.Namespace = api.NamespaceDefault
|
||||||
}
|
}
|
||||||
api.ValidNamespace(ctx, &t.ObjectMeta)
|
|
||||||
errors = validation.ValidateService(t)
|
errors = validation.ValidateService(t)
|
||||||
case *api.ServiceList:
|
case *api.ServiceList:
|
||||||
for i := range t.Items {
|
for i := range t.Items {
|
||||||
|
|
@ -59,7 +57,6 @@ func validateObject(obj runtime.Object) (errors []error) {
|
||||||
if t.Namespace == "" {
|
if t.Namespace == "" {
|
||||||
t.Namespace = api.NamespaceDefault
|
t.Namespace = api.NamespaceDefault
|
||||||
}
|
}
|
||||||
api.ValidNamespace(ctx, &t.ObjectMeta)
|
|
||||||
errors = validation.ValidatePod(t)
|
errors = validation.ValidatePod(t)
|
||||||
case *api.PodList:
|
case *api.PodList:
|
||||||
for i := range t.Items {
|
for i := range t.Items {
|
||||||
|
|
@ -68,8 +65,15 @@ func validateObject(obj runtime.Object) (errors []error) {
|
||||||
case *api.PersistentVolume:
|
case *api.PersistentVolume:
|
||||||
errors = validation.ValidatePersistentVolume(t)
|
errors = validation.ValidatePersistentVolume(t)
|
||||||
case *api.PersistentVolumeClaim:
|
case *api.PersistentVolumeClaim:
|
||||||
api.ValidNamespace(ctx, &t.ObjectMeta)
|
if t.Namespace == "" {
|
||||||
|
t.Namespace = api.NamespaceDefault
|
||||||
|
}
|
||||||
errors = validation.ValidatePersistentVolumeClaim(t)
|
errors = validation.ValidatePersistentVolumeClaim(t)
|
||||||
|
case *api.PodTemplate:
|
||||||
|
if t.Namespace == "" {
|
||||||
|
t.Namespace = api.NamespaceDefault
|
||||||
|
}
|
||||||
|
errors = validation.ValidatePodTemplate(t)
|
||||||
default:
|
default:
|
||||||
return []error{fmt.Errorf("no validation defined for %#v", obj)}
|
return []error{fmt.Errorf("no validation defined for %#v", obj)}
|
||||||
}
|
}
|
||||||
|
|
@ -156,6 +160,7 @@ func TestExampleObjectSchemas(t *testing.T) {
|
||||||
"pod-with-http-healthcheck": &api.Pod{},
|
"pod-with-http-healthcheck": &api.Pod{},
|
||||||
"service": &api.Service{},
|
"service": &api.Service{},
|
||||||
"replication-controller": &api.ReplicationController{},
|
"replication-controller": &api.ReplicationController{},
|
||||||
|
"podtemplate": &api.PodTemplate{},
|
||||||
},
|
},
|
||||||
"../examples/update-demo": {
|
"../examples/update-demo": {
|
||||||
"kitten-rc": &api.ReplicationController{},
|
"kitten-rc": &api.ReplicationController{},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"apiVersion": "v1beta3",
|
||||||
|
"kind": "PodTemplate",
|
||||||
|
"metadata": {
|
||||||
|
"name": "nginx"
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"metadata": {
|
||||||
|
"labels": {
|
||||||
|
"name": "nginx"
|
||||||
|
},
|
||||||
|
"generateName": "nginx-"
|
||||||
|
},
|
||||||
|
"spec": {
|
||||||
|
"containers": [{
|
||||||
|
"name": "nginx",
|
||||||
|
"image": "dockerfile/nginx",
|
||||||
|
"ports": [{"containerPort": 80}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue