Skip to content

Commit

Permalink
Rename PodTemplate.Spec to PodTemplate.Template
Browse files Browse the repository at this point in the history
  • Loading branch information
smarterclayton committed Apr 20, 2015
1 parent c5b6d36 commit dff885b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 39 deletions.
2 changes: 1 addition & 1 deletion examples/walkthrough/podtemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"metadata": {
"name": "nginx"
},
"spec": {
"template": {
"metadata": {
"labels": {
"name": "nginx"
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,8 @@ type PodTemplate struct {
TypeMeta `json:",inline"`
ObjectMeta `json:"metadata,omitempty"`

// Spec defines the pods that will be created from this template
Spec PodTemplateSpec `json:"spec,omitempty"`
// Template defines the pods that will be created from this pod template
Template PodTemplateSpec `json:"template,omitempty"`
}

// PodTemplateList is a list of PodTemplates.
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/v1beta3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,8 @@ type PodTemplate struct {
TypeMeta `json:",inline"`
ObjectMeta `json:"metadata,omitempty" description:"standard object metadata; see https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/api-conventions.md#metadata"`

// Spec defines the behavior of a pod.
Spec PodTemplateSpec `json:"spec,omitempty" description:"specification of the desired behavior of the pod; https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/api-conventions.md#spec-and-status"`
// Template defines the pods that will be created from this pod template
Template PodTemplateSpec `json:"template,omitempty" description:"the template of the desired behavior of the pod; https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/api-conventions.md#spec-and-status"`
}

// PodTemplateList is a list of PodTemplates.
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ func ValidatePodStatusUpdate(newPod, oldPod *api.Pod) errs.ValidationErrorList {
func ValidatePodTemplate(pod *api.PodTemplate) errs.ValidationErrorList {
allErrs := errs.ValidationErrorList{}
allErrs = append(allErrs, ValidateObjectMeta(&pod.ObjectMeta, true, ValidatePodName).Prefix("metadata")...)
allErrs = append(allErrs, ValidatePodTemplateSpec(&pod.Spec, 0).Prefix("spec")...)
allErrs = append(allErrs, ValidatePodTemplateSpec(&pod.Template, 0).Prefix("spec")...)
return allErrs
}

Expand All @@ -902,7 +902,7 @@ func ValidatePodTemplateUpdate(newPod, oldPod *api.PodTemplate) errs.ValidationE
allErrs := errs.ValidationErrorList{}

allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldPod.ObjectMeta, &newPod.ObjectMeta).Prefix("metadata")...)
allErrs = append(allErrs, ValidatePodTemplateSpec(&newPod.Spec, 0).Prefix("spec")...)
allErrs = append(allErrs, ValidatePodTemplateSpec(&newPod.Template, 0).Prefix("spec")...)
return allErrs
}

Expand Down
69 changes: 41 additions & 28 deletions pkg/api/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ func TestValidateService(t *testing.T) {
func TestValidateReplicationControllerUpdate(t *testing.T) {
validSelector := map[string]string{"a": "b"}
validPodTemplate := api.PodTemplate{
Spec: api.PodTemplateSpec{
Template: api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: validSelector,
},
Expand All @@ -1678,7 +1678,7 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
},
}
readWriteVolumePodTemplate := api.PodTemplate{
Spec: api.PodTemplateSpec{
Template: api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: validSelector,
},
Expand All @@ -1692,7 +1692,7 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
}
invalidSelector := map[string]string{"NoUppercaseOrSpecialCharsLike=Equals": "b"}
invalidPodTemplate := api.PodTemplate{
Spec: api.PodTemplateSpec{
Template: api.PodTemplateSpec{
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Expand All @@ -1712,15 +1712,15 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
update: api.ReplicationController{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Replicas: 3,
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
},
Expand All @@ -1729,15 +1729,15 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
update: api.ReplicationController{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Replicas: 1,
Selector: validSelector,
Template: &readWriteVolumePodTemplate.Spec,
Template: &readWriteVolumePodTemplate.Template,
},
},
},
Expand All @@ -1755,15 +1755,15 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
update: api.ReplicationController{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Replicas: 2,
Selector: validSelector,
Template: &readWriteVolumePodTemplate.Spec,
Template: &readWriteVolumePodTemplate.Template,
},
},
},
Expand All @@ -1772,15 +1772,15 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
update: api.ReplicationController{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Replicas: 2,
Selector: invalidSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
},
Expand All @@ -1789,15 +1789,15 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
update: api.ReplicationController{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Replicas: 2,
Selector: validSelector,
Template: &invalidPodTemplate.Spec,
Template: &invalidPodTemplate.Template,
},
},
},
Expand All @@ -1806,15 +1806,15 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
update: api.ReplicationController{
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Replicas: -1,
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
},
Expand All @@ -1830,7 +1830,7 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
func TestValidateReplicationController(t *testing.T) {
validSelector := map[string]string{"a": "b"}
validPodTemplate := api.PodTemplate{
Spec: api.PodTemplateSpec{
Template: api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: validSelector,
},
Expand All @@ -1842,7 +1842,7 @@ func TestValidateReplicationController(t *testing.T) {
},
}
readWriteVolumePodTemplate := api.PodTemplate{
Spec: api.PodTemplateSpec{
Template: api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: validSelector,
},
Expand All @@ -1856,7 +1856,7 @@ func TestValidateReplicationController(t *testing.T) {
}
invalidSelector := map[string]string{"NoUppercaseOrSpecialCharsLike=Equals": "b"}
invalidPodTemplate := api.PodTemplate{
Spec: api.PodTemplateSpec{
Template: api.PodTemplateSpec{
Spec: api.PodSpec{
RestartPolicy: api.RestartPolicyAlways,
DNSPolicy: api.DNSClusterFirst,
Expand All @@ -1871,22 +1871,22 @@ func TestValidateReplicationController(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
{
ObjectMeta: api.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
{
ObjectMeta: api.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Replicas: 1,
Selector: validSelector,
Template: &readWriteVolumePodTemplate.Spec,
Template: &readWriteVolumePodTemplate.Template,
},
},
}
Expand All @@ -1901,27 +1901,27 @@ func TestValidateReplicationController(t *testing.T) {
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
"missing-namespace": {
ObjectMeta: api.ObjectMeta{Name: "abc-123"},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
"empty selector": {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
"selector_doesnt_match": {
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
Spec: api.ReplicationControllerSpec{
Selector: map[string]string{"foo": "bar"},
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
"invalid manifest": {
Expand All @@ -1935,7 +1935,7 @@ func TestValidateReplicationController(t *testing.T) {
Spec: api.ReplicationControllerSpec{
Replicas: 2,
Selector: validSelector,
Template: &readWriteVolumePodTemplate.Spec,
Template: &readWriteVolumePodTemplate.Template,
},
},
"negative_replicas": {
Expand All @@ -1955,7 +1955,7 @@ func TestValidateReplicationController(t *testing.T) {
},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Spec,
Template: &validPodTemplate.Template,
},
},
"invalid_label 2": {
Expand All @@ -1967,7 +1967,20 @@ func TestValidateReplicationController(t *testing.T) {
},
},
Spec: api.ReplicationControllerSpec{
Template: &invalidPodTemplate.Spec,
Template: &invalidPodTemplate.Template,
},
},
"invalid_annotation": {
ObjectMeta: api.ObjectMeta{
Name: "abc-123",
Namespace: api.NamespaceDefault,
Annotations: map[string]string{
"NoUppercaseOrSpecialCharsLike=Equals": "bar",
},
},
Spec: api.ReplicationControllerSpec{
Selector: validSelector,
Template: &validPodTemplate.Template,
},
},
"invalid restart policy 1": {
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubectl/resource_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func printPodList(podList *api.PodList, w io.Writer) error {
}

func printPodTemplate(pod *api.PodTemplate, w io.Writer) error {
containers := pod.Spec.Spec.Containers
containers := pod.Template.Spec.Containers
var firstContainer api.Container
if len(containers) > 0 {
firstContainer, containers = containers[0], containers[1:]
Expand All @@ -386,7 +386,7 @@ func printPodTemplate(pod *api.PodTemplate, w io.Writer) error {
pod.Name,
firstContainer.Name,
firstContainer.Image,
formatLabels(pod.Spec.Labels),
formatLabels(pod.Template.Labels),
)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions pkg/registry/podtemplate/etcd/etcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func validNewPodTemplate(name string) *api.PodTemplate {
Name: name,
Namespace: api.NamespaceDefault,
},
Spec: api.PodTemplateSpec{
Template: api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{
Labels: map[string]string{"test": "foo"},
},
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestCreate(t *testing.T) {
pod,
// invalid
&api.PodTemplate{
Spec: api.PodTemplateSpec{},
Template: api.PodTemplateSpec{},
},
)
}
Expand Down

0 comments on commit dff885b

Please sign in to comment.