run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<void> run() async {
final args = argResults!;
final client = _apiClientFrom(args);
try {
final nodes = await _selectNodes(client, args, positional: args.rest);
final async = args['async'] as bool;
await _fanOut(nodes, (node) async {
final reply =
await client.post('/nodes/$node/reconcile', {
if (async) 'async': true,
})
as Map;
if (async) return 'dispatched — ops show ${reply['id']}';
final results = (reply['results'] as List).cast<Map>();
if (results.isEmpty) return 'already converged — nothing to do';
final failed = results.where((r) => r['success'] != true).length;
return failed == 0
? 'converged (${results.length} steps ran)'
: 'FAILED $failed/${results.length} steps';
});
} finally {
client.close();
}
}