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 BasicCruiseConfig method generatePipelineVsDownstreamMap.
@Override
public Map<CaseInsensitiveString, List<PipelineConfig>> generatePipelineVsDownstreamMap() {
List<PipelineConfig> pipelineConfigs = getAllPipelineConfigs();
Map<CaseInsensitiveString, List<PipelineConfig>> result = new HashMap<>();
for (PipelineConfig currentPipeline : pipelineConfigs) {
CaseInsensitiveString currentPipelineName = currentPipeline.name();
if (!result.containsKey(currentPipelineName)) {
result.put(currentPipelineName, new ArrayList<>());
}
for (MaterialConfig materialConfig : currentPipeline.materialConfigs()) {
if (materialConfig instanceof DependencyMaterialConfig) {
CaseInsensitiveString pipelineWhichTriggersMe = ((DependencyMaterialConfig) materialConfig).getPipelineName();
if (!result.containsKey(pipelineWhichTriggersMe)) {
result.put(pipelineWhichTriggersMe, new ArrayList<>());
}
result.get(pipelineWhichTriggersMe).add(currentPipeline);
}
}
}
return result;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class DependencyFanInNode method validateIfRevisionMatchesTheCurrentConfigAndUpdateTheMaterialMap.
private void validateIfRevisionMatchesTheCurrentConfigAndUpdateTheMaterialMap(FanInGraphContext context, Pair<StageIdentifier, List<FaninScmMaterial>> stageIdentifierScmPair) {
final Set<MaterialConfig> currentScmMaterials = context.pipelineScmDepMap.get(materialConfig);
final Set<FaninScmMaterial> scmMaterials = new HashSet<>(stageIdentifierScmPair.last());
final Set<String> currentScmFingerprint = new HashSet<>();
for (MaterialConfig currentScmMaterial : currentScmMaterials) {
currentScmFingerprint.add(currentScmMaterial.getFingerprint());
}
final Set<String> scmMaterialsFingerprint = new HashSet<>();
for (FaninScmMaterial scmMaterial : scmMaterials) {
scmMaterialsFingerprint.add(scmMaterial.fingerprint);
}
final Collection commonMaterials = CollectionUtils.intersection(currentScmFingerprint, scmMaterialsFingerprint);
if (commonMaterials.size() == scmMaterials.size() && commonMaterials.size() == currentScmMaterials.size()) {
stageIdentifierScmMaterial.put(stageIdentifierScmPair.first(), scmMaterials);
++currentCount;
} else {
Collection disjunctionWithConfig = CollectionUtils.disjunction(currentScmFingerprint, commonMaterials);
Collection disjunctionWithInstance = CollectionUtils.disjunction(scmMaterialsFingerprint, commonMaterials);
LOGGER.warn("[Fan-in] - Incompatible materials for {}. Config: {}. Instance: {}.", stageIdentifierScmPair.first().getStageLocator(), disjunctionWithConfig, disjunctionWithInstance);
// This is it. We will not go beyond this revision in history
totalInstanceCount = currentCount;
}
}
use of com.thoughtworks.go.domain.materials.MaterialConfig 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.domain.materials.MaterialConfig 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;
}
Aggregations