MCPcopy
hub / github.com/kubernetes/client-go / OpenAPISchema

Method OpenAPISchema

discovery/discovery_client.go:421–441  ·  view source on GitHub ↗

OpenAPISchema fetches the open api schema using a rest client and parses the proto.

()

Source from the content-addressed store, hash-verified

419
420// OpenAPISchema fetches the open api schema using a rest client and parses the proto.
421func (d *DiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error) {
422 data, err := d.restClient.Get().AbsPath("/openapi/v2").SetHeader("Accept", mimePb).Do().Raw()
423 if err != nil {
424 if errors.IsForbidden(err) || errors.IsNotFound(err) || errors.IsNotAcceptable(err) {
425 // single endpoint not found/registered in old server, try to fetch old endpoint
426 // TODO: remove this when kubectl/client-go don't work with 1.9 server
427 data, err = d.restClient.Get().AbsPath("/swagger-2.0.0.pb-v1").Do().Raw()
428 if err != nil {
429 return nil, err
430 }
431 } else {
432 return nil, err
433 }
434 }
435 document := &openapi_v2.Document{}
436 err = proto.Unmarshal(data, document)
437 if err != nil {
438 return nil, err
439 }
440 return document, nil
441}
442
443// withRetries retries the given recovery function in case the groups supported by the server change after ServerGroup() returns.
444func withRetries(maxRetries int, f func() ([]*metav1.APIGroup, []*metav1.APIResourceList, error)) ([]*metav1.APIGroup, []*metav1.APIResourceList, error) {

Callers

nothing calls this directly

Calls 5

RawMethod · 0.80
SetHeaderMethod · 0.80
AbsPathMethod · 0.80
DoMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected