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

Method Update

dynamic/simple.go:132–165  ·  view source on GitHub ↗
(obj *unstructured.Unstructured, opts metav1.UpdateOptions, subresources ...string)

Source from the content-addressed store, hash-verified

130}
131
132func (c *dynamicResourceClient) Update(obj *unstructured.Unstructured, opts metav1.UpdateOptions, subresources ...string) (*unstructured.Unstructured, error) {
133 accessor, err := meta.Accessor(obj)
134 if err != nil {
135 return nil, err
136 }
137 name := accessor.GetName()
138 if len(name) == 0 {
139 return nil, fmt.Errorf("name is required")
140 }
141 outBytes, err := runtime.Encode(unstructured.UnstructuredJSONScheme, obj)
142 if err != nil {
143 return nil, err
144 }
145
146 result := c.client.client.
147 Put().
148 AbsPath(append(c.makeURLSegments(name), subresources...)...).
149 Body(outBytes).
150 SpecificallyVersionedParams(&opts, dynamicParameterCodec, versionV1).
151 Do()
152 if err := result.Error(); err != nil {
153 return nil, err
154 }
155
156 retBytes, err := result.Raw()
157 if err != nil {
158 return nil, err
159 }
160 uncastObj, err := runtime.Decode(unstructured.UnstructuredJSONScheme, retBytes)
161 if err != nil {
162 return nil, err
163 }
164 return uncastObj.(*unstructured.Unstructured), nil
165}
166
167func (c *dynamicResourceClient) UpdateStatus(obj *unstructured.Unstructured, opts metav1.UpdateOptions) (*unstructured.Unstructured, error) {
168 accessor, err := meta.Accessor(obj)

Callers

nothing calls this directly

Calls 12

makeURLSegmentsMethod · 0.95
BodyMethod · 0.80
AbsPathMethod · 0.80
RawMethod · 0.80
GetNameMethod · 0.65
ErrorfMethod · 0.65
DoMethod · 0.65
PutMethod · 0.65
ErrorMethod · 0.65
EncodeMethod · 0.45
DecodeMethod · 0.45

Tested by

no test coverage detected