func (r *ReconcileLocalVolumeDiscovery) updateDiscoveryStatus(instance *localv1alpha1.LocalVolumeDiscovery, conditionType, message string,
	status operatorv1.ConditionStatus, phase localv1alpha1.DiscoveryPhase) error {
	// avoid frequently updating the same status in the CR
	if len(instance.Status.Conditions) < 1 || instance.Status.Conditions[0].Message != message {
		condition := operatorv1.OperatorCondition{
			Type:               conditionType,
			Status:             status,
			Message:            message,
			LastTransitionTime: metav1.Now(),
		}
		newConditions := []operatorv1.OperatorCondition{condition}
		instance.Status.Conditions = newConditions
		instance.Status.Phase = phase
		instance.Status.ObservedGeneration = instance.Generation
		err := r.updateStatus(instance)
		if err != nil {
			return err
		}
	}

	return nil
}
// updateDiscoveryStatus updates the discovery state with conditions and phase
updateDiscoveryStatus updates the discovery state with conditions and phase
// updateDiscoveryStatus updates the discovery state with conditions and phase
func (r *ReconcileLocalVolumeDiscovery) updateDiscoveryStatus(instance *localv1alpha1.LocalVolumeDiscovery, conditionType, message string,
	status operatorv1.ConditionStatus, phase localv1alpha1.DiscoveryPhase) error {
	if len(instance.Status.Conditions) < 1 || instance.Status.Conditions[0].Message != message {
		condition := operatorv1.OperatorCondition{
			Type:               conditionType,
			Status:             status,
			Message:            message,
			LastTransitionTime: metav1.Now(),
		}
		newConditions := []operatorv1.OperatorCondition{condition}
		instance.Status.Conditions = newConditions
		instance.Status.Phase = phase
		instance.Status.ObservedGeneration = instance.Generation
		err := r.updateStatus(instance)
		if err != nil {
			return err
		}
	}
	return nil
}
func ( r * ReconcileLocalVolumeDiscovery ) updateDiscoveryStatus ( instance * localv1alpha1 . LocalVolumeDiscovery , conditionType , message string , status operatorv1 . ConditionStatus , phase localv1alpha1 . DiscoveryPhase ) error { if len ( instance . Status . Conditions ) < 1 || instance . Status . Conditions [ 0 ] . Message != message { condition := operatorv1 . OperatorCondition { Type : conditionType , Status : status , Message : message , LastTransitionTime : metav1 . Now ( ) , } newConditions := [ ] operatorv1 . OperatorCondition { condition } instance . Status . Conditions = newConditions instance . Status . Phase = phase instance . Status . ObservedGeneration = instance . Generation err := r . updateStatus ( instance ) if err != nil { return err } } return nil }
updateDiscoveryStatus updates the discovery state with conditions and phase
updateDiscoveryStatus updates the discovery state with conditions and phase
// avoid frequently updating the same status in the CR