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) {
}
}
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;
}
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;
}
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));
}
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));
}
Aggregations