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

Method Get

rest/request.go:1065–1087  ·  view source on GitHub ↗

Get returns the result as an object, which means it passes through the decoder. If the returned object is of type Status and has .Status != StatusSuccess, the additional information in Status will be used to enrich the error.

()

Source from the content-addressed store, hash-verified

1063// If the returned object is of type Status and has .Status != StatusSuccess, the
1064// additional information in Status will be used to enrich the error.
1065func (r Result) Get() (runtime.Object, error) {
1066 if r.err != nil {
1067 // Check whether the result has a Status object in the body and prefer that.
1068 return nil, r.Error()
1069 }
1070 if r.decoder == nil {
1071 return nil, fmt.Errorf("serializer for %s doesn't exist", r.contentType)
1072 }
1073
1074 // decode, but if the result is Status return that as an error instead.
1075 out, _, err := r.decoder.Decode(r.body, nil, nil)
1076 if err != nil {
1077 return nil, err
1078 }
1079 switch t := out.(type) {
1080 case *metav1.Status:
1081 // any status besides StatusSuccess is considered an error.
1082 if t.Status != metav1.StatusSuccess {
1083 return nil, errors.FromObject(t)
1084 }
1085 }
1086 return out, nil
1087}
1088
1089// StatusCode returns the HTTP status code of the request. (Only valid if no
1090// error was returned.)

Callers

nothing calls this directly

Calls 3

ErrorMethod · 0.95
ErrorfMethod · 0.65
DecodeMethod · 0.45

Tested by

no test coverage detected