This example shows how to use the client with typed and unstructured objects to update objects.
()
| 175 | |
| 176 | // This example shows how to use the client with typed and unstructured objects to update objects. |
| 177 | func ExampleClient_update() { |
| 178 | // Using a typed object. |
| 179 | pod := &corev1.Pod{} |
| 180 | // c is a created client. |
| 181 | _ = c.Get(context.Background(), client.ObjectKey{ |
| 182 | Namespace: "namespace", |
| 183 | Name: "name", |
| 184 | }, pod) |
| 185 | controllerutil.AddFinalizer(pod, "new-finalizer") |
| 186 | _ = c.Update(context.Background(), pod) |
| 187 | |
| 188 | // Using a unstructured object. |
| 189 | u := &unstructured.Unstructured{} |
| 190 | u.SetGroupVersionKind(schema.GroupVersionKind{ |
| 191 | Group: "apps", |
| 192 | Kind: "Deployment", |
| 193 | Version: "v1", |
| 194 | }) |
| 195 | _ = c.Get(context.Background(), client.ObjectKey{ |
| 196 | Namespace: "namespace", |
| 197 | Name: "name", |
| 198 | }, u) |
| 199 | controllerutil.AddFinalizer(u, "new-finalizer") |
| 200 | _ = c.Update(context.Background(), u) |
| 201 | } |
| 202 | |
| 203 | // This example shows how to use the client with typed and unstructured objects to patch objects. |
| 204 | func ExampleClient_patch() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…