use of com.google.copybara.config.ValidationResult.ValidationMessage in project copybara by google.
the class ValidateCmd method run.
@Override
public ExitCode run(CommandEnv commandEnv) throws ValidationException, IOException, RepoException {
ConfigFileArgs configFileArgs = commandEnv.parseConfigFileArgs(this, /*useSourceRef*/
false);
ConfigLoader configLoader = configLoaderProvider.newLoader(configFileArgs.getConfigPath(), configFileArgs.getSourceRef());
ValidationResult result = validate(commandEnv.getOptions(), configLoader, configFileArgs.getWorkflowName());
Console console = commandEnv.getOptions().get(GeneralOptions.class).console();
for (ValidationMessage message : result.getAllMessages()) {
switch(message.getLevel()) {
case WARNING:
console.warn(message.getMessage());
break;
case ERROR:
console.error(message.getMessage());
break;
}
}
if (result.hasErrors()) {
console.errorFmt("Configuration '%s' is invalid.", configLoader.location());
return ExitCode.CONFIGURATION_ERROR;
}
console.infoFmt("Configuration '%s' is valid.", configLoader.location());
return ExitCode.SUCCESS;
}
Aggregations