use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class PartialConfigMother method withPipelineMultipleMaterials.
public static PartialConfig withPipelineMultipleMaterials(String name, RepoConfigOrigin repoOrigin) {
GitMaterialConfig gitMaterialConfig = MaterialConfigsMother.gitMaterialConfig();
gitMaterialConfig.setFolder("git");
SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
svnMaterialConfig.setFolder("svn");
PipelineConfig pipe = PipelineConfigMother.pipelineConfig(name, new MaterialConfigs(gitMaterialConfig, svnMaterialConfig));
BasicPipelineConfigs pipes = new BasicPipelineConfigs(pipe);
pipes.setGroup("group");
PartialConfig partialConfig = new PartialConfig(new PipelineGroups(pipes));
partialConfig.setOrigins(repoOrigin);
return partialConfig;
}
use of com.thoughtworks.go.config.materials.MaterialConfigs 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.materials.MaterialConfigs in project gocd by gocd.
the class FanInGraph method createFinalRevisionsForScmChildren.
private List<MaterialRevision> createFinalRevisionsForScmChildren(PipelineTimelineEntry latestRootNodeInstance, List<RootFanInNode> scmChildren, List<DependencyFanInNode> depChildren) {
Set<FaninScmMaterial> scmMaterialsFromDepChildren = scmMaterialsOfDepChildren(depChildren);
List<MaterialRevision> finalRevisions = new ArrayList<>();
for (RootFanInNode child : scmChildren) {
child.setScmRevision(scmMaterialsFromDepChildren);
MaterialConfig materialConfig = child.materialConfig;
Material material = materialConfigConverter.toMaterial(materialConfig);
MaterialRevision revision = new MaterialRevision(material);
if (latestRootNodeInstance != null) {
PipelineInstanceModel pipeline = pipelineDao.findPipelineHistoryByNameAndCounter(latestRootNodeInstance.getPipelineName(), latestRootNodeInstance.getCounter());
for (MaterialRevision materialRevision : pipeline.getCurrentRevisions()) {
if (materialRevision.getMaterial().getFingerprint().equals(child.materialConfig.getFingerprint())) {
List<Modification> modificationsSince = materialRepository.findModificationsSinceAndUptil(material, materialRevision, child.scmRevision);
revision.addModifications(modificationsSince);
break;
}
}
}
if (revision.getModifications().isEmpty() && child.scmRevision == null) {
MaterialRevisions latestRevisions = materialRepository.findLatestRevisions(new MaterialConfigs(materialConfig));
finalRevisions.addAll(latestRevisions.getRevisions());
continue;
}
if (revision.getModifications().isEmpty()) {
revision = new MaterialRevision(material, materialRepository.findModificationWithRevision(material, child.scmRevision.revision));
}
finalRevisions.add(revision);
}
return finalRevisions;
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class DeletePackageRepositoryCommandTest method shouldNotDeletePackageRepositoryIfItIsUsedAsAMaterialInPipeline.
@Test
public void shouldNotDeletePackageRepositoryIfItIsUsedAsAMaterialInPipeline() throws Exception {
PackageDefinition pkg = new PackageDefinition();
pkg.setId("pkg");
packageRepository.addPackage(pkg);
PackageMaterialConfig packageMaterial = new PackageMaterialConfig("pkg");
PipelineConfig pipeline = new PipelineConfig();
pipeline.setMaterialConfigs(new MaterialConfigs(packageMaterial));
cruiseConfig.addPipeline("first", pipeline);
assertThat(cruiseConfig.getPackageRepositories().size(), is(1));
assertThat(cruiseConfig.getPackageRepositories().find(repoId), is(packageRepository));
DeletePackageRepositoryCommand command = new DeletePackageRepositoryCommand(goConfigService, packageRepository, currentUser, result);
command.update(cruiseConfig);
assertFalse(command.isValid(cruiseConfig));
}
use of com.thoughtworks.go.config.materials.MaterialConfigs in project gocd by gocd.
the class GoConfigService method findMaterial.
public MaterialConfig findMaterial(final CaseInsensitiveString pipeline, String pipelineUniqueFingerprint) {
MaterialConfigs materialConfigs = materialConfigsFor(pipeline);
for (MaterialConfig materialConfig : materialConfigs) {
if (pipelineUniqueFingerprint.equals(materialConfig.getPipelineUniqueFingerprint())) {
return materialConfig;
}
}
LOGGER.error("material with fingerprint [{}] not found in pipeline [{}]", pipelineUniqueFingerprint, pipeline);
return null;
}
Aggregations