This example shows how to use the client with typed and unstructured objects to patch objects.
()
| 202 | |
| 203 | // This example shows how to use the client with typed and unstructured objects to patch objects. |
| 204 | func ExampleClient_patch() { |
| 205 | patch := []byte(`{"metadata":{"annotations":{"version": "v2"}}}`) |
| 206 | _ = c.Patch(context.Background(), &corev1.Pod{ |
| 207 | ObjectMeta: metav1.ObjectMeta{ |
| 208 | Namespace: "namespace", |
| 209 | Name: "name", |
| 210 | }, |
| 211 | }, client.RawPatch(types.StrategicMergePatchType, patch)) |
| 212 | } |
| 213 | |
| 214 | // This example shows how to use the client with unstructured objects to create/patch objects using Server Side Apply, |
| 215 | // "k8s.io/apimachinery/pkg/runtime".DefaultUnstructuredConverter.ToUnstructured is used to convert an object into map[string]any representation, |