use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class HealthStateScopeTest method shouldRemoveScopeWhenMaterialIsRemovedFromConfig.
@Test
public void shouldRemoveScopeWhenMaterialIsRemovedFromConfig() throws Exception {
HgMaterialConfig hgMaterialConfig = MaterialConfigsMother.hgMaterialConfig();
CruiseConfig config = GoConfigMother.pipelineHavingJob("blahPipeline", "blahStage", "blahJob", "fii", "baz");
config.pipelineConfigByName(new CaseInsensitiveString("blahPipeline")).addMaterialConfig(hgMaterialConfig);
assertThat(HealthStateScope.forMaterialConfig(hgMaterialConfig).isRemovedFromConfig(config), is(false));
assertThat(HealthStateScope.forMaterial(MaterialsMother.svnMaterial("file:///bar")).isRemovedFromConfig(config), is(true));
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class PipelinePauseService method notAuthorized.
private boolean notAuthorized(String pipelineName, String pauseBy, LocalizedOperationResult result) {
CruiseConfig cruiseConfig = goConfigService.getCurrentConfig();
PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
if (securityService.hasOperatePermissionForGroup(new CaseInsensitiveString(pauseBy), cruiseConfig.findGroupOfPipeline(pipelineConfig).getGroup())) {
return false;
}
result.unauthorized(LocalizedMessage.string("UNAUTHORIZED_TO_EDIT_PIPELINE", pipelineName), HealthStateType.unauthorisedForPipeline(pipelineName));
return true;
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class PipelinePauseService method pipelineDoesNotExist.
private boolean pipelineDoesNotExist(String pipelineName, LocalizedOperationResult result) {
CruiseConfig cruiseConfig = goConfigService.getCurrentConfig();
if (cruiseConfig.hasPipelineNamed(new CaseInsensitiveString(pipelineName))) {
return false;
}
result.notFound(LocalizedMessage.string("RESOURCE_NOT_FOUND", "pipeline", pipelineName), HealthStateType.general(HealthStateScope.forPipeline(pipelineName)));
return true;
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class PipelineService method getRevisionsBasedOnDependenciesForDebug.
// This is for debugging purposes
public String getRevisionsBasedOnDependenciesForDebug(CaseInsensitiveString pipelineName, final Integer targetIterationCount) {
CruiseConfig cruiseConfig = goConfigService.getCurrentConfig();
FanInGraph fanInGraph = new FanInGraph(cruiseConfig, pipelineName, materialRepository, pipelineDao, systemEnvironment, materialConfigConverter);
final String[] iterationData = { null };
fanInGraph.setFanInEventListener(new FanInEventListener() {
@Override
public void iterationComplete(int iterationCount, List<DependencyFanInNode> dependencyFanInNodes) {
if (iterationCount == targetIterationCount) {
iterationData[0] = new GsonBuilder().setExclusionStrategies(getGsonExclusionStrategy()).create().toJson(dependencyFanInNodes);
}
}
});
PipelineConfig pipelineConfig = goConfigService.pipelineConfigNamed(pipelineName);
Materials materials = materialConfigConverter.toMaterials(pipelineConfig.materialConfigs());
MaterialRevisions actualRevisions = new MaterialRevisions();
for (Material material : materials) {
actualRevisions.addAll(materialRepository.findLatestModification(material));
}
MaterialRevisions materialRevisions = fanInGraph.computeRevisions(actualRevisions, pipelineTimeline);
if (iterationData[0] == null) {
iterationData[0] = new GsonBuilder().setExclusionStrategies(getGsonExclusionStrategy()).create().toJson(materialRevisions);
}
return iterationData[0];
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class UniqueRunIfStatusValidatorTest method shouldPassWhenEachJobContainsOnCancel.
@Test
public void shouldPassWhenEachJobContainsOnCancel() throws Exception {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(ConfigMigrator.migrate(ConfigFileFixture.CONTAINS_MULTI_DIFFERENT_STATUS_RUN_IF).getBytes());
CruiseConfig cruiseConfig = new MagicalGoConfigXmlLoader(new ConfigCache(), ConfigElementImplementationRegistryMother.withNoPlugins()).loadConfigHolder(IOUtils.toString(inputStream, UTF_8)).config;
assertThat(cruiseConfig, is(not(nullValue())));
}
Aggregations