toYamlMap method

Map<String, Object?> toYamlMap()

The yaml node shape for host persistence (the agent: section's stuckTool: sub-map); only non-default values are written so the config file stays minimal.

Implementation

Map<String, Object?> toYamlMap() {
  final map = <String, Object?>{};
  if (!enabled) map['enabled'] = false;
  if (followUp != StuckFollowUpMode.autonomous) {
    map['followUp'] = followUp.name;
  }
  if (floor.inSeconds != defaultStuckFloorSeconds) {
    map['floorSeconds'] = floor.inSeconds;
  }
  if (declaredTimeoutFactor != defaultStuckDeclaredTimeoutFactor) {
    map['declaredTimeoutFactor'] = declaredTimeoutFactor;
  }
  if (heartbeatInterval.inSeconds != defaultStuckHeartbeatSeconds) {
    map['heartbeatSeconds'] = heartbeatInterval.inSeconds;
  }
  if (cancelGrace.inSeconds != defaultStuckCancelGraceSeconds) {
    map['cancelGraceSeconds'] = cancelGrace.inSeconds;
  }
  if (!_listEquals(excludeTools, defaultStuckExcludedTools)) {
    map['excludeTools'] = List<String>.of(excludeTools);
  }
  return map;
}