mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
fix bug
This commit is contained in:
parent
d97c759110
commit
d2caaf1cbe
@ -56,12 +56,15 @@ func (v *SchemaValidation) ValidateBytes(data []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (v *SchemaValidation) validateList(object interface{}) []error {
|
func (v *SchemaValidation) validateList(object interface{}) []error {
|
||||||
fields := object.(map[string]interface{})
|
fields, ok := object.(map[string]interface{})
|
||||||
if fields == nil {
|
if !ok || fields == nil {
|
||||||
return []error{errors.New("invalid object to validate")}
|
return []error{errors.New("invalid object to validate")}
|
||||||
}
|
}
|
||||||
|
|
||||||
allErrors := []error{}
|
allErrors := []error{}
|
||||||
|
if _, ok := fields["items"].([]interface{}); !ok {
|
||||||
|
return []error{errors.New("invalid object to validate")}
|
||||||
|
}
|
||||||
for _, item := range fields["items"].([]interface{}) {
|
for _, item := range fields["items"].([]interface{}) {
|
||||||
if gvk, errs := getObjectKind(item); errs != nil {
|
if gvk, errs := getObjectKind(item); errs != nil {
|
||||||
allErrors = append(allErrors, errs...)
|
allErrors = append(allErrors, errs...)
|
||||||
@ -101,8 +104,8 @@ func parse(data []byte) (interface{}, error) {
|
|||||||
|
|
||||||
func getObjectKind(object interface{}) (schema.GroupVersionKind, []error) {
|
func getObjectKind(object interface{}) (schema.GroupVersionKind, []error) {
|
||||||
var listErrors []error
|
var listErrors []error
|
||||||
fields := object.(map[string]interface{})
|
fields, ok := object.(map[string]interface{})
|
||||||
if fields == nil {
|
if !ok || fields == nil {
|
||||||
listErrors = append(listErrors, errors.New("invalid object to validate"))
|
listErrors = append(listErrors, errors.New("invalid object to validate"))
|
||||||
return schema.GroupVersionKind{}, listErrors
|
return schema.GroupVersionKind{}, listErrors
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user