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

Method Patch

dynamic/simple.go:312–334  ·  view source on GitHub ↗
(name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string)

Source from the content-addressed store, hash-verified

310}
311
312func (c *dynamicResourceClient) Patch(name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*unstructured.Unstructured, error) {
313 if len(name) == 0 {
314 return nil, fmt.Errorf("name is required")
315 }
316 result := c.client.client.
317 Patch(pt).
318 AbsPath(append(c.makeURLSegments(name), subresources...)...).
319 Body(data).
320 SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
321 Do()
322 if err := result.Error(); err != nil {
323 return nil, err
324 }
325 retBytes, err := result.Raw()
326 if err != nil {
327 return nil, err
328 }
329 uncastObj, err := runtime.Decode(unstructured.UnstructuredJSONScheme, retBytes)
330 if err != nil {
331 return nil, err
332 }
333 return uncastObj.(*unstructured.Unstructured), nil
334}
335
336func (c *dynamicResourceClient) makeURLSegments(name string) []string {
337 url := []string{}

Callers

nothing calls this directly

Calls 10

makeURLSegmentsMethod · 0.95
BodyMethod · 0.80
AbsPathMethod · 0.80
RawMethod · 0.80
ErrorfMethod · 0.65
DoMethod · 0.65
PatchMethod · 0.65
ErrorMethod · 0.65
DecodeMethod · 0.45

Tested by

no test coverage detected