reconcile method

  1. @override
Reconciliation reconcile(
  1. DesiredState desired,
  2. CurrentState current
)
override

Plans the steps required to converge current toward desired.

Implementation

@override
Reconciliation reconcile(DesiredState desired, CurrentState current) {
  final actions = <PresetStep>[];
  final notes = <String>[];
  for (final step in desired.steps) {
    final present = current.capabilities.hasNamed(step.formula.value);
    final satisfiesByPresence =
        step.action == FormulaAction.install ||
        step.action == FormulaAction.verify;
    if (present && satisfiesByPresence) {
      notes.add('skip ${step.formula.value}: already present');
    } else {
      actions.add(step);
      notes.add('run ${step.formula.value}:${step.action.name}');
    }
  }
  return Reconciliation(actions: actions, notes: notes);
}