Commit 695fbee3 authored by Brendan Burns's avatar Brendan Burns

Merge pull request #1742 from dchen1107/termination

Set EmptyDir when VolumeSource is absent.
parents 135d1879 c511b7a0
......@@ -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) {
......
......@@ -63,7 +63,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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment