mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-05 11:12:03 +00:00
Merge pull request #5012 from smarterclayton/podtemplates
Pod templates as their own type
This commit is contained in:
@@ -34,7 +34,6 @@ import (
|
||||
)
|
||||
|
||||
func validateObject(obj runtime.Object) (errors []error) {
|
||||
ctx := api.NewDefaultContext()
|
||||
switch t := obj.(type) {
|
||||
case *api.ReplicationController:
|
||||
if t.Namespace == "" {
|
||||
@@ -49,7 +48,6 @@ func validateObject(obj runtime.Object) (errors []error) {
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = api.NamespaceDefault
|
||||
}
|
||||
api.ValidNamespace(ctx, &t.ObjectMeta)
|
||||
errors = validation.ValidateService(t)
|
||||
case *api.ServiceList:
|
||||
for i := range t.Items {
|
||||
@@ -59,7 +57,6 @@ func validateObject(obj runtime.Object) (errors []error) {
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = api.NamespaceDefault
|
||||
}
|
||||
api.ValidNamespace(ctx, &t.ObjectMeta)
|
||||
errors = validation.ValidatePod(t)
|
||||
case *api.PodList:
|
||||
for i := range t.Items {
|
||||
@@ -68,8 +65,15 @@ func validateObject(obj runtime.Object) (errors []error) {
|
||||
case *api.PersistentVolume:
|
||||
errors = validation.ValidatePersistentVolume(t)
|
||||
case *api.PersistentVolumeClaim:
|
||||
api.ValidNamespace(ctx, &t.ObjectMeta)
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = api.NamespaceDefault
|
||||
}
|
||||
errors = validation.ValidatePersistentVolumeClaim(t)
|
||||
case *api.PodTemplate:
|
||||
if t.Namespace == "" {
|
||||
t.Namespace = api.NamespaceDefault
|
||||
}
|
||||
errors = validation.ValidatePodTemplate(t)
|
||||
default:
|
||||
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{},
|
||||
"service": &api.Service{},
|
||||
"replication-controller": &api.ReplicationController{},
|
||||
"podtemplate": &api.PodTemplate{},
|
||||
},
|
||||
"../examples/update-demo": {
|
||||
"kitten-rc": &api.ReplicationController{},
|
||||
|
22
examples/walkthrough/podtemplate.json
Normal file
22
examples/walkthrough/podtemplate.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"apiVersion": "v1beta3",
|
||||
"kind": "PodTemplate",
|
||||
"metadata": {
|
||||
"name": "nginx"
|
||||
},
|
||||
"template": {
|
||||
"metadata": {
|
||||
"labels": {
|
||||
"name": "nginx"
|
||||
},
|
||||
"generateName": "nginx-"
|
||||
},
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "nginx",
|
||||
"image": "dockerfile/nginx",
|
||||
"ports": [{"containerPort": 80}]
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user