use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class PipelineConfigTreeValidator method validate.
public boolean validate(PipelineConfigSaveValidationContext validationContext) {
pipelineConfig.validate(validationContext);
pipelineCreationSpecificValidations(validationContext);
validateDependencies(validationContext);
boolean isValid = pipelineConfig.errors().isEmpty();
PipelineConfigSaveValidationContext contextForChildren = validationContext.withParent(pipelineConfig);
for (StageConfig stageConfig : pipelineConfig.getStages()) {
isValid = stageConfig.validateTree(contextForChildren) && isValid;
if (pipelineConfig.hasTemplateApplied()) {
final List<ConfigErrors> allErrors = new ArrayList<>();
new GoConfigGraphWalker(stageConfig).walk(new ErrorCollectingHandler(allErrors) {
@Override
public void handleValidation(Validatable validatable, ValidationContext context) {
}
});
for (ConfigErrors error : allErrors) {
pipelineConfig.errors().add("template", ListUtil.join(error.getAll()));
}
}
}
validateCyclicDependencies(validationContext);
isValid = pipelineConfig.materialConfigs().validateTree(contextForChildren) && isValid;
isValid = pipelineConfig.getParams().validateTree(contextForChildren) && isValid;
isValid = pipelineConfig.getVariables().validateTree(contextForChildren) && isValid;
if (pipelineConfig.getTrackingTool() != null)
isValid = pipelineConfig.getTrackingTool().validateTree(contextForChildren) && isValid;
if (pipelineConfig.getMingleConfig() != null)
isValid = pipelineConfig.getMingleConfig().validateTree(contextForChildren) && isValid;
if (pipelineConfig.getTimer() != null)
isValid = pipelineConfig.getTimer().validateTree(contextForChildren) && isValid;
return isValid;
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class GoConfigInvalidMergeException method allErrorsToString.
private static String allErrorsToString(List<ConfigErrors> allErrors, String summary) {
if (allErrors == null || allErrors.size() == 0)
// should never be
return "Error list empty";
StringBuilder b = new StringBuilder();
b.append(allErrors.size()).append("+ errors :: ");
for (ConfigErrors e : allErrors) {
b.append(e.firstError()).append(";; ");
}
return b.toString();
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class EnvironmentAgentValidator method validate.
public void validate(CruiseConfig cruiseConfig) throws Exception {
List<ConfigErrors> errors = validateConfig(cruiseConfig);
List<String> errorMessages = new ArrayList<>();
for (ConfigErrors error : errors) {
errorMessages.addAll(error.getAll());
}
if (!errors.isEmpty())
throw new RuntimeException(ListUtil.join(errorMessages));
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class AdminRoleTest method shouldAddValidationErrorIfRoleNameInPipelinesAuthorizationDoesNotExist_PipelineConfigSaveValidationContext.
@Test
public void shouldAddValidationErrorIfRoleNameInPipelinesAuthorizationDoesNotExist_PipelineConfigSaveValidationContext() throws Exception {
AdminRole role = new AdminRole(new CaseInsensitiveString("role2"));
PipelineConfig pipelineConfig = new PipelineConfig();
PipelineConfigs pipelinesConfig = new BasicPipelineConfigs(new Authorization(new ViewConfig(role)), pipelineConfig);
CruiseConfig config = new BasicCruiseConfig(pipelinesConfig);
role.validate(PipelineConfigSaveValidationContext.forChain(true, "group", config, pipelineConfig));
ConfigErrors errors = role.errors();
assertThat(errors.isEmpty(), is(false));
assertThat(errors.on(AdminRole.NAME), is("Role \"role2\" does not exist."));
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class AdminRoleTest method shouldThrowExceptionIfRoleNameInPipelinesAuthorizationDoesNotExist_ConfigSaveValidationContext.
@Test
public void shouldThrowExceptionIfRoleNameInPipelinesAuthorizationDoesNotExist_ConfigSaveValidationContext() throws Exception {
AdminRole role = new AdminRole(new CaseInsensitiveString("role2"));
PipelineConfigs pipelinesConfig = new BasicPipelineConfigs(new Authorization(new ViewConfig(role)));
CruiseConfig config = new BasicCruiseConfig(pipelinesConfig);
role.validate(ConfigSaveValidationContext.forChain(config));
ConfigErrors errors = role.errors();
assertThat(errors.isEmpty(), is(false));
assertThat(errors.on(AdminRole.NAME), is("Role \"role2\" does not exist."));
}
Aggregations