use of org.opensearch.cli.Terminal in project OpenSearch by opensearch-project.
the class ValidateInputTask method accept.
@Override
public void accept(final Tuple<TaskInput, Terminal> input) {
final TaskInput taskInput = input.v1();
final Terminal terminal = input.v2();
terminal.println("Verifying the details ...");
// check if the elasticsearch version is supported
if (taskInput.getVersion().isPresent()) {
final Version version = taskInput.getVersion().get();
if (version.equals(LegacyESVersion.V_7_10_2) == false) {
throw new RuntimeException(String.format(Locale.getDefault(), "The installed version %s of elasticsearch is not supported.", version));
}
} else {
terminal.println("Unable to detect installed elasticsearch version.");
confirmToProceed(terminal);
}
// check if the OpenSearch config is set to an external location
if (taskInput.getOpenSearchConfig().getParent().equals(taskInput.getOpenSearchBin().getParent())) {
terminal.println("OpenSearch config directory is set inside the installation directory. " + "It is recommended to use an external config directory and set the environment variable " + "OPENSEARCH_PATH_CONF to it.");
confirmToProceed(terminal);
}
// print summary and confirm with user if everything looks correct.
final Map<String, String> fieldsMap = getSummaryFieldsMap(taskInput);
final String format = " %-25s | %s";
terminal.println("+----------------------- SUMMARY -----------------------+");
for (Map.Entry<String, String> entry : fieldsMap.entrySet()) {
terminal.println(String.format(Locale.getDefault(), format, entry.getKey(), entry.getValue()));
}
terminal.println("+-------------------------------------------------------+");
terminal.println("Please verify if everything above looks good.");
confirmToProceed(terminal);
}
Aggregations