Search in sources :

Example 61 with CruiseConfig

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));
}
Also used : HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 62 with CruiseConfig

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;
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 63 with CruiseConfig

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;
}
Also used : CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 64 with CruiseConfig

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];
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) GsonBuilder(com.google.gson.GsonBuilder) Materials(com.thoughtworks.go.config.materials.Materials) FanInGraph(com.thoughtworks.go.server.service.dd.FanInGraph) Material(com.thoughtworks.go.domain.materials.Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) DependencyFanInNode(com.thoughtworks.go.server.service.dd.DependencyFanInNode) FanInEventListener(com.thoughtworks.go.server.service.dd.FanInEventListener)

Example 65 with CruiseConfig

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())));
}
Also used : ConfigCache(com.thoughtworks.go.config.ConfigCache) ByteArrayInputStream(java.io.ByteArrayInputStream) MagicalGoConfigXmlLoader(com.thoughtworks.go.config.MagicalGoConfigXmlLoader) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) Test(org.junit.Test)

Aggregations

CruiseConfig (com.thoughtworks.go.config.CruiseConfig)95 Test (org.junit.Test)77 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)54 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)35 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)33 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)32 ServerConfig (com.thoughtworks.go.config.ServerConfig)11 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)7 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)5 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)5 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)4 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)4 File (java.io.File)4 ConfigCache (com.thoughtworks.go.config.ConfigCache)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)3 MagicalGoConfigXmlLoader (com.thoughtworks.go.config.MagicalGoConfigXmlLoader)3 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)3 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)3