MCPcopy Index your code
hub / github.com/kubernetes/sample-controller / updateFooStatus

Method updateFooStatus

controller.go:314–326  ·  view source on GitHub ↗
(ctx context.Context, foo *samplev1alpha1.Foo, deployment *appsv1.Deployment)

Source from the content-addressed store, hash-verified

312}
313
314func (c *Controller) updateFooStatus(ctx context.Context, foo *samplev1alpha1.Foo, deployment *appsv1.Deployment) error {
315 // NEVER modify objects from the store. It's a read-only, local cache.
316 // You can use DeepCopy() to make a deep copy of original object and modify this copy
317 // Or create a copy manually for better performance
318 fooCopy := foo.DeepCopy()
319 fooCopy.Status.AvailableReplicas = deployment.Status.AvailableReplicas
320 // If the CustomResourceSubresources feature gate is not enabled,
321 // we must use Update instead of UpdateStatus to update the Status block of the Foo resource.
322 // UpdateStatus will not allow changes to the Spec of the resource,
323 // which is ideal for ensuring nothing other than resource status has been updated.
324 _, err := c.sampleclientset.SamplecontrollerV1alpha1().Foos(foo.Namespace).UpdateStatus(ctx, fooCopy, metav1.UpdateOptions{FieldManager: FieldManager})
325 return err
326}
327
328// enqueueFoo takes a Foo resource and converts it into a namespace/name
329// string which is then put onto the work queue. This method should *not* be

Callers 1

syncHandlerMethod · 0.95

Calls 4

UpdateStatusMethod · 0.80
FoosMethod · 0.65
DeepCopyMethod · 0.45

Tested by

no test coverage detected