MCPcopy
hub / github.com/kubernetes-sigs/controller-runtime / ExampleClient_patchStatus

Function ExampleClient_patchStatus

pkg/client/example_test.go:240–255  ·  view source on GitHub ↗

This example shows how to use the client with typed and unstructured objects to patch objects' status.

()

Source from the content-addressed store, hash-verified

238
239// This example shows how to use the client with typed and unstructured objects to patch objects' status.
240func ExampleClient_patchStatus() {
241 u := &unstructured.Unstructured{}
242 u.Object = map[string]any{
243 "metadata": map[string]any{
244 "name": "foo",
245 "namespace": "namespace",
246 },
247 }
248 u.SetGroupVersionKind(schema.GroupVersionKind{
249 Group: "batch",
250 Version: "v1beta1",
251 Kind: "CronJob",
252 })
253 patch := []byte(fmt.Sprintf(`{"status":{"lastScheduleTime":"%s"}}`, time.Now().Format(time.RFC3339)))
254 _ = c.Status().Patch(context.Background(), u, client.RawPatch(types.MergePatchType, patch))
255}
256
257// This example shows how to use the client with typed and unstructured objects to delete objects.
258func ExampleClient_delete() {

Callers

nothing calls this directly

Calls 4

RawPatchFunction · 0.92
PatchMethod · 0.65
StatusMethod · 0.65
SetGroupVersionKindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…