Search in sources :

Example 16 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class ArtifactDirValidatorTest method shouldThrowExceptionWhenUserProvidesPathPointToServerSandBox.

@Test
public void shouldThrowExceptionWhenUserProvidesPathPointToServerSandBox() {
    File file = new File("");
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig(file.getAbsolutePath(), null));
    ArtifactDirValidator dirValidator = new ArtifactDirValidator();
    try {
        dirValidator.validate(cruiseConfig);
        fail("should throw exception, see dot will make server check out the repository in the wrong place.");
    } catch (Exception e) {
    }
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) File(java.io.File) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 17 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class ConfigInfoProvider method asJson.

@Override
public Map<String, Object> asJson() {
    LinkedHashMap<String, Object> json = new LinkedHashMap<>();
    CruiseConfig currentConfig = goConfigService.getCurrentConfig();
    LinkedHashMap<String, Object> validConfig = new LinkedHashMap<>();
    validConfig.put("Number of pipelines", goConfigService.getAllPipelineConfigs().size());
    validConfig.put("Number of agents", goConfigService.agents().size());
    validConfig.put("Number of environments", currentConfig.getEnvironments().size());
    validConfig.put("Number of unique materials", currentConfig.getAllUniqueMaterials().size());
    validConfig.put("Number of schedulable materials", goConfigService.getSchedulableMaterials().size());
    json.put("Valid Config", validConfig);
    json.put("Security", securityInformation());
    return json;
}
Also used : CruiseConfig(com.thoughtworks.go.config.CruiseConfig) LinkedHashMap(java.util.LinkedHashMap)

Example 18 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class ScheduledPipelineLoader method knownMaterials.

private MaterialConfigs knownMaterials(Pipeline pipeline, MaterialRevisions scheduledRevs) {
    CruiseConfig currentConfig = goConfigService.getCurrentConfig();
    MaterialConfigs configuredMaterials = new MaterialConfigs();
    for (MaterialRevision revision : scheduledRevs) {
        String fingerprint = revision.getMaterial().getFingerprint();
        // first try to find material config from current pipeline config
        MaterialConfig configuredMaterial = currentConfig.materialConfigFor(new CaseInsensitiveString(pipeline.getName()), fingerprint);
        if (configuredMaterial != null) {
            configuredMaterials.add(configuredMaterial);
            continue;
        }
        // todo: remove the global lookup fallback code after we feel safe
        if (new SystemEnvironment().get(SystemEnvironment.GO_SERVER_SCHEDULED_PIPELINE_LOADER_GLOBAL_MATERIAL_LOOKUP)) {
            // fallback to global lookup if material is not in current pipeline config (old behavior)
            configuredMaterial = currentConfig.materialConfigFor(fingerprint);
            if (configuredMaterial != null) {
                configuredMaterials.add((configuredMaterial));
            }
        }
    }
    MaterialConfigs knownMaterials = new MaterialConfigs();
    for (MaterialConfig configuredMaterial : configuredMaterials) {
        materialExpansionService.expandForScheduling(configuredMaterial, knownMaterials);
    }
    return knownMaterials;
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 19 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class UpdateEnvironmentsCommandTest method shouldAddAgentToListOfEnvironment.

@Test
public void shouldAddAgentToListOfEnvironment() throws Exception {
    String agentUuid = "uuid";
    UpdateEnvironmentsCommand command = new UpdateEnvironmentsCommand(agentUuid, "foo, bar, baz");
    CruiseConfig cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    cruiseConfig.addEnvironment("foo");
    cruiseConfig.addEnvironment("bar");
    cruiseConfig.addEnvironment("baz");
    command.update(cruiseConfig);
    EnvironmentsConfig environments = cruiseConfig.getEnvironments();
    assertThat(environments.named(new CaseInsensitiveString("foo")).getAgents().getUuids().contains(agentUuid), is(true));
    assertThat(environments.named(new CaseInsensitiveString("bar")).getAgents().getUuids().contains(agentUuid), is(true));
    assertThat(environments.named(new CaseInsensitiveString("baz")).getAgents().getUuids().contains(agentUuid), is(true));
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) EnvironmentsConfig(com.thoughtworks.go.config.EnvironmentsConfig) Test(org.junit.Test)

Example 20 with CruiseConfig

use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.

the class UpdateEnvironmentsCommandTest method shouldNotThrowUpIfEnvironmentNameIsInvalid.

@Test
public void shouldNotThrowUpIfEnvironmentNameIsInvalid() throws Exception {
    String agentUuid = "uuid";
    UpdateEnvironmentsCommand command = new UpdateEnvironmentsCommand(agentUuid, "foo, bar, monkey");
    CruiseConfig cruiseConfig = new GoConfigMother().defaultCruiseConfig();
    cruiseConfig.addEnvironment("foo");
    cruiseConfig.addEnvironment("bar");
    command.update(cruiseConfig);
    EnvironmentsConfig environments = cruiseConfig.getEnvironments();
    assertThat(environments.named(new CaseInsensitiveString("foo")).getAgents().getUuids().contains(agentUuid), is(true));
    assertThat(environments.named(new CaseInsensitiveString("bar")).getAgents().getUuids().contains(agentUuid), is(true));
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GoConfigMother(com.thoughtworks.go.helper.GoConfigMother) EnvironmentsConfig(com.thoughtworks.go.config.EnvironmentsConfig) 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