updateState updates the state field of a resource. It uses the state from the passed resource and disregards its other fields.
(name *runtimev1.ResourceName, from *runtimev1.Resource)
| 337 | // updateState updates the state field of a resource. |
| 338 | // It uses the state from the passed resource and disregards its other fields. |
| 339 | func (c *catalogCache) updateState(name *runtimev1.ResourceName, from *runtimev1.Resource) error { |
| 340 | r, err := c.get(name, true, true) |
| 341 | if err != nil { |
| 342 | return err |
| 343 | } |
| 344 | c.unlink(r) |
| 345 | err = c.ctrl.reconciler(name.Kind).AssignState(from, r) |
| 346 | if err != nil { |
| 347 | return err |
| 348 | } |
| 349 | r.Meta.Version++ |
| 350 | r.Meta.StateVersion++ |
| 351 | r.Meta.StateUpdatedOn = timestamppb.Now() |
| 352 | c.link(r) |
| 353 | c.dirty[nameStr(r.Meta.Name)] = r.Meta.Name |
| 354 | c.addEvent(r.Meta.Name, r, runtimev1.ResourceEvent_RESOURCE_EVENT_WRITE) |
| 355 | return nil |
| 356 | } |
| 357 | |
| 358 | // updateErrorAndWarning updates both reconcile_error and reconcile_warnings of a resource. |
| 359 | func (c *catalogCache) updateErrorAndWarning(name *runtimev1.ResourceName, reconcileErr error, warnings []string) error { |
no test coverage detected