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 PipelineConfig method isConfigOriginSameAsOneOfMaterials.
public boolean isConfigOriginSameAsOneOfMaterials() {
if (!(isConfigDefinedRemotely()))
return false;
RepoConfigOrigin repoConfigOrigin = (RepoConfigOrigin) this.origin;
MaterialConfig configMaterial = repoConfigOrigin.getMaterial();
for (MaterialConfig material : this.materialConfigs()) {
if (material.getFingerprint().equals(configMaterial.getFingerprint()))
return true;
}
return false;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class PipelineConfigTreeValidator method validateDependencyMaterialsForDownstreams.
private void validateDependencyMaterialsForDownstreams(PipelineConfigSaveValidationContext validationContext, CaseInsensitiveString selected, PipelineConfig downstreamPipeline) {
Node dependenciesOfSelectedPipeline = validationContext.getDependencyMaterialsFor(selected);
for (Node.DependencyNode dependencyNode : dependenciesOfSelectedPipeline.getDependencies()) {
if (dependencyNode.getPipelineName().equals(pipelineConfig.name())) {
for (MaterialConfig materialConfig : downstreamPipeline.materialConfigs()) {
if (materialConfig instanceof DependencyMaterialConfig) {
DependencyMaterialConfig dependencyMaterialConfig = new Cloner().deepClone((DependencyMaterialConfig) materialConfig);
dependencyMaterialConfig.validate(validationContext.withParent(downstreamPipeline));
List<String> allErrors = dependencyMaterialConfig.errors().getAll();
for (String error : allErrors) {
pipelineConfig.errors().add("base", error);
}
}
}
}
}
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class MaterialConfigs method validateDestinationFolder.
private void validateDestinationFolder(List<MaterialConfig> allSCMMaterials, MaterialConfig material) {
String materialFolder = material.getFolder();
for (MaterialConfig otherMaterial : allSCMMaterials) {
if (otherMaterial != material) {
if (otherMaterial instanceof ScmMaterialConfig) {
((ScmMaterialConfig) otherMaterial).validateNotSubdirectoryOf(materialFolder);
((ScmMaterialConfig) otherMaterial).validateDestinationDirectoryName(materialFolder);
} else {
((PluggableSCMMaterialConfig) otherMaterial).validateNotSubdirectoryOf(materialFolder);
((PluggableSCMMaterialConfig) otherMaterial).validateDestinationDirectoryName(materialFolder);
}
}
}
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class CruiseConfigTestBase method shouldReturnAllUniqueSchedulableScmMaterials.
@Test
public void shouldReturnAllUniqueSchedulableScmMaterials() {
final MaterialConfig svnMaterialConfig = new SvnMaterialConfig("http://svn_url_1", "username", "password", false);
svnMaterialConfig.setAutoUpdate(false);
final MaterialConfig svnMaterialConfigWithAutoUpdate = new SvnMaterialConfig("http://svn_url_2", "username", "password", false);
svnMaterialConfigWithAutoUpdate.setAutoUpdate(true);
final MaterialConfig hgMaterialConfig = new HgMaterialConfig("http://hg_url", null);
hgMaterialConfig.setAutoUpdate(false);
final MaterialConfig gitMaterialConfig = new GitMaterialConfig("http://git_url");
gitMaterialConfig.setAutoUpdate(false);
final MaterialConfig tfsMaterialConfig = new TfsMaterialConfig(mock(GoCipher.class), new UrlArgument("http://tfs_url"), "username", "domain", "password", "project_path");
tfsMaterialConfig.setAutoUpdate(false);
final MaterialConfig p4MaterialConfig = new P4MaterialConfig("http://p4_url", "view", "username");
p4MaterialConfig.setAutoUpdate(false);
final MaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
final PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig("scm-id-1", null, null);
pluggableSCMMaterialConfig.getSCMConfig().setAutoUpdate(false);
final PipelineConfig p1 = PipelineConfigMother.pipelineConfig("pipeline1", new MaterialConfigs(svnMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p2 = PipelineConfigMother.pipelineConfig("pipeline2", new MaterialConfigs(svnMaterialConfig, gitMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p3 = PipelineConfigMother.pipelineConfig("pipeline3", new MaterialConfigs(hgMaterialConfig, dependencyMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p4 = PipelineConfigMother.pipelineConfig("pipeline4", new MaterialConfigs(p4MaterialConfig, pluggableSCMMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
final PipelineConfig p5 = PipelineConfigMother.pipelineConfig("pipeline5", new MaterialConfigs(svnMaterialConfigWithAutoUpdate, tfsMaterialConfig), new JobConfigs(new JobConfig(new CaseInsensitiveString("jobName"))));
cruiseConfig.getGroups().add(new BasicPipelineConfigs(p1, p2, p3, p4, p5));
final Set<MaterialConfig> materials = cruiseConfig.getAllUniquePostCommitSchedulableMaterials();
assertThat(materials.size(), is(6));
assertThat(materials, hasItems(svnMaterialConfig, hgMaterialConfig, gitMaterialConfig, tfsMaterialConfig, p4MaterialConfig, pluggableSCMMaterialConfig));
assertThat(materials, not(hasItem(svnMaterialConfigWithAutoUpdate)));
}
Aggregations