MCPcopy
hub / github.com/kubernetes/kubectl / validateList

Method validateList

pkg/validation/validation.go:62–80  ·  view source on GitHub ↗
(object interface{})

Source from the content-addressed store, hash-verified

60}
61
62func (v *schemaValidation) validateList(object interface{}) []error {
63 fields, ok := object.(map[string]interface{})
64 if !ok || fields == nil {
65 return []error{errors.New("invalid object to validate")}
66 }
67
68 allErrors := []error{}
69 if _, ok := fields["items"].([]interface{}); !ok {
70 return []error{errors.New("invalid object to validate")}
71 }
72 for _, item := range fields["items"].([]interface{}) {
73 if gvk, errs := getObjectKind(item); errs != nil {
74 allErrors = append(allErrors, errs...)
75 } else {
76 allErrors = append(allErrors, v.validateResource(item, gvk)...)
77 }
78 }
79 return allErrors
80}
81
82func (v *schemaValidation) validateResource(obj interface{}, gvk schema.GroupVersionKind) []error {
83 // This lazy-loads the OpenAPI V2 specifications, caching the specs.

Callers 1

ValidateBytesMethod · 0.95

Calls 2

validateResourceMethod · 0.95
getObjectKindFunction · 0.85

Tested by

no test coverage detected