openapi-validation: Handle List special case

This commit is contained in:
Antoine Pelisse
2017-08-16 15:16:24 -07:00
parent 4e87d2d572
commit a950afecdc
2 changed files with 57 additions and 7 deletions

View File

@@ -328,4 +328,32 @@ spec:
Expect(err).To(BeNil())
})
It("can validate lists", func() {
err := validator.ValidateBytes([]byte(`
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Pod
metadata:
labels:
name: redis-master
name: name
spec:
containers:
- name: name
`))
Expect(err).To(Equal(utilerrors.NewAggregate([]error{
validation.ValidationError{
Path: "Pod.spec.containers[0]",
Err: validation.MissingRequiredFieldError{
Path: "io.k8s.api.core.v1.Container",
Field: "image",
},
},
})))
})
})