use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class BasicCruiseConfig method getUniqueMaterials.
private Set<MaterialConfig> getUniqueMaterials(boolean ignoreManualPipelines, boolean ignoreConfigRepos) {
Set<MaterialConfig> materialConfigs = new HashSet<>();
Set<Map> uniqueMaterials = new HashSet<>();
for (PipelineConfig pipelineConfig : pipelinesFromAllGroups()) {
for (MaterialConfig materialConfig : pipelineConfig.materialConfigs()) {
if (!uniqueMaterials.contains(materialConfig.getSqlCriteria())) {
boolean shouldSkipPolling = !materialConfig.isAutoUpdate();
boolean scmOrPackageMaterial = !(materialConfig instanceof DependencyMaterialConfig);
if (ignoreManualPipelines && scmOrPackageMaterial && shouldSkipPolling) {
continue;
}
materialConfigs.add(materialConfig);
uniqueMaterials.add(materialConfig.getSqlCriteria());
}
}
}
if (!ignoreConfigRepos) {
for (ConfigRepoConfig configRepo : this.configRepos) {
MaterialConfig materialConfig = configRepo.getMaterialConfig();
if (!uniqueMaterials.contains(materialConfig.getSqlCriteria())) {
materialConfigs.add(materialConfig);
uniqueMaterials.add(materialConfig.getSqlCriteria());
}
}
}
return materialConfigs;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class BasicCruiseConfig method materialConfigFor.
@Override
public MaterialConfig materialConfigFor(CaseInsensitiveString pipelineName, String fingerprint) {
PipelineConfig pipelineConfig = pipelineConfigByName(pipelineName);
MaterialConfigs materialConfigs = pipelineConfig.materialConfigs();
for (MaterialConfig materialConfig : materialConfigs) {
if (materialConfig.getFingerprint().equals(fingerprint)) {
return materialConfig;
}
}
return null;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class ConfigSaveValidationContext method primeForMaterialValidations.
private void primeForMaterialValidations() {
CruiseConfig cruiseConfig = getCruiseConfig();
fingerprintToMaterials = new HashMap<>();
for (PipelineConfig pipelineConfig : cruiseConfig.getAllPipelineConfigs()) {
for (MaterialConfig material : pipelineConfig.materialConfigs()) {
String fingerprint = material.getFingerprint();
if (!fingerprintToMaterials.containsKey(fingerprint)) {
fingerprintToMaterials.put(fingerprint, new MaterialConfigs());
}
MaterialConfigs materialsForFingerprint = fingerprintToMaterials.get(fingerprint);
materialsForFingerprint.add(material);
}
}
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class SCMConfigXmlWriterTest method shouldAllowSCMTypeMaterialForPipeline.
@Test
public void shouldAllowSCMTypeMaterialForPipeline() throws Exception {
CruiseConfig configToSave = new BasicCruiseConfig();
SCM scm = new SCM();
String scmId = "scm-id";
scm.setId(scmId);
scm.setName("name");
scm.setPluginConfiguration(new PluginConfiguration("plugin-id", "1.0"));
scm.setConfiguration(new Configuration(getConfigurationProperty("url", false, "http://go")));
configToSave.getSCMs().add(scm);
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(scmId);
pluggableSCMMaterialConfig.setSCMConfig(scm);
configToSave.addPipeline("default", PipelineConfigMother.pipelineConfig("test", new MaterialConfigs(pluggableSCMMaterialConfig), new JobConfigs(new JobConfig("ls"))));
xmlWriter.write(configToSave, output, false);
GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(output.toString());
PipelineConfig pipelineConfig = goConfigHolder.config.pipelineConfigByName(new CaseInsensitiveString("test"));
MaterialConfig materialConfig = pipelineConfig.materialConfigs().get(0);
assertThat(materialConfig instanceof PluggableSCMMaterialConfig, is(true));
assertThat(((PluggableSCMMaterialConfig) materialConfig).getScmId(), is(scmId));
assertThat(((PluggableSCMMaterialConfig) materialConfig).getSCMConfig(), is(scm));
assertThat(materialConfig.getFolder(), is(nullValue()));
assertThat(materialConfig.filter(), is(new Filter()));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class GoConfigFileHelper method addMaterialToPipeline.
public PipelineConfig addMaterialToPipeline(String pipelineName, MaterialConfig materialConfig) {
CruiseConfig config = loadForEdit();
PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
for (MaterialConfig materialConfig1 : new MaterialConfig[] { materialConfig }) {
pipelineConfig.addMaterialConfig(materialConfig1);
}
writeConfigFile(config);
return pipelineConfig;
}
Aggregations