validation: improve ProjectedVolume validation errors
* only report "may not specify more than 1 volume type" once * fix incorrectly reported field paths * continue to traverse into projections to report further errors.
This commit is contained in:
@@ -3542,6 +3542,71 @@ func TestValidateVolumes(t *testing.T) {
|
||||
field: "scaleIO.system",
|
||||
}},
|
||||
},
|
||||
// ProjectedVolumeSource
|
||||
{
|
||||
name: "ProjectedVolumeSource more than one projection in a source",
|
||||
vol: core.Volume{
|
||||
Name: "projected-volume",
|
||||
VolumeSource: core.VolumeSource{
|
||||
Projected: &core.ProjectedVolumeSource{
|
||||
Sources: []core.VolumeProjection{
|
||||
{
|
||||
Secret: &core.SecretProjection{
|
||||
LocalObjectReference: core.LocalObjectReference{
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Secret: &core.SecretProjection{
|
||||
LocalObjectReference: core.LocalObjectReference{
|
||||
Name: "foo",
|
||||
},
|
||||
},
|
||||
DownwardAPI: &core.DownwardAPIProjection{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
errs: []verr{{
|
||||
etype: field.ErrorTypeForbidden,
|
||||
field: "projected.sources[1]",
|
||||
}},
|
||||
},
|
||||
{
|
||||
name: "ProjectedVolumeSource more than one projection in a source",
|
||||
vol: core.Volume{
|
||||
Name: "projected-volume",
|
||||
VolumeSource: core.VolumeSource{
|
||||
Projected: &core.ProjectedVolumeSource{
|
||||
Sources: []core.VolumeProjection{
|
||||
{
|
||||
Secret: &core.SecretProjection{},
|
||||
},
|
||||
{
|
||||
Secret: &core.SecretProjection{},
|
||||
DownwardAPI: &core.DownwardAPIProjection{},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
errs: []verr{
|
||||
{
|
||||
etype: field.ErrorTypeRequired,
|
||||
field: "projected.sources[0].secret.name",
|
||||
},
|
||||
{
|
||||
etype: field.ErrorTypeRequired,
|
||||
field: "projected.sources[1].secret.name",
|
||||
},
|
||||
{
|
||||
etype: field.ErrorTypeForbidden,
|
||||
field: "projected.sources[1]",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
Reference in New Issue
Block a user