From c511b7a0cec8f99bcff3e9f4ceadae34cd9462bb Mon Sep 17 00:00:00 2001 From: Dawn Chen Date: Fri, 10 Oct 2014 15:34:48 -0700 Subject: [PATCH] Fix #1683 --- pkg/api/validation/validation.go | 9 ++++++--- pkg/api/validation/validation_test.go | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index a260d3a1f5e..2374b9249ac 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -33,10 +33,13 @@ func validateVolumes(volumes []api.Volume) (util.StringSet, errs.ErrorList) { for i := range volumes { vol := &volumes[i] // so we can set default values el := errs.ErrorList{} - // TODO(thockin) enforce that a source is set once we deprecate the implied form. - if vol.Source != nil { - el = validateSource(vol.Source).Prefix("source") + if vol.Source == nil { + // TODO: Enforce that a source is set once we deprecate the implied form. + vol.Source = &api.VolumeSource{ + EmptyDir: &api.EmptyDir{}, + } } + el = validateSource(vol.Source).Prefix("source") if len(vol.Name) == 0 { el = append(el, errs.NewFieldRequired("name", vol.Name)) } else if !util.IsDNSLabel(vol.Name) { diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index ca2ea7de104..404a1cd2996 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -62,7 +62,7 @@ func TestValidateVolumes(t *testing.T) { for k, v := range errorCases { _, errs := validateVolumes(v.V) if len(errs) == 0 { - t.Errorf("expected failure for %s", k) + t.Errorf("expected failure %s for %v", k, v.V) continue } for i := range errs {