mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Fix #1683
This commit is contained in:
parent
e1cb72f1ae
commit
c511b7a0ce
@ -33,10 +33,13 @@ func validateVolumes(volumes []api.Volume) (util.StringSet, errs.ErrorList) {
|
|||||||
for i := range volumes {
|
for i := range volumes {
|
||||||
vol := &volumes[i] // so we can set default values
|
vol := &volumes[i] // so we can set default values
|
||||||
el := errs.ErrorList{}
|
el := errs.ErrorList{}
|
||||||
// TODO(thockin) enforce that a source is set once we deprecate the implied form.
|
if vol.Source == nil {
|
||||||
if vol.Source != nil {
|
// TODO: Enforce that a source is set once we deprecate the implied form.
|
||||||
el = validateSource(vol.Source).Prefix("source")
|
vol.Source = &api.VolumeSource{
|
||||||
|
EmptyDir: &api.EmptyDir{},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
el = validateSource(vol.Source).Prefix("source")
|
||||||
if len(vol.Name) == 0 {
|
if len(vol.Name) == 0 {
|
||||||
el = append(el, errs.NewFieldRequired("name", vol.Name))
|
el = append(el, errs.NewFieldRequired("name", vol.Name))
|
||||||
} else if !util.IsDNSLabel(vol.Name) {
|
} else if !util.IsDNSLabel(vol.Name) {
|
||||||
|
@ -62,7 +62,7 @@ func TestValidateVolumes(t *testing.T) {
|
|||||||
for k, v := range errorCases {
|
for k, v := range errorCases {
|
||||||
_, errs := validateVolumes(v.V)
|
_, errs := validateVolumes(v.V)
|
||||||
if len(errs) == 0 {
|
if len(errs) == 0 {
|
||||||
t.Errorf("expected failure for %s", k)
|
t.Errorf("expected failure %s for %v", k, v.V)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for i := range errs {
|
for i := range errs {
|
||||||
|
Loading…
Reference in New Issue
Block a user