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

Method transformUnstructuredResponseError

rest/request.go:973–981  ·  view source on GitHub ↗

transformUnstructuredResponseError handles an error from the server that is not in a structured form. It is expected to transform any response that is not recognizable as a clear server sent error from the K8S API using the information provided with the request. In practice, HTTP proxies and client

(resp *http.Response, req *http.Request, body []byte)

Source from the content-addressed store, hash-verified

971//
972// TODO: introduce transformation of generic http.Client.Do() errors that separates 4.
973func (r *Request) transformUnstructuredResponseError(resp *http.Response, req *http.Request, body []byte) error {
974 if body == nil && resp.Body != nil {
975 if data, err := ioutil.ReadAll(&io.LimitedReader{R: resp.Body, N: maxUnstructuredResponseTextBytes}); err == nil {
976 body = data
977 }
978 }
979 retryAfter, _ := retryAfterSeconds(resp)
980 return r.newUnstructuredResponseError(body, isTextResponse(resp), resp.StatusCode, req.Method, retryAfter)
981}
982
983// newUnstructuredResponseError instantiates the appropriate generic error for the provided input. It also logs the body.
984func (r *Request) newUnstructuredResponseError(body []byte, isTextResponse bool, statusCode int, method string, retryAfter int) error {

Callers 2

DoRawMethod · 0.95
transformResponseMethod · 0.95

Calls 3

retryAfterSecondsFunction · 0.85
isTextResponseFunction · 0.85

Tested by

no test coverage detected