Merge pull request #9597 from mikedanese/fix-swagger-validate-panic
fix panic in kubectl --validate when no apiVersion is passed
This commit is contained in:
@@ -79,11 +79,11 @@ func (s *SwaggerSchema) ValidateBytes(data []byte) error {
|
|||||||
}
|
}
|
||||||
apiVersion := fields["apiVersion"]
|
apiVersion := fields["apiVersion"]
|
||||||
if apiVersion == nil {
|
if apiVersion == nil {
|
||||||
fmt.Errorf("apiVersion not set")
|
return fmt.Errorf("apiVersion not set")
|
||||||
}
|
}
|
||||||
kind := fields["kind"]
|
kind := fields["kind"]
|
||||||
if kind == nil {
|
if kind == nil {
|
||||||
fmt.Errorf("kind not set")
|
return fmt.Errorf("kind not set")
|
||||||
}
|
}
|
||||||
return s.ValidateObject(obj, apiVersion.(string), "", apiVersion.(string)+"."+kind.(string))
|
return s.ValidateObject(obj, apiVersion.(string), "", apiVersion.(string)+"."+kind.(string))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user