status method
The state of integration.
Implementation
Future<TomSecretsIntegrationState> status(
TomSecretsIntegration integration,
) async {
final file = fileOf(integration);
final text = await _read(file);
final block = text == null ? null : tomSecretsBlockOf(text);
if (block == null) {
return TomSecretsIntegrationState(
integration,
installed: false,
current: false,
file: file,
);
}
final problems = <String>[];
String? hosts;
switch (integration) {
case TomSecretsIntegration.ssh:
hosts = _hostsOf(block);
final endpoint = agentEndpoint;
if (endpoint == null) {
problems.add('the service names no agent (is it running?)');
} else if (block.join('\n') !=
sshBlock(hosts: hosts ?? '*').join('\n')) {
problems.add('the block does not name this agent ($endpoint)');
}
case TomSecretsIntegration.git:
if (block.join('\n') != gitBlock.join('\n')) {
problems.add('the block does not name the helper tsm');
}
problems.addAll(await _linkProblems());
}
return TomSecretsIntegrationState(
integration,
installed: true,
current: problems.isEmpty,
file: file,
problems: problems,
hosts: hosts,
);
}