use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class ConfigReposConfig method getAllErrors.
public ConfigErrors getAllErrors() {
ConfigErrors configErrors = new ConfigErrors();
configErrors.addAll(errors);
for (ConfigRepoConfig repoConfig : this) {
configErrors.addAll(repoConfig.errors());
}
return configErrors;
}
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(StringUtils.join(errorMessages, ", "));
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class GoFileConfigDataSourceTest method shouldNotRetryConfigSaveWhenConfigRepoIsNotSetup.
@Test
public void shouldNotRetryConfigSaveWhenConfigRepoIsNotSetup() throws Exception {
MagicalGoConfigXmlLoader loader = mock(MagicalGoConfigXmlLoader.class);
MagicalGoConfigXmlWriter writer = mock(MagicalGoConfigXmlWriter.class);
GoConfigMigration migration = mock(GoConfigMigration.class);
ServerHealthService serverHealthService = mock(ServerHealthService.class);
CachedGoPartials cachedGoPartials = mock(CachedGoPartials.class);
ConfigRepository configRepository = mock(ConfigRepository.class);
dataSource = new GoFileConfigDataSource(migration, configRepository, systemEnvironment, timeProvider, mock(ServerVersion.class), loader, writer, serverHealthService, cachedGoPartials, null, null, null, null);
final String pipelineName = UUID.randomUUID().toString();
BasicCruiseConfig cruiseConfig = GoConfigMother.configWithPipelines(pipelineName);
ConfigErrors configErrors = new ConfigErrors();
configErrors.add("key", "some error");
when(loader.loadConfigHolder(Matchers.any(String.class))).thenThrow(new GoConfigInvalidException(cruiseConfig, configErrors.firstError()));
try {
dataSource.writeWithLock(new UpdateConfigCommand() {
@Override
public CruiseConfig update(CruiseConfig cruiseConfig) throws Exception {
cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString(pipelineName)).clear();
return cruiseConfig;
}
}, new GoConfigHolder(cruiseConfig, cruiseConfig));
fail("expected the test to fail");
} catch (Exception e) {
verifyZeroInteractions(configRepository);
verifyZeroInteractions(serverHealthService);
verify(loader, times(1)).loadConfigHolder(Matchers.any(String.class), Matchers.any(MagicalGoConfigXmlLoader.Callback.class));
}
}
use of com.thoughtworks.go.domain.ConfigErrors in project gocd by gocd.
the class AdminRoleTest method shouldAddValidationErrorWithPipelineNameIfRoleNameInPipelinesAuthorizationDoesNotExist_PipelineConfigSaveValidationContext.
@Test
public void shouldAddValidationErrorWithPipelineNameIfRoleNameInPipelinesAuthorizationDoesNotExist_PipelineConfigSaveValidationContext() {
AdminRole role = new AdminRole(new CaseInsensitiveString("role2"));
PipelineConfig pipelineConfig = new PipelineConfig();
pipelineConfig.setName("foo");
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 BuildTaskTest method shouldErrorOutIfWorkingDirectoryIsOutsideTheCurrentWorkingDirectory.
@Test
public void shouldErrorOutIfWorkingDirectoryIsOutsideTheCurrentWorkingDirectory() {
BuildTask task = new BuildTask() {
@Override
public String getTaskType() {
return "build";
}
public String getTypeForDisplay() {
return null;
}
@Override
public String command() {
return null;
}
@Override
public String arguments() {
return null;
}
};
task.setWorkingDirectory("/blah");
CruiseConfig config = GoConfigMother.configWithPipelines("pipeline");
PipelineConfig pipeline = config.pipelineConfigByName(new CaseInsensitiveString("pipeline"));
StageConfig stage = pipeline.get(0);
JobConfig job = stage.getJobs().get(0);
job.addTask(task);
List<ConfigErrors> errors = config.validateAfterPreprocess();
assertThat(errors.size(), is(1));
String message = "Task of job 'job' in stage 'stage' of pipeline 'pipeline' has path '/blah' which is outside the working directory.";
assertThat(task.errors().on(BuildTask.WORKING_DIRECTORY), is(message));
}
Aggregations