in operator/controllers/operator/fetcher_controller.go [81:116]
func (r *FetcherReconciler) UpdateStatus(ctx context.Context, fetcher *operatorv1alpha1.Fetcher, status core.ConditionStatus, msg string) error {
log := runtimelog.FromContext(ctx)
if fetcher.Status.Replicas == 0 {
fetcher.Status.Replicas = 1
}
now := metav1.NewTime(time.Now())
changed := false
if len(fetcher.Status.Conditions) < 1 {
changed = true
fetcher.Status.Conditions = append(fetcher.Status.Conditions, operatorv1alpha1.FetcherCondition{
Type: operatorv1alpha1.FetcherConditionTypeRead,
Status: status,
Message: msg,
LastTransitionTime: now,
LastUpdateTime: now,
})
} else {
current := fetcher.Status.Conditions[0]
if current.Status != status || current.Message != msg {
changed = true
current.Status = status
current.Message = msg
current.LastUpdateTime = now
}
}
if !changed {
return nil
}
overlay := fetcher.Status
if err := r.updateStatus(ctx, fetcher, overlay, log); err != nil {
log.Error(err, "failed to update status")
return err
}
return nil
}